Hi, I’m currently working with cdktf using typescript and I would like to ensure that an output will be treated as json string.
I have a module (AwsEksIrsaPolicy) that has output with attributes:
public get assumeRolePolicyOutput(): string {
return this.interpolationForOutput('assume_role_policy')
}
Which I would then assign to a string property:
const iamRole = new IamRole(this, 'exampleIamRole', {
name: 'ExampleIAMRoleForServiceAccount',
assumeRolePolicy: 'awsEksIrsaPolicy.assumeRolePolicyOutput',
});
However, this will be synthesized to simply
${module.awsEksIrsaPolicy.assume_role_policy} and terraform plan will error out with:
│ Error: Invalid template interpolation value
│
│ 63: "assume_role_policy": "${module.awsEksIrsaPolicy.assume_role_policy}",
│ ├────────────────
│ │ module.awsEksIrsaPolicy.assume_role_policy is object with 9 attributes
I was able to workaround with it by hardcoding. i.e.
assumeRolePolicy: '${module.awsEksIrsaPolicy.assume_role_policy.json}'
This way, jsonencode will be called in terraform plan.
What is the best way to ensure that it will be treated as json string?
cdktf version is 0.5.0
terraform version is v1.0.1
Thank you.