Yogesh Gupta
Yogesh Gupta

Reputation: 1336

Cloudformation: parameterize the name of a parameter?

I'm currently dealing with an annoying issue:

We are storing some environment (dev/test/prod/etc) specific parameter values in SSM Parameter Store, as such they have different names. They change fairly often.

The environment is being passed to update-stack as a CF template parameter, and I'd like to construct the actual SSM parameter name from that (this is the blog post I'm referencing: https://aws.amazon.com/blogs/mt/integrating-aws-cloudformation-with-aws-systems-manager-parameter-store/)

I really want to use a single generic parameter in my Cloudformation template, however, that does not seem to be possible because the values of the parameters need to be hardcoded. And you can't seem to !Ref a !Join statement.

Anyone out there done something similar and found a good workaround?

Upvotes: 2

Views: 560

Answers (1)

Lee Netherton
Lee Netherton

Reputation: 22512

Unfortunately, intrinsic functions (such as !Join) can only be used in certain parts of a CloudFormation template:

You can use intrinsic functions only in specific parts of a template. Currently, you can use intrinsic functions in resource properties, outputs, metadata attributes, and update policy attributes.

This means you will probably have to use !Join in every place that you want to build the SSM parameter name.

You may be able to use !Transform to do a find-and-replace operation, but it depends on the specific circumstances that you have.

Upvotes: 2

Related Questions