Skip to content

Commit 5151f67

Browse files
authored
Updates to use new version of aws cli (#353)
* Refactor tests * fix naming * Add alias to matrix * Add subname * Add context to login job * remove macos * fix * Update setup * Use only default profile * Don't ask confirmation to install credentials helper
1 parent f81b5a8 commit 5151f67

File tree

2 files changed

+98
-27
lines changed

2 files changed

+98
-27
lines changed

.circleci/test-deploy.yml

Lines changed: 97 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22
orbs:
33
orb-tools: circleci/[email protected]
4-
aws-cli: circleci/aws-cli@4.0
4+
aws-cli: circleci/aws-cli@5.1.0
55
aws-ecr: {}
66
filters: &filters
77
tags:
@@ -52,6 +52,23 @@ jobs:
5252
source_tag: <<parameters.source_tag>>
5353
target_tag: <<parameters.target_tag>>
5454
profile_name: <<parameters.profile_name>>
55+
login:
56+
executor: <<parameters.executor>>
57+
parameters:
58+
region:
59+
type: string
60+
profile_name:
61+
type: string
62+
executor:
63+
type: executor
64+
auth:
65+
type: steps
66+
steps:
67+
- steps: <<parameters.auth>>
68+
- aws-ecr/ecr_login:
69+
profile_name: <<parameters.profile_name>>
70+
region: <<parameters.region>>
71+
5572
build-test-then-push-with-buildx:
5673
machine:
5774
image: ubuntu-2204:current
@@ -113,6 +130,9 @@ workflows:
113130
auth:
114131
- aws-cli/setup:
115132
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
133+
profile_name: "default"
134+
role_session_name: ecr-orb-test-session-buildx
135+
region: "us-west-2"
116136
attach_workspace: true
117137
workspace_root: workspace
118138
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-build-test-then-push-with-buildx
@@ -135,6 +155,9 @@ workflows:
135155
auth:
136156
- aws-cli/setup:
137157
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
158+
profile_name: "default"
159+
role_session_name: ecr-orb-test-session-nopush
160+
region: "us-west-2"
138161
attach_workspace: true
139162
workspace_root: workspace
140163
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-multi-platform-without-push
@@ -157,6 +180,9 @@ workflows:
157180
auth:
158181
- aws-cli/setup:
159182
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
183+
profile_name: "default"
184+
role_session_name: ecr-orb-test-session-default
185+
region: "us-west-2"
160186
attach_workspace: true
161187
workspace_root: workspace
162188
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-default-profile
@@ -180,6 +206,9 @@ workflows:
180206
auth:
181207
- aws-cli/setup:
182208
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
209+
profile_name: "default"
210+
role_session_name: ecr-orb-test-session-cred-helper
211+
region: "us-west-2"
183212
attach_workspace: true
184213
workspace_root: workspace
185214
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-credential-helper
@@ -210,6 +239,9 @@ workflows:
210239
auth:
211240
- aws-cli/setup:
212241
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
242+
profile_name: "default"
243+
role_session_name: ecr-orb-test-session-cache
244+
region: "us-west-2"
213245
attach_workspace: true
214246
workspace_root: workspace
215247
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-cache-to-flag
@@ -226,13 +258,15 @@ workflows:
226258
auth:
227259
- aws-cli/setup:
228260
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
229-
profile_name: "OIDC-User"
261+
profile_name: "default"
262+
role_session_name: ecr-orb-test-session-public-registry
263+
region: "us-west-2"
230264
attach_workspace: true
231265
workspace_root: workspace
232266
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-public_registry
233267
create_repo: true
234268
region: "us-west-2"
235-
profile_name: "OIDC-User"
269+
profile_name: "default"
236270
context: [CPE-OIDC]
237271
tag: integration,myECRRepoTag
238272
dockerfile: Dockerfile
@@ -243,7 +277,7 @@ workflows:
243277
post-steps:
244278
- run:
245279
name: "Delete repository"
246-
command: aws ecr-public delete-repository --region us-east-1 --repository-name aws-ecr-orb-${CIRCLE_SHA1:0:7}-public_registry --force --profile OIDC-User
280+
command: aws ecr-public delete-repository --region us-east-1 --repository-name aws-ecr-orb-${CIRCLE_SHA1:0:7}-public_registry --force --profile default
247281
platform: linux/arm64,linux/amd64
248282
filters: *filters
249283
requires: [pre-integration]
@@ -256,11 +290,14 @@ workflows:
256290
auth:
257291
- aws-cli/setup:
258292
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
259-
profile_name: "OIDC-User"
293+
profile_name: "default"
294+
role_session_name: ecr-orb-test-session-cred-helper-<<matrix.use_credentials_helper>>
295+
region: "us-west-2"
260296
attach_workspace: true
261297
region: "us-west-2"
262-
profile_name: "OIDC-User"
298+
profile_name: "default"
263299
matrix:
300+
alias: integration-test-named-profile
264301
parameters:
265302
use_credentials_helper: [true, false]
266303
context: [CPE-OIDC]
@@ -283,10 +320,12 @@ workflows:
283320
auth:
284321
- aws-cli/setup:
285322
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
286-
profile_name: "OIDC-User"
323+
profile_name: "default"
324+
role_session_name: ecr-orb-test-session-tag-existing
325+
region: "us-west-2"
287326
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-named-profile-true
288327
region: "us-west-2"
289-
profile_name: "OIDC-User"
328+
profile_name: "default"
290329
context: [CPE-OIDC]
291330
source_tag: integration
292331
target_tag: latest
@@ -297,18 +336,20 @@ workflows:
297336
auth:
298337
- aws-cli/setup:
299338
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
300-
profile_name: "OIDC-User"
339+
profile_name: "default"
340+
role_session_name: ecr-orb-test-session-existing
341+
region: "us-west-2"
301342
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-named-profile-true
302343
region: "us-west-2"
303-
profile_name: "OIDC-User"
344+
profile_name: "default"
304345
context: [CPE-OIDC]
305346
source_tag: integration
306347
target_tag: alpha,latest
307348
skip_when_tags_exist: true
308349
post-steps:
309350
- run:
310351
name: "Delete repository"
311-
command: aws ecr delete-repository --repository-name aws-ecr-orb-${CIRCLE_SHA1:0:7}-named-profile-true --force --profile OIDC-User
352+
command: aws ecr delete-repository --repository-name aws-ecr-orb-${CIRCLE_SHA1:0:7}-named-profile-true --force --profile default
312353
filters: *filters
313354
requires:
314355
- integration-test-tag-existing-image
@@ -317,10 +358,12 @@ workflows:
317358
auth:
318359
- aws-cli/setup:
319360
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
320-
profile_name: "OIDC-User"
361+
profile_name: "default"
362+
role_session_name: ecr-orb-test-session-populate-<<matrix.executor>>
363+
region: "us-west-2"
321364
attach_workspace: true
322365
region: "us-west-2"
323-
profile_name: "OIDC-User"
366+
profile_name: "default"
324367
context: [CPE-OIDC]
325368
workspace_root: workspace
326369
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-skip_when_tags_exist-<<matrix.executor>>
@@ -332,6 +375,7 @@ workflows:
332375
extra_build_args: --compress
333376
skip_when_tags_exist: true
334377
matrix:
378+
alias: integration-test-skip_when_tags_exist-populate-image
335379
parameters:
336380
executor: ["arm64", "amd64"]
337381
filters: *filters
@@ -341,10 +385,12 @@ workflows:
341385
auth:
342386
- aws-cli/setup:
343387
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
344-
profile_name: "OIDC-User"
388+
profile_name: "default"
389+
role_session_name: ecr-orb-test-session-<<matrix.executor>>
390+
region: "us-west-2"
345391
attach_workspace: true
346392
region: "us-west-2"
347-
profile_name: "OIDC-User"
393+
profile_name: "default"
348394
context: [CPE-OIDC]
349395
workspace_root: workspace
350396
repo: aws-ecr-orb-${CIRCLE_SHA1:0:7}-skip_when_tags_exist-<<matrix.executor>>
@@ -358,26 +404,51 @@ workflows:
358404
- run:
359405
name: "Delete repository"
360406
command: |
361-
aws ecr delete-repository --repository-name aws-ecr-orb-${CIRCLE_SHA1:0:7}-skip_when_tags_exist-<<matrix.executor>> --force --profile OIDC-User
407+
aws ecr delete-repository --repository-name aws-ecr-orb-${CIRCLE_SHA1:0:7}-skip_when_tags_exist-<<matrix.executor>> --force --profile default
362408
matrix:
409+
alias: integration-test-skip_when_tags_exist
363410
parameters:
364-
executor: ["amd64", "arm64"]
411+
executor: ["arm64", "amd64"]
365412
filters: *filters
366413
requires:
367-
- integration-test-skip_when_tags_exist-populate-image-amd64
368-
- integration-test-skip_when_tags_exist-populate-image-arm64
369-
- orb-tools/lint:
370-
filters: *filters
371-
- orb-tools/pack:
372-
filters: *filters
373-
- orb-tools/review:
374-
filters: *release-filters
414+
- integration-test-skip_when_tags_exist-populate-image
415+
- login:
416+
name: login-<<matrix.executor>>
417+
auth:
418+
- aws-cli/setup:
419+
role_arn: arn:aws:iam::122211685980:role/CPE_ECR_OIDC_TEST
420+
profile_name: "default"
421+
role_session_name: ecr-orb-test-session-login-<<matrix.executor>>
422+
region: "us-west-2"
423+
profile_name: "default"
424+
region: "us-west-2"
425+
context: [CPE-OIDC]
426+
requires: [pre-integration]
427+
matrix:
428+
alias: login
429+
parameters:
430+
executor: ["arm64", "amd64"]
431+
post-steps:
432+
- run:
433+
name: "Validation"
434+
command: |
435+
aws sts get-caller-identity --profile default
375436
- orb-tools/publish:
376437
orb_name: circleci/aws-ecr
377438
vcs_type: << pipeline.project.type >>
378439
pub_type: production
379440
enable_pr_comment: true
380-
requires: [ orb-tools/lint, orb-tools/review, orb-tools/pack, integration-test-default-profile, integration-test-pubic-registry, integration-test-skip_when_tags_exist-amd64, integration-test-skip_when_tags_exist-arm64, integration-test-named-profile-true-helper, integration-test-named-profile-false-helper, integration-test-tag-existing-image, integration-test-tag-image-with-existing-tag ]
441+
requires:
442+
- build-test-then-push-with-buildx
443+
- integration-test-multi-platform-without-push
444+
- integration-test-default-profile
445+
- integration-test-aws-ecr-credential-helper
446+
- integration-test-cache-to-flag
447+
- integration-test-pubic-registry
448+
- integration-test-skip_when_tags_exist
449+
- integration-test-named-profile-false-helper
450+
- login
451+
- integration-test-tag-image-with-existing-tag
381452
github_token: GHI_TOKEN
382453
context: orb-publisher
383454
filters: *release-filters

src/scripts/ecr_login.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ install_aws_ecr_credential_helper(){
5151
HELPER_INSTALLED=$(dpkg --get-selections | (grep amazon-ecr-credential-helper || test $?) | awk '{print $2}')
5252
if [[ "$HELPER_INSTALLED" != "install" ]]; then
5353
$SUDO apt update
54-
$SUDO apt install amazon-ecr-credential-helper
54+
$SUDO apt -y install amazon-ecr-credential-helper
5555
fi
5656
configure_config_json
5757
elif [[ "$SYS_ENV_PLATFORM" = "macos" && "$AWS_ECR_BOOL_HELPER" = "1" ]]; then

0 commit comments

Comments
 (0)