Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Mar 21, 2023
1 parent 4601543 commit 84bff5c
Show file tree
Hide file tree
Showing 25 changed files with 411 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,7 @@
* 2.6.2 -- 2023-03-20
- tag-shared-vpc-resources
- enable tgw tagging by default, which works now

* 2.6.3 -- 2023-03-21
- tag-shared-vpc-resources
- pass network provider in module
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
_module_version = "2.6.2"
_module_version = "2.6.3"
_module_names = {
"_main_" = "aws-vpc-setup"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module "tag_shared" {
source = "git@github.e.it.census.gov:terraform-modules/aws-vpc-setup.git//tag-shared-vpc-resources?ref=tf-upgrade"
network_account_profile = "057445207498-ent-gov-network-sa"
network_account_profile = "057405694017-ent-gov-network-prod"

## optional, with defaults
### tag_enabled_vpcs = true
### tag_enabled_dhcp_options = true
### tag_enabled_route_tables = true
### tag_enabled_subnets = true
### tag_enabled_network_acls = true
### tag_enabled_transit_gateway = false
### tag_enabled_transit_gateway = true
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
VERSION 1.0.1
VERSION 1.0.0
REMOTE-STATE
COMMAND tf-directory-setup.py -l none -f
COMMAND setup-new-directory.sh
COMMAND tf-init -upgrade
ALL
ALL
COMMAND tf-directory-setup.py -l s3
33 changes: 33 additions & 0 deletions examples/region-shared-setup/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
terraform {
required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0"
}
## ldap = {
## source = "trevex/ldap"
## version = ">= 0.5.4"
## }
## external = {
## source = "hashicorp/external"
## version = ">= 1.0"
## }
## null = {
## source = "hashicorp/null"
## version = ">= 1.0"
## }
## random = {
## source = "hashicorp/random"
## version = ">= 1.0"
## }
## template = {
## source = "hashicorp/template"
## version = ">= 1.0"
## }
## infoblox = {
## source = "infobloxopen/infoblox"
## version = ">= 2.1.0"
## }
}
}
4 changes: 4 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/.tf-control
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#TFCOMMAND="terraform_0.13.7"
#TFCOMMAND="terraform_0.14.11"
TFCOMMAND="terraform_latest"
## TF_CLI_CONFIG_FILE=$HOME/.tf-control.tfrc
23 changes: 23 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/.tf-control.tfrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://www.terraform.io/docs/cli/config/config-file.html

plugin_cache_dir = "/data/terraform/terraform.d/plugin-cache"
#disable_checkpoint = true

provider_installation {
# filesystem_mirror {
# path = "/apps/terraform/terraform.d/providers"
# include = [ "*/*/*" ]
# }
filesystem_mirror {
path = "/data/terraform/terraform.d/providers"
include = [ "*/*/*" ]
}
# filesystem_mirror {
# path = "/apps/terraform/terraform.d/providers"
# include = [ "external.terraform.census.gov/*/*" ]
# }
direct {
include = [ "*/*/*" ]
}
}

48 changes: 48 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/M
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- [x] nhpc-app1.rm.census.gov
- [x] nhpc-transfer1.rm.census.gov
- [x] nhpc-login1.rm.census.gov
- [x] nhpc-login2.rm.census.gov
- [x] hpc-compute1.rm.census.gov
- [ ] hpc-compute2.rm.census.gov
- [ ] hpc-compute3.rm.census.gov
- [ ] hpc-compute4.rm.census.gov
- [ ] hpc-compute5.rm.census.gov
- [ ] hpc-compute6.rm.census.gov
- [ ] hpc-compute7.rm.census.gov
- [ ] hpc-compute8.rm.census.gov
- [ ] hpc-compute9.rm.census.gov
- [ ] hpc-compute10.rm.census.gov
- [ ] hpc-compute11.rm.census.gov
- [ ] hpc-compute12.rm.census.gov
- [ ] hpc-compute13.rm.census.gov
- [ ] hpc-compute14.rm.census.gov
- [ ] hpc-compute15.rm.census.gov
- [ ] hpc-compute16.rm.census.gov
- [ ] hpc-compute17.rm.census.gov
- [ ] hpc-compute18.rm.census.gov
- [ ] hpc-compute19.rm.census.gov
- [ ] hpc-compute20.rm.census.gov
- [ ] hpc-compute21.rm.census.gov
- [ ] hpc-compute22.rm.census.gov
- [ ] hpc-compute23.rm.census.gov
- [ ] hpc-compute24.rm.census.gov
- [ ] hpc-compute25.rm.census.gov
- [ ] hpc-compute26.rm.census.gov
- [ ] hpc-compute27.rm.census.gov
- [ ] hpc-compute28.rm.census.gov
- [ ] hpc-compute29.rm.census.gov
- [ ] hpc-compute30.rm.census.gov
- [ ] hpc-compute31.rm.census.gov
- [ ] hpc-compute32.rm.census.gov
- [ ] hpc-compute33.rm.census.gov
- [ ] hpc-compute34.rm.census.gov
- [ ] hpc-compute35.rm.census.gov
- [ ] hpc-compute36.rm.census.gov
- [ ] hpc-compute37.rm.census.gov
- [ ] hpc-compute38.rm.census.gov
- [ ] hpc-compute39.rm.census.gov
- [ ] hpc-compute40.rm.census.gov
- [ ] hpc-compute41.rm.census.gov
- [ ] hpc-compute42.rm.census.gov
- [ ] hpc-compute43.rm.census.gov
- [ ] hpc-compute44.rm.census.gov
4 changes: 4 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/apps/.tf-control
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#TFCOMMAND="terraform_0.13.7"
#TFCOMMAND="terraform_0.14.11"
TFCOMMAND="terraform_latest"
## TF_CLI_CONFIG_FILE=$HOME/.tf-control.tfrc
23 changes: 23 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/apps/.tf-control.tfrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://www.terraform.io/docs/cli/config/config-file.html

