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"

      Terraform language logo

      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


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.