aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
245 stars 104 forks source link

EC2 Container Registry support? #29

Closed Tharnas closed 6 years ago

Tharnas commented 6 years ago

Is there a way to deploy docker images to ECR on a Linux build server?

There is the "AWS Tools for Windows PowerShell scripts" Task but PowerShell does not work on Linux. With "AWS CLI commands" it is also not possible to login docker to AWS ECR.

stevejroberts commented 6 years ago

We don't currently have a task that can deploy an image to ECR. I've added the request to our backlog of new features to address.

In the meantime, there are a couple of options that might work for you:

  1. The AWS CLI has a get login command that will retrieve the necessary login command for ECR.
  2. A similar command, Get-ECRLoginCommand is also available in the AWS Tools for PowerShell (both desktop and PowerShell Core editions). As you are using Linux you would need to install PowerShell 6 and install the AWSPowerShell.NetCore module to get to this command.
cameronattard commented 6 years ago

You can use the Docker tasks with ECR if you install amazon-ecr-credential-helper on your agents.

Tharnas commented 6 years ago

Many thanks for your help.

@cameronattard: amazon-ecr-credential-helper looks interesting but I don't really like to persist my credentials on the build server.

Tharnas commented 6 years ago

@steveataws: I installed PowerShell 6 on linux but I cannot trigger the deployment of a release. The following error message is shown:

There are issues with the release definition that may prevent deployment of release

Issues with Environment '\': Issues with deploy phase 'Run on agent' - No agents could be found that match the following demands (queue: '\'): DotNetFramework

Do you want to queue the release anyway?

In case I continue it breaks with the following error in the "Run on agent" step:

Deployment on this environment was cancelled.

stevejroberts commented 6 years ago

Were you trying to run the 'AWS Tools for Windows PowerShell Script Task' by any chance? That task is for the Windows desktop version of PowerShell, and our corresponding module named AWSPowerShell, hence it has a dependency on the 'full' .NET framework.

To run in PowerShell Core on Linux, you need to get the module named AWSPowerShell.NetCore. Start PowerShell Core on Linux and run install-module AWSPowerShell.NetCore.

Once the Linux agent is set up with the installs, you'll need to concoct some form of a shell task to run PowerShell and a script using the NetCore version of our module. I haven't recently looked at the built-in TFS PowerShell tasks to see if any of them now support running PowerShell Core on Linux. If they don't, a shell script to launch PowerShell, set up credentials and then run a script using the AWSPowerShell.NetCore cmdlets would need to be put together.

In a future release we want to circle back and add a task to run scripts using our AWSPowerShell.NetCore module, with the auto-install capability of our existing task. We've some research yet though to figure out best approaches.

Tharnas commented 6 years ago

Ah ok, my bad. Thanks for clarifying!

stevejroberts commented 6 years ago

v1.0.14 is now released with a new task to push an image to an ECR registry.

HTH

Tharnas commented 6 years ago

Many thanks. Works like a charm!

stevejroberts commented 6 years ago

Good to know! Resolving request.