Skip to content

Commit fccc8c4

Browse files
committed
Update Tf Outputs
Why these changes are being introduced: Now that we have ECR Repositories in multiple regions, we need to genarate a few additional lines for each workflow and Makefile when we enable an additional region. How this addresses that need: * Create an additional template file for the Makefile add-ins * Create an additional template file for the dev-build add-ins * Create an additional template file for the stage-build add-ins * Create an additional template file for the prod-promote add-ins * Create a new Tf output for the Makefile add-ins for the bagit Lambda that is deployed in us-west-2 * Create a new Tf output for the dev-build add-ins for the bagit Lambda that is deployed in us-west-2 * Create a new Tf output for the stage-build add-ins for the bagit Lambda that is deployed in us-west-2 * Create a new Tf output for the prod-promote add-ins for the bagit Lambda that is deployed in us-west-2 Side effects of this change: None. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IR-238
1 parent 08e9737 commit fccc8c4

File tree

8 files changed

+114
-46
lines changed

8 files changed

+114
-46
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,13 @@ This is a core infrastructure repository that defines infrastructure related to
270270
| ppod\_prod\_promote\_workflow | Full contents of the prod-promote.yml for the ppod repo |
271271
| ppod\_stage\_build\_workflow | Full contents of the stage-build.yml for the ppod repo |
272272
| s3\_bagit\_validator\_dev\_build\_workflow | Full contents of the dev-build.yml for the s3-bagit-validator repo |
273+
| s3\_bagit\_validator\_dev\_build\_workflow\_west | Additional job for the dev-build.yml for the s3-bagit-validator repo to deploy in us-west-2 |
273274
| s3\_bagit\_validator\_makefile | Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only) |
275+
| s3\_bagit\_validator\_makefile\_west | Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only) |
274276
| s3\_bagit\_validator\_prod\_promote\_workflow | Full contents of the prod-promote.yml for the s3-bagit-validator repo |
277+
| s3\_bagit\_validator\_prod\_promote\_workflow\_west | Additional job for the prod-promote.yml for the s3-bagit-validator repo to deploy in us-west-2 |
275278
| s3\_bagit\_validator\_stage\_build\_workflow | Full contents of the stage-build.yml for the s3-bagit-validator repo |
279+
| s3\_bagit\_validator\_stage\_build\_workflow\_west | Additional job for the stage-build.yml for the s3-bagit-validator repo to deploy in us-west-2 |
276280
| sapinvoices\_dev\_build\_workflow | Full contents of the dev-build.yml for the alma-sapinvoices repo |
277281
| sapinvoices\_makefile | Full contents of the Makefile for the alma-sapinvoices repo (allows devs to push to Dev account only) |
278282
| sapinvoices\_prod\_promote\_workflow | Full contents of the prod-promote.yml for the alma-sapinvoices repo |
File renamed without changes.

cdps_ecrs_west.tf

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,52 @@ module "ecr_cdps_s3_bagit_validator_west" {
1717
}
1818
}
1919

20-
# ## For s3-bagit-validator application repo and ECR repository
21-
# # Outputs in dev
22-
# output "s3_bagit_validator_dev_build_workflow_west" {
23-
# value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/dev-build.tpl", {
24-
# region = var.aws_region
25-
# role = module.ecr_cdps_s3_bagit_validator_west.gha_role
26-
# ecr = module.ecr_cdps_s3_bagit_validator_west.repository_name
27-
# function = local.ecr_cdps_s3_bagit_validator_function_name
28-
# }
29-
# )
30-
# description = "Full contents of the dev-build.yml for the s3-bagit-validator repo to deploy in us-west-2"
31-
# }
32-
# output "s3_bagit_validator_makefile_west" {
33-
# value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/makefile.tpl", {
34-
# ecr_name = module.ecr_cdps_s3_bagit_validator_west.repository_name
35-
# ecr_url = module.ecr_cdps_s3_bagit_validator_west.repository_url
36-
# function = local.ecr_cdps_s3_bagit_validator_function_name
37-
# }
38-
# )
39-
# description = "Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only)"
40-
# }
20+
## For s3-bagit-validator application repo and ECR repository in us-west-2
21+
# Outputs in dev
22+
output "s3_bagit_validator_dev_build_workflow_west" {
23+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/dev-build-extra-region.tpl", {
24+
region = "us-west-2"
25+
role = module.ecr_cdps_s3_bagit_validator.gha_role
26+
ecr = module.ecr_cdps_s3_bagit_validator_west.repository_name
27+
function = local.ecr_cdps_s3_bagit_validator_function_name
28+
}
29+
)
30+
description = "Additional job for the dev-build.yml for the s3-bagit-validator repo to deploy in us-west-2"
31+
}
4132

42-
# # Outputs in stage
43-
# output "s3_bagit_validator_stage_build_workflow_west" {
44-
# value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/stage-build.tpl", {
45-
# region = var.aws_region
46-
# role = module.ecr_cdps_s3_bagit_validator_west.gha_role
47-
# ecr = module.ecr_cdps_s3_bagit_validator_west.repository_name
48-
# function = local.ecr_cdps_s3_bagit_validator_function_name
49-
# }
50-
# )
51-
# description = "Full contents of the stage-build.yml for the s3-bagit-validator repo to deploy in us-west-2"
52-
# }
33+
output "s3_bagit_validator_makefile_west" {
34+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/makefile-extra-region.tpl", {
35+
region = "us-west-2"
36+
ecr_name = module.ecr_cdps_s3_bagit_validator_west.repository_name
37+
ecr_url = module.ecr_cdps_s3_bagit_validator_west.repository_url
38+
function = local.ecr_cdps_s3_bagit_validator_function_name
39+
}
40+
)
41+
description = "Full contents of the Makefile for the s3-bagit-validator repo (allows devs to push to Dev account only)"
42+
}
5343

