-
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.
add tgw_environment, generate vpc config for use in routing setup
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
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
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| variable "tgw_environment" { | ||
| description = "Transit Gatewway environment purpose (services, dev, test, stage, prod, cre)" | ||
| type = string | ||
| default = null | ||
| } | ||
|
|
||
| # variable "transit_gateway_environment" { | ||
| # description = "Transit Gateway Environment (aka, VRF) to which to connnect this VPC" | ||
| # type = string | ||
| # | ||
| # validation { | ||
| # condition = contains(["services", "dev", "test", "stage", "prod", "cre"], var.transit_gateway_environment) | ||
| # error_message = "transit_gateway_environment value must be one of the valid VRF selections" | ||
| # } | ||
| # } |
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| locals { | ||
| vpc_config_output = { | ||
| vpc_id = aws_vpc.vpc.id | ||
| vpc_arn = aws_vpc.vpc.arn | ||
| vpc_cidr_block = aws_vpc.vpc.cidr_block | ||
| vpc_name = var.vpc_name | ||
| vpc_short_name = var.vpc_short_name | ||
| region = local.region | ||
| region_short = local.region_short | ||
| account_id = local.account_id | ||
| account_alias = data.aws_iam_account_alias.current.account_alias | ||
| tgw_environment = var.tgw_environment != null ? var.tgw_environment : "unknown" | ||
| version = local._module_version | ||
| } | ||
| } | ||
|
|
||
| resource "null_resource" "directory_setup" { | ||
| triggers = { | ||
| name = "setus" | ||
| } | ||
| provisioner "local-exec" { | ||
| working_dir = path.root | ||
| command = "test -d ${self.triggers.name} || mkdir ${self.triggers.name}; echo ${self.triggers.name}" | ||
| } | ||
| } | ||
|
|
||
| resource "local_sensitive_file" "vpc_details_json" { | ||
| content = jsonencode(local.vpc_config_output) | ||
| filename = format("%v/%v/vpc.%v.%v.%v.json", path.root, null_resource.directory_setup.triggers.name, local.account_id, local.region, local.vpc_id) | ||
| file_permission = "0644" | ||
| directory_permission = "0755" | ||
| } | ||
|
|
||
| resource "local_sensitive_file" "vpc_details_yaml" { | ||
| content = yamlencode(local.vpc_config_output) | ||
| filename = format("%v/%v/vpc.%v.%v.%v.yml", path.root, null_resource.directory_setup.triggers.name, local.account_id, local.region, local.vpc_id) | ||
| file_permission = "0644" | ||
| directory_permission = "0755" | ||
| } | ||
|
|