aws_security_group

    0

    0

    lucycodes42

    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

    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"
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.