• 카테고리

    질문 & 답변
  • 세부 분야

    데브옵스 · 인프라

  • 해결 여부

    미해결

security-group 생성 중 오류가 나서 질문을 드립니다.

21.09.16 10:28 작성 조회수 201

0

테라폼 버전은 1.0.6 이고 aws 버전은 3.5.8을 이용하여 실습을 따라하고 있습니다.
 
현재 Security-group을 생성 하는 실습을 하고 있는데 tf plan 명령어를 입력하면
 
Inappropriate value for attribute "ingress": element 0: attributes "prefix_list_ids", "security_groups", and "self" are required.
 
Inappropriate value for attribute "egress": element 0: attributes "prefix_list_ids", "security_groups", and "self" are required.
 
이 2가지 문구가 나오면 오류가 표시 됩니다.
 
알려주신 registry.terraform.io 에서도 "prefix_list_ids", "security_groups","self"는 선택 사항이라고 나오는데 오류 문구는 필수라고 나오는데 버전 다운을 하지 않고 해결 할 수 있는 법이 있을까요??
 
아래는 오류 메시지랑 버전 이미지입니다.
 

답변 1

답변을 작성해보세요.

0

안녕하세요. alsyean님, 강의 들어주셔서 감사합니다.

질문 내용에 대해 답변드리겠습니다.

 

Terraform 버전 v1.0.4, v1.0.7 2개의 버전으로 Terraform 의 Security Group 테스트를 해보았습니다.

결과적으로 terraform plan 실행 시에 2개의 Terraform 버전 동일하고 아래와 같이 정상 결과가 나왔습니다. 

 

# aws_security_group.allow_web will be created

  + resource "aws_security_group" "allow_web" {

      + arn                    = (known after apply)

      + description            = "Allow web inbound traffic"

      + egress                 = [

          + {

              + cidr_blocks      = [

                  + "0.0.0.0/0",

                ]

              + description      = ""

              + from_port        = 0

              + ipv6_cidr_blocks = []

              + prefix_list_ids  = []

              + protocol         = "-1"

              + security_groups  = []

              + self             = false

              + to_port          = 0

            },

        ]

      + id                     = (known after apply)

      + ingress                = [

          + {

              + cidr_blocks      = [

                  + "0.0.0.0/0",

                ]

              + description      = "web from VPC"

              + from_port        = 0

              + ipv6_cidr_blocks = []

              + prefix_list_ids  = []

              + protocol         = "-1"

              + security_groups  = []

              + self             = false

              + to_port          = 0

            },

        ]

      + name                   = "allow_web"

      + name_prefix            = (known after apply)

      + owner_id               = (known after apply)

      + revoke_rules_on_delete = false

      + tags                   = {

          + "Name" = "allow_web"

        }

      + tags_all               = {

          + "Name" = "allow_web"

        }

      + vpc_id                 = "vpc-0707d523c3a075ee0"

    }

 

Plan: 3 to add, 0 to change, 0 to destroy.

 

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

 

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you

run "terraform apply" now.

 

강의에 나오는 테스트 Security Group 예제를 공유 드립니다.

resource "aws_security_group" "allow_web" {

  name        = "allow_web"

  description = "Allow web inbound traffic"

  vpc_id      = var.vpc_id

 

  ingress {

    description = "web from VPC"

    from_port   = 0

    to_port     = 0

    protocol    = "-1"

    cidr_blocks = ["0.0.0.0/0"]

  }

 

  egress {

    from_port   = 0

    to_port     = 0

    protocol    = "-1"

    cidr_blocks = ["0.0.0.0/0"]

  }

 

  tags = {

    Name = "allow_web"

  }

}