plugin_cache_dir = "/data/terraform/terraform.d/plugin-cache"
#disable_checkpoint = true

provider_installation {
# filesystem_mirror {
# path = "/apps/terraform/terraform.d/providers"
# include = [ "*/*/*" ]
# }
filesystem_mirror {
path = "/data/terraform/terraform.d/providers"
include = [ "*/*/*" ]
}
# filesystem_mirror {
# path = "/apps/terraform/terraform.d/providers"
# include = [ "external.terraform.census.gov/*/*" ]
# }
direct {
include = [ "*/*/*" ]
}
}

4 changes: 4 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/apps/region.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
region = var.region
}

7 changes: 7 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/apps/tf-run.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VERSION 1.0.0
REMOTE-STATE
COMMAND tf-directory-setup.py -l none -f
COMMAND setup-new-directory.sh
COMMAND tf-init -upgrade
ALL
COMMAND tf-directory-setup.py -l s3
33 changes: 33 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/apps/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.0"
}
# ldap = {
# source = "trevex/ldap"
# version = ">= 0.5.4"
# }
# external = {
# source = "hashicorp/external"
# version = ">= 1.0"
# }
# null = {
# source = "hashicorp/null"
# version = ">= 1.0"
# }
# random = {
# source = "hashicorp/random"
# version = ">= 1.0"
# }
# template = {
# source = "hashicorp/template"
# version = ">= 1.0"
# }
# infoblox = {
# source = "infobloxopen/infoblox"
# version = ">= 2.1.0"
# }
}
required_version = ">= 1.0"
}
35 changes: 35 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/outputs.shared-vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
locals {
shared_vpc_info = {
vpc_id = data.aws_vpc.vpc.id
vpc_arn = data.aws_vpc.vpc.arn
vpc_cidr_block = data.aws_vpc.vpc.cidr_block
vpc_full_name = var.vpc_full_name
owner_id = data.aws_vpc.vpc.owner_id
vpc_environment = data.aws_vpc.vpc.tags["Environment"]
vpc_short_name = split("-", var.vpc_full_name)[0]
vpc_domain_name = data.aws_vpc_dhcp_options.dhcp_options.domain_name
# _raw = data.aws_vpc.vpc
}
shared_private_subnet_info = [for k, v in data.aws_subnet.subnet : {
id = v.id
arn = v.arn
availability_zone = v.availability_zone
owner_id = v.owner_id
cidr_block = v.cidr_block
subnet = v.cidr_block
label = replace(v.tags["Name"], format("%v-", var.vpc_full_name), "")
tags = v.tags
# _raw = v
}]
}


output "shared_vpc_info" {
description = "Details from shared VPC"
value = local.shared_vpc_info
}

output "shared_private_subnet_info" {
description = "Details from shared VPC subnets"
value = local.shared_private_subnet_info
}
4 changes: 4 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/region.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
region = var.region
}

42 changes: 42 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/shared-vpc-data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
data "aws_vpcs" "vpcs" {
filter {
name = "tag:Name"
values = [var.vpc_full_name]
}
}

data "aws_vpc" "vpc" {
id = coalesce(data.aws_vpcs.vpcs.ids[0], null)
}

data "aws_subnets" "subnets" {
filter {
name = "vpc-id"
values = [data.aws_vpc.vpc.id]
}
}

data "aws_subnet" "subnet" {
for_each = toset(data.aws_subnets.subnets.ids)
id = each.key
}

data "aws_vpc_dhcp_options" "dhcp_options" {
dhcp_options_id = data.aws_vpc.vpc.dhcp_options_id
}

## output "vpcs" {
## value = data.aws_vpcs.vpcs
## }
##
## output "vpc" {
## value = data.aws_vpc.vpc
## }
##
## output "subnets" {
## value = data.aws_subnets.subnets
## }
##
## output "subnet" {
## value = data.aws_subnet.subnet
## }
25 changes: 25 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/shared-vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
locals {
# vpc_info = data.terraform_remote_state.vpc_east_shared_vpc1.outputs.shared_vpc_info
# subnet_info = data.terraform_remote_state.vpc_east_shared_vpc1.outputs.shared_private_subnet_info
vpc_info = local.shared_vpc_info
subnet_info = local.shared_private_subnet_info
vpc_id = local.vpc_info.vpc_id

tags = {
CostAllocation = "csvd:infrastructure"
Environment = var.vpc_environment
}
}

# the only thing not shared are security groups, so they need to be created in each account/region and
# vpc where they intend to be used

module "base-security-groups" {
source = "git@github.e.it.census.gov:terraform-modules/aws-vpc-setup.git//security-groups?ref=tf-upgrade"
vpc_id = local.vpc_id

enable_manage_default_sg = false
vpc_full_name = var.vpc_full_name
vpc_environment = var.vpc_environment
tags = local.tags
}
7 changes: 7 additions & 0 deletions examples/shared-vpc-setup-tf-upgrade/tf-run.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VERSION 1.0.0
REMOTE-STATE
COMMAND tf-directory-setup.py -l none -f
COMMAND setup-new-directory.sh
COMMAND tf-init -upgrade
ALL
COMMAND tf-directory-setup.py -l s3
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# network_account_profile = "057445207498-ent-gov-network-sa"

vpc_name = "tgw-common"
vpc_full_name = "vpc1-tgw-common"
vpc_environment = "common"
vpc_domain_name = "common.network-sa-1.csp1.census.gov"
tgw_environment = "services"


Loading

0 comments on commit 84bff5c

Please sign in to comment.