Skip to content

Commit aaedc67

Browse files
authored
Merge pull request #30 from MITLibraries/update-ecr-outputs
Update Terraform Outputs to use new shared workflows
2 parents 4901fd1 + 873a98d commit aaedc67

File tree

11 files changed

+192
-148
lines changed

11 files changed

+192
-148
lines changed

.terraform.lock.hcl

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,26 @@ The [ppod_ecr.tf](./ppod_ecr.tf) is a good example of a single ECR repository fo
3333

3434
A quick note for application developers and the integration of workflows to automate the deployment of their containerized application to either Fargate or Lambda. When this code is deployed in Terraform Cloud, it generates outputs that contain the caller workflows code as well as the `Makefile` code for their application. Those outputs are accessible to the developers via Terraform Cloud -- they can go into TfC, find the correct Terraform Output, and then copy that text into their application repository.
3535

36-
## Making this work in your environment outside of MIT libraries:
37-
This repository is a part of an ecosystem of components designed to work in our AWS organization. This component is responsible for a standardized setup of ECR repositories and a build process that goes in github actions and makefiles. On its own, this repository could be useful to you if you want to emulate how we deploy and promote containers across our AWS accounts, or utilize github OIDC connections for depositing ECR containers to AWS. Before this will deploy in your environment, you will need an OpenID Connect Provider. We generate this in our "init" repo, but you could just as easily place it here and reference it directly.
36+
## Making this work in your environment outside of MIT libraries
37+
38+
This repository is a part of an ecosystem of components designed to work in our AWS organization. This component is responsible for a standardized setup of ECR repositories and a build process that goes in Github Actions and Makefiles. On its own, this repository could be useful to you if you want to emulate how we deploy and promote containers across our AWS accounts, or utilize GitHub OIDC connections for depositing ECR containers to AWS. Before this will deploy in your environment, you will need an OpenID Connect Provider. We generate this in our "init" repo, but you could just as easily place it here and reference it directly.
3839

3940
An example of that infrastructure is:
40-
```
41+
42+
```terraform
4143
resource "aws_iam_openid_connect_provider" "github" {
4244
url = "https://token.actions.githubusercontent.com"
4345
client_id_list = ["sts.amazonaws.com"]
4446
thumbprint_list = ["6938fd4d98bab03faadb97b34396831e3780aea1"]
4547
}
4648
```
49+
4750
then replace all the ssm parameter references for `oidc_arn` with `aws_iam_openid_connect_provider.github.arn`
4851

4952
## Additional Reference
5053

51-
* https://blog.tedivm.com/guides/2021/10/github-actions-push-to-aws-ecr-without-credentials-oidc/
52-
* https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims
54+
* [github-actions-push-to-aws-ecr-without-credentials-oidc](https://blog.tedivm.com/guides/2021/10/github-actions-push-to-aws-ecr-without-credentials-oidc/)
55+
* [about-security-hardening-with-openid-connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims)
5356

5457
## TF markdown is automatically inserted at the bottom of this file, nothing should be written beyond this point
5558

@@ -65,7 +68,7 @@ then replace all the ssm parameter references for `oidc_arn` with `aws_iam_openi
6568

6669
| Name | Version |
6770
|------|---------|
68-
| aws | 4.26.0 |
71+
| aws | 4.37.0 |
6972

7073
## Modules
7174

