I was looking at the code of terraform VPC module and found
resource "aws_subnet" "public" {
vpc_id = aws_vpc_ipv4_cidr_block_association.secondary_cidr.vpc_id
cidr_block = "172.2.0.0/24"
availability_zone = null
}
availability_zone
attribute is optional based on the docs of AWS provider.
Is setting availability_zone
to null
is the same as not listing it all? For example, this is the same way to write the following configuration:
resource "aws_subnet" "in_secondary_cidr" {
vpc_id = aws_vpc_ipv4_cidr_block_association.secondary_cidr.vpc_id
cidr_block = "172.2.0.0/24"
}
I've never seen it before. Seems like it's a popular way to declare an optional variable in a module:
variable "private_subnet_assign_ipv6_address_on_creation" {
description = "Assign IPv6 address on private subnet, must be disabled to change IPv6 CIDRs. This is the IPv6 equivalent of map_public_ip_on_launch"
type = bool
default = null
}
Yes, if you use null is the same as not listing it all. From docs: