aws_vpc

    0

    0

    lucycodes42

    Terraform snippets

    This code snippet creates an AWS VPC and assigns it the VPC ID "{var.vpc_id}" . The VPC has an availability zone of "us-west-2a" and a CIDR block of "4.1.1.0/24" .

    Shortcut: tf_aws_vpc

    variable "vpc_id" {}
    
    data "aws_vpc" "${selected}" {
       id = "\${var.vpc_id}"
    }
    
    resource "aws_subnet" "example" {
        vpc_id            = "\${data.aws_vpc.${selected}.id}"
        availability_zone = "us-west-2a"
        cidr_block        = "\${cidrsubnet(data.aws_vpc.${selected}.cidr_block, 4, 1)}"
    }
    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.