Systematic name prefix for all compatible constructs (Python)

Hi there,
I’d like to know if there is a way to provide a name prefix for all constructs where such a prefix would be sensible.
For example, in the case of an S3 bucket, there is a bucket_prefix argument which can be supplied to S3Bucket.
The idea here is that when I deploy these resources, I can easily determine their purpose based on their names.

As the application I’m developing grows in complexity, I’d love a way to just handle this systematically in one place.

If this isn’t possible, are there any mechanisms to operate on the generated resource names in some way to achieve the same effect?


You can define variables or constants for these prefixes in a central location within your codebase. It will allows you to easily modify them if needed and ensures consistency across all resources. Maybe something like this:

USER_PREFIX = “usr_”
ORDER_PREFIX = “ordr_”

If you ever need to change a prefix, you can do so in just one place, confirming consistency across your codebase.

Hi @sanjana8903,
Thanks for the reply but that’s not what I meant, though I can see I was ambiguous in my post.
What I meant was on the cdktf side, or the terraform side - I’m new to these technologies so I’m not sure if this is possible. Ultimately I guess terraform, along with the providers it uses are in charge of creating resource names and what I was hoping for was a way to make all resource names in some configuration have the same prefix without having to worry about it on a case by case basis at the construct level.

I’ve skimmed some of the Python source and I don’t see a mechanism, but I thought I’d ask anyway.


Huh, Aspects - CDK for Terraform | Terraform | HashiCorp Developer seems like the best place for me to start with this. At the very least I can add some policy checks as regards prefixes. The example in that page is actually for S3 bucket name prefixes!