diff --git a/vpc/README.md b/vpc/README.md index bd86305..0d6f0e3 100644 --- a/vpc/README.md +++ b/vpc/README.md @@ -34,6 +34,7 @@ module "vpc" { | [terraform](#requirement\_terraform) | >= 0.13 | | [aws](#requirement\_aws) | >= 3.66.0 | | [ldap](#requirement\_ldap) | >= 0.5.4 | +| [local](#requirement\_local) | >= 1.0.0 | | [null](#requirement\_null) | >= 3.0 | | [random](#requirement\_random) | >= 3.0 | | [template](#requirement\_template) | >= 2.0 | @@ -43,6 +44,8 @@ module "vpc" { | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.66.0 | +| [local](#provider\_local) | >= 1.0.0 | +| [null](#provider\_null) | >= 3.0 | ## Modules @@ -56,22 +59,27 @@ No modules. | [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource | | [aws_vpc_dhcp_options.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_dhcp_options) | resource | | [aws_vpc_dhcp_options_association.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_dhcp_options_association) | resource | +| [local_sensitive_file.vpc_details_json](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | +| [local_sensitive_file.vpc_details_yaml](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | +| [null_resource.directory_setup](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_iam_account_alias.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no | -| [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no | +| [account\_alias](#input\_account\_alias) | AWS Account Alias (default: will pull from current account\_alias) | `string` | `""` | no | +| [account\_id](#input\_account\_id) | AWS Account ID (default: will pull from current user) | `string` | `""` | no | | [enable\_aws\_dns](#input\_enable\_aws\_dns) | Enable use of AWS DNS server. This overrides the settings of vpc\_dns\_servers and enables dns\_support and dns\_hostnames | `bool` | `false` | no | | [enable\_dns\_hostnames](#input\_enable\_dns\_hostnames) | Enable DNS hostnames within the VPC | `bool` | `true` | no | | [enable\_dns\_support](#input\_enable\_dns\_support) | Enable DNS support within the VPC | `bool` | `true` | no | | [network\_census](#input\_network\_census) | Census Subnets | `list` |
[| no | | [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | | [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no | +| [tgw\_environment](#input\_tgw\_environment) | Transit Gatewway environment purpose (services, dev, test, stage, prod, cre) | `string` | `null` | no | | [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | VPC CIDR Block | `string` | n/a | yes | | [vpc\_dns\_servers](#input\_vpc\_dns\_servers) | VPC DNS Servers (default: Enterprise primary DNS at BCC and HQ) | `list(string)` |
"148.129.0.0/16",
"172.16.0.0/12",
"192.168.0.0/16"
]
[| no | | [vpc\_domain\_name](#input\_vpc\_domain\_name) | VPC Domain Name for DHCP settings | `string` | `"unknown.census.gov"` | no | diff --git a/vpc/variables.tgw_environment.tf b/vpc/variables.tgw_environment.tf new file mode 100644 index 0000000..26f93fa --- /dev/null +++ b/vpc/variables.tgw_environment.tf @@ -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" +# } +# } diff --git a/vpc/vpc-config.tf b/vpc/vpc-config.tf new file mode 100644 index 0000000..51a4c39 --- /dev/null +++ b/vpc/vpc-config.tf @@ -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" +} +
"148.129.127.22",
"148.129.191.22"
]