【InvalidParameterValue: The same permission must not appear multiple times】aws_security_group リソースを terraform apply したときのエラーの原因と解決策
1.この記事で達成したいこと aws_security_groupリソースを使って複数のインバウンドルールを追加しようとして引いたエラーを解決する $ terraform apply 略 │ Error: error updating Security Group (sg-000000000000): error authorizing Security Group (ingress) rules: InvalidParameterValue: The same permission must not appear multiple times │ status code: 400, request id: 000000000000000000 │ │ with aws_security_group.dummy-sg, │ on main.tf line 23, in resource "aws_security_group" "dummy-sg": │ 23: resource "aws_security_group" "dummy-sg" { エラーメッセージが指す23行目付近で書いていること $ view main.tf 略 23 resource "aws_security_group" "dummy-sg" { 24 name = "dummy-sg" 25 description = "dummy security group" 26 vpc_id = aws_vpc.dummy-vpc.id 27 28 ingress { 29 description = "Allow 80 from anywhere for redirection" 30 from_port = 80 31 to_port = 80 32 protocol = "all" 33 cidr_blocks = ["0.0.0.0/0"] 34 } 35 36 ingress { 37 description = "Allow 8080 from anywhere for redirection" 38 from_port = 8080 39 to_port = 8080 40 protocol = "all" 41 cidr_blocks = ["0.0.0.0/0"] 42 } 2.前提 Terraformのインストール方法を始めとする初期設定は終えているものとして話を進める 3.環境情報 Terraform実行環境 $ grep VERSION= /etc/os-release VERSION="20.04.3 LTS (Focal Fossa)" $ terraform version Terraform v1.1.0 on linux_amd64 + provider registry.terraform.io/hashicorp/aws v3.70.0 ※ terraform applyで使う要件については、後述するaws_security_groupリソースくらい。なので、ここでは割愛。 ...