aws_subnet

    0

    0

    lucycodes42

    Terraform snippets

    The code defines a variable "subnet_id" and assigns it the value of the data item "${selected}" which is the contents of the data variable "aws_subnet". Additionally, the code defines a resource "aws_security_group" and sets its associated variable "subnet" to the value of the data item "${selected}.

    Shortcut: tf_aws_subnet

    variable "subnet_id" {}
    
    data "aws_subnet" "${selected}" {
        id = "\${var.subnet_id}"
    }
    
    resource "aws_security_group" "subnet" {
        vpc_id = "\${data.aws_subnet.${selected}.vpc_id}"
    
        ingress {
            cidr_blocks = ["\${data.aws_subnet.${selected}.cidr_block}"]
            from_port   = 80
            to_port     = 80
            protocol    = "tcp"
        }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.