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"
      }
      Terraform language logo

      aws_security_group

      Terraform snippets

      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

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.