snippetpythonMinor
How to install aws cli on a self-hosted azure DevOps Windows agent?
Viewed 0 times
installagenthostedazurecliawshowwindowsdevopsself
Problem
I have quite some difficulties installing aws cli on a self-hosted Azure DevOps Windows agent as part of a pipeline. Does anyone have a working solution?
What I have tried so far:
a) install aws cli via pip
Firstly, I install Python (tried both; Python2 and Python3) within the pipeline (Powershell) by downloading and extracting a tar file. Example:
Secondly, I use the freshly installed Python for installing aws cli. Example:
Aws cli is then installed in the
When I try to execute aws.cmd, I receive an error message:
Similar issues are described here: 1, 2, 3. The suggested solution is, to associate python files with the freshly installed python executable:
I do not feel this is appropriate for an azure agent:
Another option would be, to install the required tools system-wide (python, aws). That would, however, make it difficult to try out a specific (new?) version of python or aws cli.
b) install aws cli via extracted msi package
... extracted the contents of the msi package via
This obviously does not work either. - It actually does work properly with aws cli version 2, but not with aws cli version 1. Version 2 is not recommended for use in production yet.
c) Use AWS Tools for Microsoft Visual Studio Team Services
This is an extension for Azure DevOps,
What I have tried so far:
a) install aws cli via pip
Firstly, I install Python (tried both; Python2 and Python3) within the pipeline (Powershell) by downloading and extracting a tar file. Example:
(New-Object System.Net.WebClient).DownloadFile("$(python3_download_url)", ".\Python.tar")
Expand-7Zip .\Python.tar .Secondly, I use the freshly installed Python for installing aws cli. Example:
$(PYTHON364EXE) -m pip install awscliAws cli is then installed in the
SCRIPTS directory, as expected. When I try to execute aws.cmd, I receive an error message:
File association not found for extension .py
'""' is not recognized as an internal or external command,
operable program or batch fileSimilar issues are described here: 1, 2, 3. The suggested solution is, to associate python files with the freshly installed python executable:
assoc .py=pyautofile
ftype pyautofile="$(PYTHON364EXE)" "%1" %*I do not feel this is appropriate for an azure agent:
- It does not feel right to use Admin permissions for a simple build
- I am worried that the proposed change would impact all agents and the entire host server, while I need it for only one specific agent.
Another option would be, to install the required tools system-wide (python, aws). That would, however, make it difficult to try out a specific (new?) version of python or aws cli.
b) install aws cli via extracted msi package
... extracted the contents of the msi package via
lessmsi, then run the aws cli:C:\AWS> aws
failed to create process.This obviously does not work either. - It actually does work properly with aws cli version 2, but not with aws cli version 1. Version 2 is not recommended for use in production yet.
c) Use AWS Tools for Microsoft Visual Studio Team Services
This is an extension for Azure DevOps,
Solution
The best way to have AWS CLI tooling installed to your custom agent is by installing from Visual Studio Marketplace. AWS CLI is part of AWS Tools for Azure DevOps Service and Azure DevOps Server (the on-premise Azure DevOps) under the name of "AWS Tools for Microsoft Visual Studio Team Services".
Installing this AWS Tools will enable AWS tooling on CI (build pipeline) and CD (release pipeline).
This is the official landing page of AWS Tools in Visual Studio Marketplace:
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-vsts-tools
Official documentation is available at: https://docs.aws.amazon.com/vsts/index.html
Installing this AWS Tools will enable AWS tooling on CI (build pipeline) and CD (release pipeline).
This is the official landing page of AWS Tools in Visual Studio Marketplace:
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-vsts-tools
Official documentation is available at: https://docs.aws.amazon.com/vsts/index.html
Context
StackExchange DevOps Q#9874, answer score: 3
Revisions (0)
No revisions yet.