UPD: moved random into a module
This commit is contained in:
parent
8710ded36a
commit
1e1c4b978e
17
tf-modulised/vpc-subnets/random/main.tf
Normal file
17
tf-modulised/vpc-subnets/random/main.tf
Normal 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
|
||||
}
|
@ -1,25 +1,19 @@
|
||||
data "aws_availability_zones" "available" {}
|
||||
|
||||
#resource "random_string" "suffix" {
|
||||
# length = 4
|
||||
# special = false
|
||||
#}
|
||||
|
||||
resource "random_integer" "suffix" {
|
||||
min = 1000
|
||||
max = 9999
|
||||
module "random" {
|
||||
source = "./random"
|
||||
}
|
||||
|
||||
module "vpc" {
|
||||
source = "terraform-aws-modules/vpc/aws"
|
||||
version = "2.6.0"
|
||||
|
||||
name = "demo-vpc-${random_integer.suffix.result}"
|
||||
name = "demo-vpc-${module.random.number}"
|
||||
cidr = "172.16.0.0/16"
|
||||
azs = data.aws_availability_zones.available.names
|
||||
private_subnets = cidrsubnets("172.16.18.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
|
||||
enable_dns_hostnames = true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user