UPD: modified vpc

This commit is contained in:
xpk 2021-01-29 11:22:47 +08:00
parent 660572afdc
commit 93e9670539
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
7 changed files with 65 additions and 8 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
.DS_Store .DS_Store
*.iml *.iml
.idea .idea
cred.txt

View File

@ -0,0 +1,36 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/aws" {
version = "3.26.0"
hashes = [
"h1:0i78FItlPeiomd+4ThZrtm56P5K33k7/6dnEe4ZePI0=",
"zh:26043eed36d070ca032cf04bc980c654a25821a8abc0c85e1e570e3935bbfcbb",
"zh:2fe68f3f78d23830a04d7fac3eda550eef1f627dfc130486f70a65dc5c254300",
"zh:3d66484c608c64678e639db25d63872783ce60363a1246e30317f21c9c23b84b",
"zh:46ffd755cfd4cf94fe66342797b5afdcef010a24e126c67fee141b357d393535",
"zh:5e96f24357e945c9067cf5e032ad1d003609629c956c2f9f642fefe714e74587",
"zh:60c27aca36bb63bf3e865c2193be80ca83b376581d00f9c220af4b013e163c4d",
"zh:896f0f22d19d41e71b22f9240b261714c3915b165ddefeb771e7734d69dc47ea",
"zh:90de9966cb2fd3e2f326df291595e55d2dd2d90e7d6dd085c2c8691dce82bdb4",
"zh:ad05a91a88ceb1d6de5a568f7cc0b0e5bc0a79f3da70bc28c1e7f3750e362d58",
"zh:e8c63f59c6465329e1f3357498face3dd7ef10a033df3c366a33aa9e94b46c01",
]
}
provider "registry.terraform.io/hashicorp/null" {
version = "3.0.0"
hashes = [
"h1:ysHGBhBNkIiJLEpthB/IVCLpA1Qoncp3KbCTFGFZTO0=",
"zh:05fb7eab469324c97e9b73a61d2ece6f91de4e9b493e573bfeda0f2077bc3a4c",
"zh:1688aa91885a395c4ae67636d411475d0b831e422e005dcf02eedacaafac3bb4",
"zh:24a0b1292e3a474f57c483a7a4512d797e041bc9c2fbaac42fe12e86a7fb5a3c",
"zh:2fc951bd0d1b9b23427acc93be09b6909d72871e464088171da60fbee4fdde03",
"zh:6db825759425599a326385a68acc6be2d9ba0d7d6ef587191d0cdc6daef9ac63",
"zh:85985763d02618993c32c294072cc6ec51f1692b803cb506fcfedca9d40eaec9",
"zh:a53186599c57058be1509f904da512342cfdc5d808efdaf02dec15f0f3cb039a",
"zh:c2e07b49b6efa676bdc7b00c06333ea1792a983a5720f9e2233db27323d2707c",
"zh:cdc8fe1096103cf5374751e2e8408ec4abd2eb67d5a1c5151fe2c7ecfd525bef",
"zh:dbdef21df0c012b0d08776f3d4f34eb0f2f229adfde07ff252a119e52c0f65b7",
]
}

View File

@ -0,0 +1,21 @@
data aws_availability_zones available-az {
state = "available"
}
module "subnet_addrs" {
source = "hashicorp/subnets/cidr"
base_cidr_block = "10.0.0.0/16"
networks = [
for az in data.aws_availability_zones.available-az.names :
{
name = az
new_bits = 8
}
]
}
output module-output {
value = values(module.subnet_addrs.network_cidr_blocks)
}

View File

@ -13,7 +13,7 @@ locals {
Application = var.application Application = var.application
TerraformMode = "managed" TerraformMode = "managed"
TerraformDir = trimprefix(path.cwd, "/my/work/xpk-git/") TerraformDir = trimprefix(path.cwd, "/my/work/xpk-git/")
CreatedBy = split(":",data.aws_caller_identity.this.user_id)[1] CreatedBy = data.aws_caller_identity.this.arn
BuildDate = formatdate("YYYYMMDD", timestamp()) BuildDate = formatdate("YYYYMMDD", timestamp())
} }
ct-bucket-name = "${var.environment}-${var.aws-region-short}-${var.customer-name}-${var.project}-ctbucket-${data.aws_caller_identity.this.account_id}" ct-bucket-name = "${var.environment}-${var.aws-region-short}-${var.customer-name}-${var.project}-ctbucket-${data.aws_caller_identity.this.account_id}"

View File

@ -13,7 +13,7 @@ locals {
Application = var.application Application = var.application
TerraformMode = "managed" TerraformMode = "managed"
TerraformDir = trimprefix(path.cwd, "/my/work/xpk-git/") TerraformDir = trimprefix(path.cwd, "/my/work/xpk-git/")
CreatedBy = split(":",data.aws_caller_identity.this.user_id)[1] CreatedBy = data.aws_caller_identity.this.arn
BuildDate = formatdate("YYYYMMDD", timestamp()) BuildDate = formatdate("YYYYMMDD", timestamp())
} }
ct-bucket-name = "${var.environment}-${var.aws-region-short}-${var.customer-name}-${var.project}-ctbucket-${data.aws_caller_identity.this.account_id}" ct-bucket-name = "${var.environment}-${var.aws-region-short}-${var.customer-name}-${var.project}-ctbucket-${data.aws_caller_identity.this.account_id}"

View File

@ -13,7 +13,7 @@ locals {
Application = var.application Application = var.application
TerraformMode = "managed" TerraformMode = "managed"
TerraformDir = trimprefix(path.cwd, "/my/work/xpk-git/") TerraformDir = trimprefix(path.cwd, "/my/work/xpk-git/")
CreatedBy = split(":",data.aws_caller_identity.this.user_id)[1] CreatedBy = data.aws_caller_identity.this.arn
BuildDate = formatdate("YYYYMMDD", timestamp()) BuildDate = formatdate("YYYYMMDD", timestamp())
} }
ct-bucket-name = "${var.environment}-${var.aws-region-short}-${var.customer-name}-${var.project}-ctbucket-${data.aws_caller_identity.this.account_id}" ct-bucket-name = "${var.environment}-${var.aws-region-short}-${var.customer-name}-${var.project}-ctbucket-${data.aws_caller_identity.this.account_id}"

View File

@ -122,14 +122,13 @@ resource "aws_route" "private-routes" {
} }
resource "aws_route_table_association" "public_route_association" { resource "aws_route_table_association" "public_route_association" {
count = length(aws_subnet.public-subnets) for_each = toset(aws_subnet.public-subnets.*.id)
route_table_id = aws_route_table.public-route-table[0].id route_table_id = aws_route_table.public-route-table[0].id
subnet_id = aws_subnet.public-subnets[count.index].id subnet_id = each.value
} }
resource "aws_route_table_association" "private_route_association" { resource "aws_route_table_association" "private_route_association" {
count = length(aws_subnet.private-subnets) for_each = toset(aws_subnet.private-subnets.*.id)
route_table_id = aws_route_table.private-route-table[0].id route_table_id = aws_route_table.private-route-table[0].id
subnet_id = aws_subnet.private-subnets[count.index].id subnet_id = each.value
} }