0
0
llucycodes42
The code creates a variable, security_group_id, that contains the id of the security group that is being selected. The data section sets the id of the subnet resource to the value that is returned from the variable.
Shortcut: tf_aws_security_group
variable "security_group_id" {}
data "aws_security_group" "${selected}" {
id = "\${var.security_group}"
}
resource "aws_subnet" "subnet" {
vpc_id = "\${data.aws_security_group.${selected}.vpc_id}"
cidr_block = "10.0.1.0/24"
}