File tree Expand file tree Collapse file tree
pkg/iac/scanners/terraformplan/tfjson/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,10 +144,13 @@ func (r *hclRenderer) renderSlice(vals []any) {
144144 r .incIndent ()
145145 defer r .decIndent ()
146146
147- for _ , v := range vals {
147+ for i , v := range vals {
148148 r .write (r .indent + " " )
149- renderPrimitive (r .w , v )
150- r .writeln ("," )
149+ r .renderAttributeValue (v )
150+ if i != len (vals )- 1 {
151+ r .write ("," )
152+ }
153+ r .writeln ("" )
151154 }
152155 r .write (r .indent + "]" )
153156}
Original file line number Diff line number Diff line change @@ -120,6 +120,38 @@ func Test_ToHcl(t *testing.T) {
120120 to_port = 80
121121 }
122122}
123+ ` ,
124+ },
125+ {
126+ name : "list attribute with nested lists" ,
127+ block : PlanBlock {
128+ BlockType : "resource" ,
129+ Type : "foo" ,
130+ Name : "bar" ,
131+ Attributes : map [string ]any {
132+ "nested" : []any {
133+ []any {"a" , "b" },
134+ []any {"c" },
135+ []any {"d" , "e" , "f" },
136+ },
137+ },
138+ },
139+ expected : `resource "foo" "bar" {
140+ nested = [
141+ [
142+ "a",
143+ "b"
144+ ],
145+ [
146+ "c"
147+ ],
148+ [
149+ "d",
150+ "e",
151+ "f"
152+ ]
153+ ]
154+ }
123155` ,
124156 },
125157 {
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ resource "aws_security_group" "sg" {
5757 }
5858 ingress {
5959 cidr_blocks = [
60- "0.0.0.0/0",
60+ "0.0.0.0/0"
6161 ]
6262 description = ""
6363 from_port = 80
You can’t perform that action at this time.
0 commit comments