54-
# # Outputs after promotion to prod
55-
# output "s3_bagit_validator_prod_promote_workflow_west" {
56-
# value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/prod-promote.tpl", {
57-
# region = var.aws_region
58-
# role_stage = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-gha-stage"
59-
# role_prod = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-gha-prod"
60-
# ecr_stage = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-stage"
61-
# ecr_prod = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-prod"
62-
# function = local.ecr_cdps_s3_bagit_validator_function_name
63-
# }
64-
# )
65-
# description = "Full contents of the prod-promote.yml for the s3-bagit-validator repo to deploy in us-west-2"
66-
# }
44+
# Outputs in stage
45+
output "s3_bagit_validator_stage_build_workflow_west" {
46+
value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/stage-build.tpl", {
47+
region = "us-west-2"
48+
role = module.ecr_cdps_s3_bagit_validator.gha_role
49+
ecr = module.ecr_cdps_s3_bagit_validator_west.repository_name
50+
function = local.ecr_cdps_s3_bagit_validator_function_name
51+
}
52+
)
53+
description = "Additional job for the stage-build.yml for the s3-bagit-validator repo to deploy in us-west-2"
54+
}
55+
56+
# Outputs after promotion to prod
57+
output "s3_bagit_validator_prod_promote_workflow_west" {
58+
value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/prod-promote.tpl", {
59+
region = "us-west-2"
60+
role_stage = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-gha-stage"
61+
role_prod = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-gha-prod"
62+
ecr_stage = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-stage"
63+
ecr_prod = "${module.ecr_cdps_s3_bagit_validator_west.repo_name}-prod"
64+
function = local.ecr_cdps_s3_bagit_validator_function_name
65+
}
66+
)
67+
description = "Additional job for the prod-promote.yml for the s3-bagit-validator repo to deploy in us-west-2"
68+
}

files/dev-build-extra-region.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### This is the Terraform-generated extra workflow job for the
2+
### ${ecr} app repository.
3+
### This should be added to jobs section of the dev-build.yml.
4+
### If this is a Lambda function, uncomment the FUNCTION: line
5+
6+
deploy-${region}:
7+
name: Dev Container Deploy ${region}
8+
uses: mitlibraries/.github/.github/workflows/ecr-shared-deploy-dev.yml@main
9+
secrets: inherit
10+
with:
11+
AWS_REGION: "${region}"
12+
GHA_ROLE: "${role}"
13+
ECR: "${ecr}"
14+
# FUNCTION: "${function}"
15+
# PREBUILD:

files/makefile-extra-region.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Add the following lines to the Makefile header:
2+
ECR_URL_OTHER_DEV:=${ecr_url}
3+
### End of Terraform-generated header
4+
5+
6+
### Add the following lines to the docker build command in the dist-dev command
7+
-t $(ECR_URL_OTHER_DEV):latest \
8+
-t $(ECR_URL_OTHER_DEV):`git describe --always` \
9+
10+
11+
### Add the following lines to the publish-dev command:
12+
publish-dev: dist-dev ## Build, tag and push (intended for developer-based manual publish)
13+
docker login -u AWS -p $$(aws ecr get-login-password --region ${region}) $(ECR_URL_OTHER_DEV)
14+
docker push $(ECR_URL_OTHER_DEV):latest
15+
docker push $(ECR_URL_OTHER_DEV):`git describe --always`
16+
17+
18+
### Add the following line to the update-lambda-dev command if this is a Lambda Function
19+
# aws lambda update-function-code --region ${region} --function-name $(FUNCTION_DEV) --image-uri $(ECR_URL_OTHER_DEV):latest

files/makefile.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ publish-dev: dist-dev ## Build, tag and push (intended for developer-based manua
2020

2121
### If this is a Lambda repo, uncomment the two lines below ###
2222
# update-lambda-dev: ## Updates the lambda with whatever is the most recent image in the ecr (intended for developer-based manual update)
23-
# aws lambda update-function-code --function-name $(FUNCTION_DEV) --image-uri $(ECR_URL_DEV):latest
23+
# aws lambda update-function-code --region us-east-1 --function-name $(FUNCTION_DEV) --image-uri $(ECR_URL_DEV):latest
2424

2525

2626
### Terraform-generated manual shortcuts for deploying to Stage. This requires ###
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### This should be added to jobs section of the dev-build.yml.
2+
### If this is a Lambda function, uncomment the FUNCTION: line
3+
4+
deploy-${region}:
5+
name: Prod Container Promote ${region}
6+
uses: mitlibraries/.github/.github/workflows/ecr-shared-promote-prod.yml@main
7+
secrets: inherit
8+
with:
9+
AWS_REGION: "${region}"
10+
GHA_ROLE_STAGE: ${role_stage}
11+
GHA_ROLE_PROD: ${role_prod}
12+
ECR_STAGE: "${ecr_stage}"
13+
ECR_PROD: "${ecr_prod}"
14+
# FUNCTION: "${function}"
15+

files/stage-build-extra-region.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### This should be added to jobs section of the stage-build.yml.
2+
### If this is a Lambda function, uncomment the FUNCTION: line
3+
4+
deploy-${region}:
5+
name: Stage Container Deploy ${region}
6+
uses: mitlibraries/.github/.github/workflows/ecr-shared-deploy-stage.yml@main
7+
secrets: inherit
8+
with:
9+
AWS_REGION: "${region}"
10+
GHA_ROLE: "${role}"
11+
ECR: "${ecr}"
12+
# FUNCTION: "${function}"
13+
# PREBUILD:

0 commit comments

Comments
 (0)