File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ function wrapIdentifierInQuotesIfNeeded(key: string): string {
26
26
*
27
27
*/
28
28
function renderString ( str : string ) : string {
29
+ if ( str === "" ) {
30
+ return `""` ;
31
+ }
32
+
29
33
if ( ! str ) {
30
34
return str ;
31
35
}
@@ -526,6 +530,10 @@ function renderFuzzyJsonExpression(jsonExpression: any): string {
526
530
}
527
531
528
532
if ( typeof jsonExpression === "string" ) {
533
+ if ( jsonExpression === "" ) {
534
+ return `""` ;
535
+ }
536
+
529
537
if ( jsonExpression . includes ( "${" ) ) {
530
538
return `"${ jsonExpression } "` ;
531
539
}
@@ -609,7 +617,7 @@ export function renderAttributes(attributes: any): string {
609
617
! v . hasOwnProperty ( "dynamic" )
610
618
) {
611
619
if ( metaBlocks . includes ( name ) ) {
612
- return `${ name } {
620
+ return `${ name } {
613
621
${ renderSimpleAttributes ( v ) }
614
622
}` ;
615
623
}
@@ -643,8 +651,8 @@ ${renderSimpleAttributes(v)}
643
651
}
644
652
645
653
if ( block && type !== "list" && type !== "set" ) {
646
- return `${ name } {
647
- ${ renderAttributes ( value ) }
654
+ return `${ name } {
655
+ ${ renderAttributes ( value ) }
648
656
}` ;
649
657
}
650
658
if ( type === "list" || type === "set" ) {
Original file line number Diff line number Diff line change @@ -74,6 +74,33 @@ test("string local with quoted name", async () => {
74
74
` ) ;
75
75
} ) ;
76
76
77
+ test ( "empty string" , async ( ) => {
78
+ const app = Testing . app ( ) ;
79
+ const stack = new TerraformStack ( app , "test" ) ;
80
+
81
+ new TerraformLocal ( stack , "greeting" , {
82
+ a : "" ,
83
+ } ) ;
84
+
85
+ new TestResource ( stack , "test" , {
86
+ name : "" ,
87
+ } ) ;
88
+
89
+ const hcl = Testing . synthHcl ( stack ) ;
90
+ expect ( hcl ) . toMatchInlineSnapshot ( `
91
+ "
92
+
93
+ locals {
94
+ greeting = {
95
+ a = ""
96
+ }
97
+ }
98
+ resource "test_resource" "test" {
99
+ name = ""
100
+ }"
101
+ ` ) ;
102
+ } ) ;
103
+
77
104
test ( "with provider alias" , async ( ) => {
78
105
const app = Testing . app ( ) ;
79
106
const stack = new TerraformStack ( app , "test" ) ;
You can’t perform that action at this time.
0 commit comments