hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.79k stars 441 forks source link

SecurityGroup error: The argument "egress.0.to_port" is required, but no definition was found. #3661

Open RoniFinTech3 opened 1 week ago

RoniFinTech3 commented 1 week ago

Expected Behavior

When Terraform plan is complete, to_port and from_port should appear in the SecurityGroup plan.

example code: sg = aws.security_group.SecurityGroup(self, "SecurityGroup", vpc_id=vpc.id, description="Allow internal access and outbound public access", ingress=[], egress=[{"protocol": "-1", "from_port": 0, "to_port": 0, "cidr_blocks": ["0.0.0.0/0"]}], tags={"Name": config["vpc"]["sec_grp_name"]})

Actual Behavior

"aws_security_group": { "SecurityGroup": { "//": { "metadata": { "path": "vpc-nonprod/SecurityGroup", "uniqueId": "SecurityGroup" } }, "description": "Allow internal access and outbound public access", "egress": [ { "cidr_blocks": null, "description": null, "from_port": null, "ipv6_cidr_blocks": null, "prefix_list_ids": null, "protocol": "-1", "security_groups": null, "self": null, "to_port": null } ], "ingress": [ ], "tags": { "Name": "nonprod-fd-sec-grp" }, "vpc_id": "${aws_vpc.Vpc.id}" } },

to_port and from_port are both null.

Steps to Reproduce

use CDKTF in Python and define a security group:

sg = aws.security_group.SecurityGroup(self, "SecurityGroup",
                                              vpc_id=vpc.id,
                                              description="Allow internal access and outbound public access",
                                              ingress=[],
                                              egress=[{"protocol": "-1", "from_port": 0, "to_port": 0,
                                                       "cidr_blocks": ["0.0.0.0/0"]}],
                                              tags={"Name": config["vpc"]["sec_grp_name"]})

Versions

Terraform v1.8.5 on darwin_arm64

cdktf --version 0.20.7

Python 3.9

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

Community Note