almahook_ecr.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module "ecr_alma_webhook_lambdas" {
2222
## For alma-webhook-lambdas application repo and ECR repository
2323
# Outputs in dev
2424
output "alma_webhook_lambdas_dev_build_workflow" {
25-
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/lambda-dev-build.tpl", {
25+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/dev-build.tpl", {
2626
region = var.aws_region
2727
role = module.ecr_alma_webhook_lambdas.gha_role
2828
ecr = module.ecr_alma_webhook_lambdas.repository_name
@@ -32,7 +32,7 @@ output "alma_webhook_lambdas_dev_build_workflow" {
3232
description = "Full contents of the dev-build.yml for the alma-webhook-lambdas repo"
3333
}
3434
output "alma_webhook_lambdas_makefile" {
35-
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/lambda-makefile.tpl", {
35+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/makefile.tpl", {
3636
ecr_name = module.ecr_alma_webhook_lambdas.repository_name
3737
ecr_url = module.ecr_alma_webhook_lambdas.repository_url
3838
function = local.ecr_alma_webhook_lambdas_function_name
@@ -43,7 +43,7 @@ output "alma_webhook_lambdas_makefile" {
4343

4444
# Outputs in stage
4545
output "alma_webhook_lambdas_stage_build_workflow" {
46-
value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/lambda-stage-build.tpl", {
46+
value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/stage-build.tpl", {
4747
region = var.aws_region
4848
role = module.ecr_alma_webhook_lambdas.gha_role
4949
ecr = module.ecr_alma_webhook_lambdas.repository_name
@@ -55,7 +55,7 @@ output "alma_webhook_lambdas_stage_build_workflow" {
5555

5656
# Outputs after promotion to prod
5757
output "alma_webhook_lambdas_prod_promote_workflow" {
58-
value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/lambda-prod-promote.tpl", {
58+
value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/prod-promote.tpl", {
5959
region = var.aws_region
6060
role_stage = "${module.ecr_alma_webhook_lambdas.repo_name}-gha-stage"
6161
role_prod = "${module.ecr_alma_webhook_lambdas.repo_name}-gha-prod"

dss.tf

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,46 @@ module "ecr_dss" {
2121
## For dss application repo and ECR repository
2222
# Outputs in dev
2323
output "dss_fargate_dev_build_workflow" {
24-
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/fargate-dev-build.tpl", {
25-
region = var.aws_region
26-
role = module.ecr_dss.gha_role
27-
ecr = module.ecr_dss.repository_name
24+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/dev-build.tpl", {
25+
region = var.aws_region
26+
role = module.ecr_dss.gha_role
27+
ecr = module.ecr_dss.repository_name
28+
function = ""
2829
}
2930
)
3031
description = "Full contents of the dev-build.yml for the dss repo"
3132
}
3233
output "dss_fargate_makefile" {
33-
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/fargate-makefile.tpl", {
34+
value = var.environment == "prod" || var.environment == "stage" ? null : templatefile("${path.module}/files/makefile.tpl", {
3435
ecr_name = module.ecr_dss.repository_name
3536
ecr_url = module.ecr_dss.repository_url
37+
function = ""
3638
}
3739
)
3840
description = "Full contents of the Makefile for the dss repo (allows devs to push to Dev account only)"
3941
}
4042

4143
# Outputs in stage
4244
output "dss_fargate_stage_build_workflow" {
43-
value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/fargate-stage-build.tpl", {
44-
region = var.aws_region
45-
role = module.ecr_dss.gha_role
46-
ecr = module.ecr_dss.repository_name
45+
value = var.environment == "prod" || var.environment == "dev" ? null : templatefile("${path.module}/files/stage-build.tpl", {
46+
region = var.aws_region
47+
role = module.ecr_dss.gha_role
48+
ecr = module.ecr_dss.repository_name
49+
function = ""
4750
}
4851
)
4952
description = "Full contents of the stage-build.yml for the dss repo"
5053
}
5154

5255
# Outputs after promotion to prod
5356
output "dss_fargate_prod_promote_workflow" {
54-
value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/fargate-prod-promote.tpl", {
57+
value = var.environment == "stage" || var.environment == "dev" ? null : templatefile("${path.module}/files/prod-promote.tpl", {
5558
region = var.aws_region
5659
role_stage = "${module.ecr_dss.repo_name}-gha-stage"
5760
role_prod = "${module.ecr_dss.repo_name}-gha-prod"
5861
ecr_stage = "${module.ecr_dss.repo_name}-stage"
5962
ecr_prod = "${module.ecr_dss.repo_name}-prod"
63+
function = ""
6064
}
6165
)
6266
description = "Full contents of the prod-promote.yml for the dss repo"

0 commit comments

Comments
 (0)