diff --git a/packages/@cdktf/hcl2cdk/test/__snapshots__/tfExpressions.test.ts.snap b/packages/@cdktf/hcl2cdk/test/__snapshots__/tfExpressions.test.ts.snap index 2970110647..25c213a716 100644 --- a/packages/@cdktf/hcl2cdk/test/__snapshots__/tfExpressions.test.ts.snap +++ b/packages/@cdktf/hcl2cdk/test/__snapshots__/tfExpressions.test.ts.snap @@ -314,3 +314,17 @@ class MyConvertedCode extends TerraformStack { } " `; + +exports[`tfExpressions strings containing single outer quotes are supported snapshot typescript 1`] = ` +"import { Construct } from "constructs"; +import { TerraformOutput, TerraformStack } from "cdktf"; +class MyConvertedCode extends TerraformStack { + constructor(scope: Construct, name: string) { + super(scope, name); + new TerraformOutput(this, "hash", { + value: "'static'", + }); + } +} +" +`; diff --git a/packages/@cdktf/hcl2cdk/test/tfExpressions.test.ts b/packages/@cdktf/hcl2cdk/test/tfExpressions.test.ts index 04ae970559..594c1d23a0 100644 --- a/packages/@cdktf/hcl2cdk/test/tfExpressions.test.ts +++ b/packages/@cdktf/hcl2cdk/test/tfExpressions.test.ts @@ -238,4 +238,18 @@ ITEM resources: [], } ); + + testCase.test( + "strings containing single outer quotes are supported", + ` + output "hash" { + value = "'static'" + }`, + [], + Snapshot.yes, + Synth.yes, + { + resources: [], + } + ); }); diff --git a/packages/@cdktf/hcl2json/lib/bridge.ts b/packages/@cdktf/hcl2json/lib/bridge.ts index 58b68ee3dc..5502f30ec7 100644 --- a/packages/@cdktf/hcl2json/lib/bridge.ts +++ b/packages/@cdktf/hcl2json/lib/bridge.ts @@ -144,7 +144,7 @@ export async function getReferencesInExpression( // with a multi-line string, which is causing all kinds of problems let offset = 0; let quoteWrappedExpression = expression; - if (!expression.startsWith('"') && !expression.startsWith("'")) { + if (!expression.startsWith('"')) { quoteWrappedExpression = `"${expression}"`; offset = 1; } diff --git a/packages/@cdktf/hcl2json/lib/util.ts b/packages/@cdktf/hcl2json/lib/util.ts index b73de5a5f7..51ccc618c6 100644 --- a/packages/@cdktf/hcl2json/lib/util.ts +++ b/packages/@cdktf/hcl2json/lib/util.ts @@ -55,7 +55,7 @@ export function wrapTerraformExpression(input: string): { return { wrap: input, wrapOffset: 0 }; } - if (input.startsWith(`"`) || input.startsWith("'")) { + if (input.startsWith(`"`)) { if (input.indexOf("\n") >= 0) { const trimWrapped = input.substring(1, input.length - 1); return {