Open Jiafi opened 1 year ago
https://github.com/hashicorp/terraform-cdk/pull/2446 Potential fix.
Hi @Jiafi π
Good catch, it seems like these lines are a bit too overambitious: https://github.com/hashicorp/terraform-cdk/blob/1908d763a5a676651579983100f92cb08c74777c/packages/cdktf/lib/terraform-resource.ts#L185-L189
We should confirm what exactly we need to convert there. Probably just the first layer but not deeper.
That said, you can workaround this problem using an escape hatch:
new nullProvider.NullProvider(this, "null", {});
const adminScript = new nullResource.Resource(
this,
"postgisAdminScript",
{}
);
// using overrides to preserve casing of environment variables (open issue: https://github.com/hashicorp/terraform-cdk/issues/2443)
adminScript.addOverride("provisioner", [
{
// Pipe system password into script as input
type: "local-exec",
// If this command fails, the password is printed out locally. Need to figure out a better way of configuring the password
command: `echo $PGPASSWORD`,
environment: {
PGPASSWORD: "password",
},
},
]);
@ansgarm Thanks for the workaround! It mostly worked but needed to be changed slightly. Needed local-exec
as the key.
new nullProvider.NullProvider(this, "null", {});
const adminScript = new nullResource.Resource(
this,
"postgisAdminScript",
{}
);
// using overrides to preserve casing of environment variables (open issue: https://github.com/hashicorp/terraform-cdk/issues/2443)
adminScript.addOverride('provisioner', [
{
['local-exec']: {
command: `${postgisUserSetupScript.path} ${rds.rdsHostOutput} ${this.postgresDB} ${rds.rdsSystemUsernameOutput} ${this.postgresUser}`,
environment: {
PGPASSWORD: rds.rdsSystemPasswordOutput,
},
},
},
]);
Ah, whoops π Glad you figured it out!
Community Note
cdktf & Language Versions
cdktf version
0.14.3
TypescriptAffected Resource(s)
nullResource using the
LocalExecProvisioner
.Debug Output
Generates
Expected Behavior
Actual Behavior
Steps to Reproduce
Create a null provider and resource.
Important Factoids
environment should respect the casing that is originally used in the
environment
Record
.It looks like all keys are being lower cased here
References
0000