Open
Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
Currently tokens are forced into strings, and dependsOn
or addOverride
resolves these down to templated strings, which are not allowed. Where a block of code such as this:
const account = new ServiceAccount(scope, `${name}-account`, {
accountId: name,
description: "Generated by Terraform",
});
const key = new ServiceAccountKey(scope, `${name}-key`, {
serviceAccountId: account.id,
publicKeyType: "TYPE_RAW_PUBLIC_KEY",
});
key.dependsOn = [ account.id ];
Which results in the following error from terraform:
│ Error: Invalid expression
│
│ on cdk.tf.json line 102, in resource.google_service_account_key.logging-robot-key.depends_on:
│ 102: "${google_service_account.logging-robot-account.id}",
│
│ A single static variable reference is required: only attribute access and
│ indexing with constant keys. No calculations, function calls, template
│ expressions, etc are allowed here.
There needs to be a simple way for people to reference the object without templated strings.
Ideally, this might be as simple as having some kind of toUntemplatedString
(ugly, not set on the name of the function/property)
So the above code would look something along the lines of:
const account = new ServiceAccount(scope, `${name}-account`, {
accountId: name,
description: "Generated by Terraform",
});
const key = new ServiceAccountKey(scope, `${name}-key`, {
serviceAccountId: account.id,
publicKeyType: "TYPE_RAW_PUBLIC_KEY",
});
key.dependsOn = [ account.idRaw ];
Which result in a cdk.tf.json:
"depends_on": [
"google_service_account.logging-robot-account.id"
]
Happy to do some of the implementation if it helps!