@@ -140,16 +140,30 @@ jobs:
140140 machine :
141141 docker_layer_caching : false # only for performance plan circleci accounts
142142 parameters :
143+ account-id :
144+ type : string
145+ default : ' '
146+ description : |
147+ The id of the aws account containing the ECR repo to push an image to.
143148 repo :
144149 type : string
145150 default : ' '
146151 description : |
147152 The name of the ECR repo to push an image to.
153+ region :
154+ type : string
155+ default : ' '
156+ description : |
157+ The region to use for AWS operations.
148158 steps :
149159 - attach_workspace :
150160 at : *workspace
151161 - run : *checkout-shallow
152162 - version-tag/create
163+ - run : # Required by aws-cli
164+ command : |
165+ echo 'export AWS_REGION=<< parameters.region >>' >> $BASH_ENV
166+ echo 'export AWS_ECR_ACCOUNT_URL=<< parameters.account-id >>.dkr.ecr.<< parameters.region >>.amazonaws.com' >> $BASH_ENV
153167 - aws-ecr/build-and-push-image :
154168 repo : << parameters.repo >>
155169 tag : $VERSION_TAG,latest
@@ -162,6 +176,11 @@ jobs:
162176 default : ' '
163177 description : |
164178 The kubernetes namespace that should be used.
179+ account-id :
180+ type : string
181+ default : ' '
182+ description : |
183+ The id of the aws account containing the ECR repo to push an image to.
165184 repo :
166185 type : string
167186 default : ' '
@@ -214,7 +233,7 @@ jobs:
214233 command : |
215234 kubectl create namespace << parameters.namespace >> || echo "Namespace already exists"
216235 cd kubernetes/overlays/<< parameters.config-environment >>
217- IMAGE=<% index .Params `accountId` % >.dkr.ecr.<< parameters.region >>.amazonaws.com/<< parameters.repo >>
236+ IMAGE=<< parameters.account-id > >.dkr.ecr.<< parameters.region >>.amazonaws.com/<< parameters.repo >>
218237 kustomize edit set image fake-image=${IMAGE}:${VERSION_TAG}
219238 kustomize build . | kubectl apply -f - -n << parameters.namespace >>
220239workflows :
@@ -229,7 +248,9 @@ workflows:
229248 - checkout_code
230249
231250 - build_and_push :
232- repo : <% .Name %>
251+ account-id : " <% index .Params `accountId` % >"
252+ repo : " <% .Name % >"
253+ region : " <% index .Params `region` % >"
233254 requires :
234255 - unit_test
235256 filters :
@@ -239,6 +260,7 @@ workflows:
239260
240261 - deploy :
241262 name : deploy_staging
263+ account-id : " <% index .Params `accountId` % >"
242264 repo : " <% .Name % >"
243265 cluster-name : " <% .Name % >-staging-<% index .Params `region` % >"
244266 config-environment : " staging"
0 commit comments