UPD: moved random into a module

This commit is contained in:
xpk 2020-08-02 18:58:41 +08:00
parent 8710ded36a
commit 1e1c4b978e
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 21 additions and 10 deletions

View File

@ -0,0 +1,17 @@
resource "random_string" "string" {
length = 4
special = false
}
resource "random_integer" "number" {
min = 1000
max = 9999
}
output "string" {
value = random_string.string.result
}
output "number" {
value = random_integer.number.result
}

View File

@ -1,25 +1,19 @@
data "aws_availability_zones" "available" {} data "aws_availability_zones" "available" {}
#resource "random_string" "suffix" { module "random" {
# length = 4 source = "./random"
# special = false
#}
resource "random_integer" "suffix" {
min = 1000
max = 9999
} }
module "vpc" { module "vpc" {
source = "terraform-aws-modules/vpc/aws" source = "terraform-aws-modules/vpc/aws"
version = "2.6.0" version = "2.6.0"
name = "demo-vpc-${random_integer.suffix.result}" name = "demo-vpc-${module.random.number}"
cidr = "172.16.0.0/16" cidr = "172.16.0.0/16"
azs = data.aws_availability_zones.available.names azs = data.aws_availability_zones.available.names
private_subnets = cidrsubnets("172.16.18.0/23", 1, 1) private_subnets = cidrsubnets("172.16.18.0/23", 1, 1)
public_subnets = cidrsubnets("172.16.20.0/23", 1, 1) public_subnets = cidrsubnets("172.16.20.0/23", 1, 1)
enable_nat_gateway = true enable_nat_gateway = false
single_nat_gateway = true single_nat_gateway = true
enable_dns_hostnames = true enable_dns_hostnames = true