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" {}
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user