Skip to content

Commit

Permalink
chore(cicd): update aws-cli ecr get-login (aws#2052)
Browse files Browse the repository at this point in the history
The [`get-login`](https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login.html) command we used previously in our buildspec has been deprecated in AWS CLI v2.
This replaces it with the new [`get-login-password`](https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login-password.html).
The new command doesn't automatically print a `docker login` command, so that has been added.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
  • Loading branch information
huanjani committed Mar 15, 2021
1 parent d7214ac commit 2479051
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ Resources:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
PrivilegedMode: true
Image: aws/codebuild/amazonlinux2-x86_64-standard:1.0
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
EnvironmentVariables:
- Name: AWS_ACCOUNT_ID
Value: !Sub '${AWS::AccountId}'
Source:
Type: CODEPIPELINE
BuildSpec: copilot/buildspec.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ Resources:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
PrivilegedMode: true
Image: aws/codebuild/amazonlinux2-x86_64-standard:1.0
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
EnvironmentVariables:
- Name: AWS_ACCOUNT_ID
Value: !Sub '${AWS::AccountId}'
Source:
Type: CODEPIPELINE
BuildSpec: copilot/buildspec.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ Resources:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
PrivilegedMode: true
Image: aws/codebuild/amazonlinux2-x86_64-standard:1.0
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
EnvironmentVariables:
- Name: AWS_ACCOUNT_ID
Value: !Sub '${AWS::AccountId}'
Source:
Type: CODEPIPELINE
BuildSpec: copilot/buildspec.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ Resources:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
PrivilegedMode: true
Image: aws/codebuild/amazonlinux2-x86_64-standard:1.0
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
EnvironmentVariables:
- Name: AWS_ACCOUNT_ID
Value: !Sub '${AWS::AccountId}'
Source:
Type: CODEPIPELINE
BuildSpec: copilot/buildspec.yml
Expand Down
2 changes: 1 addition & 1 deletion templates/cicd/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ phases:
for env in $envs; do
repo=$(cat $CODEBUILD_SRC_DIR/infrastructure/$workload-$env.params.json | jq '.Parameters.ContainerImage' | sed 's/"//g');
region=$(echo $repo | cut -d'.' -f4);
$(aws ecr get-login --no-include-email --region $region);
$(aws ecr get-login-password --region $region | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$region.amazonaws.com);
docker tag $image_id $repo;
docker push $repo;
done;
Expand Down
5 changes: 4 additions & 1 deletion templates/cicd/pipeline_cfn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ Resources:
Type: LINUX_CONTAINER
ComputeType: BUILD_GENERAL1_SMALL
PrivilegedMode: true
Image: aws/codebuild/amazonlinux2-x86_64-standard:1.0
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
EnvironmentVariables:
- Name: AWS_ACCOUNT_ID
Value: !Sub '${AWS::AccountId}'
Source:
Type: CODEPIPELINE
BuildSpec: copilot/buildspec.yml
Expand Down

0 comments on commit 2479051

Please sign in to comment.