-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
136 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,98 +1,115 @@ | ||
| locals { | ||
| proxy_env_vars = { | ||
| HTTP_PROXY = "http://proxy.tco.census.gov:3128" | ||
| NO_PROXY = ".census.gov,169.254.169.254,148.129.*,10.*,172.18.*,172.22.*,172.23.*,172.24.*,172.25.*,.eks.amazonaws.com,.s3.amazonaws.com,.amazonaws.com,.gcr.io,.pkg.dev" | ||
| HTTPS_PROXY = "http://proxy.tco.census.gov:3128" | ||
| } | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "s3_access" { | ||
| statement { | ||
| effect = "Allow" | ||
| actions = ["s3:*"] | ||
| resources = ["*"] | ||
| } | ||
| } | ||
|
|
||
|
|
||
| resource "aws_security_group" "allow_amznlinux_cdn" { | ||
| name = "allow_amznlinux_cdn" | ||
| description = "Allow TLS inbound traffic and all outbound traffic" | ||
| vpc_id = local.vpc_id | ||
|
|
||
| tags = { | ||
| Name = "allow_amznlinux_cdn" | ||
| } | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_egress_rule" "allow_all_traffic_ipv4" { | ||
| security_group_id = aws_security_group.allow_amznlinux_cdn.id | ||
| cidr_ipv4 = "0.0.0.0/0" | ||
| ip_protocol = "-1" # semantically equivalent to all ports | ||
| } | ||
|
|
||
|
|
||
| locals { | ||
| vpc_id = "vpc-00576a396ec570b94" | ||
| } | ||
|
|
||
| data "aws_codecommit_repository" "ansible" { | ||
| repository_name = "image-pipeline-ansible-roles" | ||
| } | ||
|
|
||
| data "aws_codecommit_repository" "goss" { | ||
| repository_name = "image-pipeline-goss-testing" | ||
| } | ||
|
|
||
|
|
||
| data "aws_region" "current" {} | ||
|
|
||
|
|
||
| module "main" { | ||
| source = "HappyPathway/image-pipeline/aws" | ||
| project_name = "image-pipeline-demo2" | ||
| environment = "dev" | ||
| source_repo_name = "image-pipeline-hello-world" | ||
| source_repo_branch = "main" | ||
| builder_image = "aws/codebuild/standard:7.0" | ||
| create_new_repo = true | ||
| create_new_role = true | ||
| build_permissions_iam_doc = data.aws_iam_policy_document.s3_access | ||
| build_environment_variables = [ | ||
| for proxy_var in keys(local.proxy_env_vars) : | ||
| { | ||
| name=proxy_var, | ||
| value=lookup(local.proxy_env_vars, proxy_var), | ||
| type = "PLAINTEXT" | ||
| } | ||
| ] | ||
| ansible_repo = data.aws_codecommit_repository.ansible | ||
| goss_repo = data.aws_codecommit_repository.goss | ||
|
|
||
| state = { | ||
| bucket = "inf-tfstate-229685449397" | ||
| key = "csvd-dev-gov/common/apps/aws-image-pipeline-demo" | ||
| region = "us-gov-east-1" | ||
| dynamodb_table = "tf_remote_state" | ||
| } | ||
|
|
||
| vpc_config = { | ||
| vpc_id = local.vpc_id | ||
| region = "us-gov-west-1" | ||
| security_group_ids = [ | ||
| "sg-0d828d223df9834a6", | ||
| aws_security_group.allow_amznlinux_cdn.id | ||
| ] | ||
| subnets = [ | ||
| "subnet-0b1992a84536c581b" | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| output iam_arn { | ||
| value = module.main.iam_arn | ||
| } | ||
|
|
||
| output codebuild_user { | ||
| value = module.main.build_user.name | ||
| } | ||
| locals { | ||
| proxy_env_vars = { | ||
| HTTP_PROXY = "http://proxy.tco.census.gov:3128" | ||
| NO_PROXY = ".census.gov,169.254.169.254,148.129.*,10.*,172.18.*,172.22.*,172.23.*,172.24.*,172.25.*,.eks.amazonaws.com,.s3.amazonaws.com,.amazonaws.com,.gcr.io,.pkg.dev" | ||
| HTTPS_PROXY = "http://proxy.tco.census.gov:3128" | ||
| } | ||
| source_repo = "image-pipeline-hello-world" | ||
| project_name = "image-pipeline-demo2" | ||
| environment = "dev" | ||
| _vpc_config = { | ||
| vpc_id = "vpc-00576a396ec570b94" | ||
| region = "us-gov-west-1" | ||
| security_group_ids = [ | ||
| "sg-0d828d223df9834a6" | ||
| ] | ||
| subnets = [ | ||
| # "subnet-0b1992a84536c581b" | ||
| "subnet-062189d742937204e" | ||
| ] | ||
| } | ||
| vpc_config = merge( | ||
| local._vpc_config, | ||
| { | ||
| security_group_ids = concat( | ||
| local._vpc_config.security_group_ids, | ||
| [ | ||
| aws_security_group.allow_amznlinux_cdn.id | ||
| ]) | ||
| } | ||
| ) | ||
| state_config = { | ||
| bucket = aws_s3_bucket.state_bucket.bucket | ||
| key = "csvd-dev-gov/common/apps/${local.environment}/${local.project_name}" | ||
| region = local.vpc_config.region | ||
| dynamodb_table = "tf_remote_state" | ||
| } | ||
| } | ||
|
|
||
| resource random_uuid random {} | ||
| resource aws_s3_bucket state_bucket { | ||
| bucket = "inf-test-${random_uuid.random.result}" | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "s3_access" { | ||
| statement { | ||
| effect = "Allow" | ||
| actions = ["s3:*"] | ||
| resources = ["*"] | ||
| } | ||
| } | ||
|
|
||
| resource "aws_security_group" "allow_amznlinux_cdn" { | ||
| name = "allow_amznlinux_cdn" | ||
| description = "Allow TLS inbound traffic and all outbound traffic" | ||
| vpc_id = local._vpc_config.vpc_id | ||
| tags = { | ||
| Name = "allow_amznlinux_cdn" | ||
| } | ||
| } | ||
|
|
||
| resource "aws_vpc_security_group_egress_rule" "allow_all_traffic_ipv4" { | ||
| security_group_id = aws_security_group.allow_amznlinux_cdn.id | ||
| cidr_ipv4 = "0.0.0.0/0" | ||
| ip_protocol = "-1" # semantically equivalent to all ports | ||
| } | ||
|
|
||
| # referenced_security_group_id | ||
| resource "aws_vpc_security_group_ingress_rule" "allow_all_between_self" { | ||
| security_group_id = aws_security_group.allow_amznlinux_cdn.id | ||
| ip_protocol = "-1" # semantically equivalent to all ports | ||
| referenced_security_group_id = aws_security_group.allow_amznlinux_cdn.id | ||
| } | ||
|
|
||
| data "aws_codecommit_repository" "ansible" { | ||
| repository_name = "image-pipeline-ansible-roles" | ||
| } | ||
|
|
||
| data "aws_codecommit_repository" "goss" { | ||
| repository_name = "image-pipeline-goss-testing" | ||
| } | ||
|
|
||
|
|
||
| module "main" { | ||
| source = "HappyPathway/image-pipeline/aws" | ||
| project_name = local.project_name | ||
| environment = local.environment | ||
| source_repo_name = local.source_repo | ||
| source_repo_branch = "main" | ||
| builder_image = "aws/codebuild/standard:7.0" | ||
| create_new_repo = true | ||
| create_new_role = true | ||
| build_permissions_iam_doc = data.aws_iam_policy_document.s3_access | ||
| build_environment_variables = [ | ||
| for proxy_var in keys(local.proxy_env_vars) : | ||
| { | ||
| name=proxy_var, | ||
| value=lookup(local.proxy_env_vars, proxy_var), | ||
| type = "PLAINTEXT" | ||
| } | ||
| ] | ||
| ansible_repo = data.aws_codecommit_repository.ansible | ||
| goss_repo = data.aws_codecommit_repository.goss | ||
| goss_profile = "base-test" | ||
| state = local.state_config | ||
| vpc_config = local.vpc_config | ||
| } | ||
|
|
||
| output iam_arn { | ||
| value = module.main.iam_arn | ||
| } | ||
|
|
||
| output codebuild_user { | ||
| value = module.main.build_user.name | ||
| } | ||
|
|