Can I access terraform functions using add_override?

I need to decode a GCP Service account json at runtime. Pseudocode:

datadog_sa_key = ServiceAccountKey(
        scope, f'datadog-sa-key-{project_id}',
stuff = TerraformOutput(scope, 'yass', value='ywass')
stuff.add_override('value', '`jsondecode(base64decode("google_service_account_key.datadog_sa_key.private_key")).client_email`')

The docs are a bit sparse in terms of python examples. I’ve tried various variations of specifying the function string but to no avail

The goal is to actually print out the a value from the base64-encoded json stored in the private_key attribute of the datadog_sa_key variable

This is just printing the string for me, not actually executing it. Should what I’m trying to do be possible?

Turns out I was missing a bit of syntax:

this seems to work:


One has to know the id of the terraform resource to perform the function on (in my case it’s a google service account key), but that’s doable.

You can use resource.fqn to get the fully qualified terraform id.

that’s neat! Thanks!