-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS CLI Verison 2 support #40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
Related to my question in #39, could we drop support for aws-cli
< 1.17.10 in this plugin release? Seems reasonable to me.
I think that would cause quite a bit of chaos, since 1.17.10 was only tagged 28 days ago. We could however drop support for < 1.11.91 re. the |
This commit adds the foundations to version-check awscli for ecr get-login-password support, and send that down a different code path. However the implementation is currently the same, and will not work for awscli v2+
For awscli >= 1.17.10 we now use `aws ecr get-login-password` instead of the deprecated (removed in 2.0.0) `aws ecr get-login`. As a result, we need to build the registry address, which means determining the AWS region and account ID. If the AWS region is not specified in the existing plugin config options, AWS_DEFAULT_REGION is used, which default to us-east-1. If the AWS account ID is not specified in the existing plugin config options, it is (hopefully) found with `aws sts get-caller-identity`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, yeah having thought that through, that would be chaos.
🚀
Rebased, tests still look good:
|
Otherwise AWS_DEFAULT_REGION (which defaults to us-east-1) is always used for 'aws ecr get-login-password', but 'docker login' runs against the region specified by plugin config. If they differ, the docker login fails. Leaving region completely unspecified produces a warning, but still defaults to us-east-1 for compatibility.
I found a bug in my implementation; potential AWS region mismatch between the |
awscli v2.0.0 removed the
aws ecr get-login
command, in favour of theaws ecr get-login-password
command which was introduced very recently in v1.17.10 via aws/aws-cli#4874 . In order for ecr-buildkite-plugin to support new and slightly-less-new versions of the AWS CLI, we need to decide which to use by version-checking.Additionally, the new
get-login-password
no longer provides the ECR registry address(es), so we need to build them with knowledge of the AWS account ID and region.AWS region is determined by:
registry-region
plugin config)region
plugin configAWS_DEFAULT_REGION
environmentus-east-1
default.AWS account IDs are determined by:
account-ids
plugin config (YAML array, or legacy comma-separated)aws sts get-caller-identity
If multiple
account-ids
are configured, a singleaws ecr get-login-password
call is made, and multipledocker login ...
are made; one for each account/registry. This is correct according to aws/aws-cli#4874 (comment) and https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_auth:Fixes #37