Skip to content

Commit 13835df

Browse files
committed
get region from environmnet
1 parent 8f7c326 commit 13835df

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

hooks/lib/ecr-registry-provider.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ login() {
55
$(aws ecr get-login --no-include-email)
66
else
77
local account_id=$(aws sts get-caller-identity --query Account --output text)
8-
local region=$(aws configure get region)
8+
local region=$AWS_REGION
99

1010
aws ecr get-login-password \
1111
--region "${region}" \

tests/ecr-registry-provider.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ pre_command_hook="$PWD/hooks/pre-command"
9393
}
9494

9595
@test "ECR: Applies lifecycle policy to existing repositories with aws-cli v2" {
96+
export AWS_REGION="ap-southeast-2"
9697
export BUILDKITE_ORGANIZATION_SLUG="example-org"
9798
export BUILDKITE_PIPELINE_SLUG="example-pipeline"
9899
local expected_repository_name="build-cache/example-org/example-pipeline"
99100

100101
stub aws \
101102
"--version : echo 'aws-cli/2.4.15 Python/3.9.2 Linux/5.10.76-linuxkit botocore/1.24.3'" \
102-
"sts get-caller-identity --query \"Account\" --output text : echo 1234567891012" \
103-
"configure get region : echo ap-southeast-2" \
103+
"sts get-caller-identity --query Account --output text : echo 1234567891012" \
104104
"ecr get-login-password --region ap-southeast-2 : echo secure-ecr-password" \
105105
"ecr describe-repositories --repository-names ${expected_repository_name} --output text --query repositories[0].registryId : echo looked up repository" \
106106
"ecr describe-repositories --repository-names ${expected_repository_name} --output text --query repositories[0].repositoryArn : echo arn:aws:ecr:ap-southeast-2:1234567891012:repository/${expected_repository_name}" \
@@ -133,15 +133,15 @@ pre_command_hook="$PWD/hooks/pre-command"
133133
}
134134

135135
@test "ECR: Builds new images with tags with aws-cli v2" {
136+
export AWS_REGION="ap-southeast-2"
136137
export BUILDKITE_ORGANIZATION_SLUG="example-org"
137138
export BUILDKITE_PIPELINE_SLUG="example-pipeline"
138139
local expected_repository_name="build-cache/example-org/example-pipeline"
139140
local repository_uri="1234567891012.dkr.ecr.ap-southeast-2.amazonaws.com/${expected_repository_name}"
140141

141142
stub aws \
142143
"--version : echo 'aws-cli/2.4.15 Python/3.9.2 Linux/5.10.76-linuxkit botocore/1.24.3'" \
143-
"sts get-caller-identity --query \"Account\" --output text : echo 1234567891012" \
144-
"configure get region : echo ap-southeast-2" \
144+
"sts get-caller-identity --query Account --output text : echo 1234567891012" \
145145
"ecr get-login-password --region ap-southeast-2 : echo secure-ecr-password" \
146146
"ecr describe-repositories --repository-names ${expected_repository_name} --output text --query repositories[0].registryId : echo looked up repository" \
147147
"ecr describe-repositories --repository-names ${expected_repository_name} --output text --query repositories[0].repositoryArn : echo arn:aws:ecr:ap-southeast-2:1234567891012:repository/${expected_repository_name}" \

0 commit comments

Comments
 (0)