SecurityGroupIngress self_attribute not converted to self
See original GitHub issueCommunity Note
- Please vote on this issue by adding a š reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave ā+1ā or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
cdktf & Language Versions
- Terraform 0.12.29
- cdktf 0.0.13
- Python 3.8.2
Affected Resource(s)
AWS Security Group Ingress
Overview
allow = SecurityGroupIngress(
cidr_blocks=['8.8.8.8/32'],
ipv6_cidr_blocks=[],
protocol='tcp',
from_port=5432,
to_port=5432,
description="Allow",
prefix_list_ids=[],
security_groups=[],
self_attribute=False
)
SecurityGroup(
self, sec_group_name, vpc_id=vpc_id, ingress=[allow]
)
This synthesizes, but terraform plan
fails this way:
Error: Incorrect attribute value type
on cdk.tf.json line 76, in resource.aws_security_group.partneranalyticsdevuseast1_partneranalyticsdevuseast1sg_06726120:
76: "ingress": [
77: {
78: "cidr_blocks": [
79: "8.8.8.8/32"
80: ],
81: "description": "Allow",
82: "from_port": 5432,
83: "ipv6_cidr_blocks": [],
84: "prefix_list_ids": [],
85: "protocol": "tcp",
86: "security_groups": [],
87: "self_attribute": false,
88: "to_port": 5432
89: }
90: ],
Inappropriate value for attribute "ingress": element 0: attribute "self" is
required.
self_attribute
is valid in Python and I assume itās intentionally named that to avoid conflict with Pythonās self
keyword.
But itās not valid in Terraform - it needs to be self
in the output.
Editing cdktf.out
manually and replacing self_attribute
with self
is what Iāll use as a temporary work-around.
Expected Behavior
Plan passes.
Actual Behavior
See above for error.
Steps to Reproduce
Hereās a repo with a full example:
https://github.com/cmclaughlin/terraform-cdk-sgbug
References
By the way, self
is normally an optional value for security groups. However, according to this issue itās required when using JSON instead of HCL. Sounds like thereās not much we can do about that from the cdktf perspective, but if so that would be nice.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:14 (8 by maintainers)
You donāt have to patch the output file for Typescript, you just have to disable the error and provide the right attribute name which is not a reserved word or an issue in JSON. Hereās an example:
Hereās the sed command Iāve been running - just a simple CLI command after
synth
but beforeplan
/apply
:sed -i 's/self_attribute/self/' cdk.tf.json