diff --git a/.gitignore b/.gitignore index 9b8a46e..cd0ad89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,34 @@ -# Local .terraform directories -**/.terraform/* - -# .tfstate files -*.tfstate -*.tfstate.* - -# Crash log files -crash.log -crash.*.log - -# Exclude all .tfvars files, which are likely to contain sensitive data, such as -# password, private keys, and other secrets. These should not be part of version -# control as they are data points which are potentially sensitive and subject -# to change depending on the environment. -*.tfvars -*.tfvars.json - -# Ignore override files as they are usually used to override resources locally and so -# are not checked in -override.tf -override.tf.json -*_override.tf -*_override.tf.json - -# Include override files you do wish to add to version control using negated pattern -# !example_override.tf - -# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan -# example: *tfplan* - -# Ignore CLI configuration files -.terraformrc -terraform.rc +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index a32206e..d3d5dc5 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -1,25 +1,25 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "5.49.0" - constraints = ">= 4.20.1" - hashes = [ - "h1:Y3xvYjzBIwYSbcnZDcs6moiy30uxRoY5oT2ExQHKG5A=", - "zh:0979b07cdeffb868ea605e4bbc008adc7cccb5f3ba1d3a0b794ea3e8fff20932", - "zh:2121a0a048a1d9419df69f3561e524b7e8a6b74ba0f57bd8948799f12b6ad3a1", - "zh:573362042ba0bd18e98567a4f45d91b09eb0d223513518ba04f16a646a906403", - "zh:57be7a4d6c362be2fa586d270203f4eac1ee239816239a9503b86ebc8fa1fef0", - "zh:5c72ed211d9234edd70eac9d77c3cafc7bbf819d1c28332a6d77acf227c9a23c", - "zh:7786d1a9781f8e8c0079bf58f4ed4aeddec0caf54ad7ddcf43c47936d545a04f", - "zh:82133e7d39787ee91ed41988da71beecc2ecb900b5da94b3f3d77fbc4d4dc722", - "zh:8cdb1c154dead85be8352afd30eaf41c59249de9e7e0a8eb4ab8e625b90a4922", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:ac215fd1c3bd647ae38868940651b97a53197688daefcd70b3595c84560e5267", - "zh:c45db22356d20e431639061a72e07da5201f4937c1df6b9f03f32019facf3905", - "zh:c9ba90e62db9a4708ed1a4e094849f88ce9d44c52b49f613b30bb3f7523b8d97", - "zh:d2be3607be2209995c80dc1d66086d527de5d470f73509e813254067e8287106", - "zh:e3fa20090f3cebf3911fc7ef122bd8c0505e3330ab7d541fa945fea861205007", - "zh:ef1b9d5c0b6279323f2ecfc322db8083e141984cfe1bb2f33c0f4934fccb69e3", - ] -} +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.49.0" + constraints = ">= 4.20.1" + hashes = [ + "h1:Y3xvYjzBIwYSbcnZDcs6moiy30uxRoY5oT2ExQHKG5A=", + "zh:0979b07cdeffb868ea605e4bbc008adc7cccb5f3ba1d3a0b794ea3e8fff20932", + "zh:2121a0a048a1d9419df69f3561e524b7e8a6b74ba0f57bd8948799f12b6ad3a1", + "zh:573362042ba0bd18e98567a4f45d91b09eb0d223513518ba04f16a646a906403", + "zh:57be7a4d6c362be2fa586d270203f4eac1ee239816239a9503b86ebc8fa1fef0", + "zh:5c72ed211d9234edd70eac9d77c3cafc7bbf819d1c28332a6d77acf227c9a23c", + "zh:7786d1a9781f8e8c0079bf58f4ed4aeddec0caf54ad7ddcf43c47936d545a04f", + "zh:82133e7d39787ee91ed41988da71beecc2ecb900b5da94b3f3d77fbc4d4dc722", + "zh:8cdb1c154dead85be8352afd30eaf41c59249de9e7e0a8eb4ab8e625b90a4922", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:ac215fd1c3bd647ae38868940651b97a53197688daefcd70b3595c84560e5267", + "zh:c45db22356d20e431639061a72e07da5201f4937c1df6b9f03f32019facf3905", + "zh:c9ba90e62db9a4708ed1a4e094849f88ce9d44c52b49f613b30bb3f7523b8d97", + "zh:d2be3607be2209995c80dc1d66086d527de5d470f73509e813254067e8287106", + "zh:e3fa20090f3cebf3911fc7ef122bd8c0505e3330ab7d541fa945fea861205007", + "zh:ef1b9d5c0b6279323f2ecfc322db8083e141984cfe1bb2f33c0f4934fccb69e3", + ] +} diff --git a/README.md b/README.md index 3291125..c4195ac 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# aws-image-pipeline -Terraform Workspace for creating and managing AWS Image Pipelines +# aws-image-pipeline +Terraform Workspace for creating and managing AWS Image Pipelines diff --git a/main.tf b/main.tf index bce48d1..133a9f7 100644 --- a/main.tf +++ b/main.tf @@ -1,77 +1,84 @@ -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 = ["*"] - } -} - - -locals { - example_build_variables = [ - { - name = "TF_VAR_greeting", - value = "Dave", - type = "PLAINTEXT" - } - ] -} - -locals { - vpc_id = "vpc-00576a396ec570b94" -} - -resource "aws_codecommit_repository" "ansible" { - repository_name = "image-pipeline-ansible-roles" - description = "This is the Sample App Repository" -} - -data "aws_region" "current" {} - - -module "main" { - source = "HappyPathway/image-pipeline/aws" - project_name = "HelloAMI" - environment = "dev" - source_repo_name = "image-pipeline-hello-world" - source_repo_branch = "main" - create_new_repo = true - create_new_role = true - build_permissions_iam_doc = data.aws_iam_policy_document.s3_access - build_environment_variables = local.example_build_variables - ansible_repo = aws_codecommit_repository.ansible - vpc_config = { - vpc_id = local.vpc_id - security_group_ids = [] - subnets = [ - "subnet-062189d742937204e" - ] - } -} - - -resource "aws_iam_service_specific_credential" "codecommit" { - service_name = "codecommit.amazonaws.com" - user_name = module.main.build_user.name -} - -output codecommit_credentials_username { - value = aws_iam_service_specific_credential.codecommit.service_user_name -} - -output codecommit_credentials_password { - value =nonsensitive(aws_iam_service_specific_credential.codecommit.service_password) -} - - -output iam_arn { - value = module.main.iam_arn -} +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 = ["*"] + } +} + + +locals { + example_build_variables = [ + { + name = "TF_VAR_greeting", + value = "Dave", + type = "PLAINTEXT" + } + ] +} + +locals { + vpc_id = "vpc-00576a396ec570b94" +} + +resource "aws_codecommit_repository" "ansible" { + repository_name = "image-pipeline-ansible-roles" + description = "This is the Sample App Repository" +} + +data "aws_region" "current" {} + + +module "main" { + source = "HappyPathway/image-pipeline/aws" + project_name = "HelloAMI" + environment = "dev" + source_repo_name = "image-pipeline-hello-world" + source_repo_branch = "main" + 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), + type = "PLAINTEXT" + } + ] + ansible_repo = aws_codecommit_repository.ansible + vpc_config = { + vpc_id = local.vpc_id + security_group_ids = [] + subnets = [ + "subnet-062189d742937204e" + ] + } +} + + +resource "aws_iam_service_specific_credential" "codecommit" { + service_name = "codecommit.amazonaws.com" + user_name = module.main.build_user.name +} + +output codecommit_credentials_username { + value = aws_iam_service_specific_credential.codecommit.service_user_name +} + +output codecommit_credentials_password { + value =nonsensitive(aws_iam_service_specific_credential.codecommit.service_password) +} + + +output iam_arn { + value = module.main.iam_arn +}