Home > Blockchain >  Is it possible to reference optional Parameter Store parameters in a CloudFormation template?
Is it possible to reference optional Parameter Store parameters in a CloudFormation template?

Time:02-04

I'd like to make CloudFormation look in Parameter Store for a particular parameter - and if not found, look for a different one.

The actual use case is that stacks are deployed for different branches and we'd like to have top-level parameters for all branches that can optionally be overridden by creating a branch-specific parameter. Something like this:

dev-param = 120  <-- top-level, applies if branch-specific parameter doesn't exist
dev-param.mybranch = 60  <-- branch-specific parameter

Have tried a couple of ways but got an error when deploying the stack for both - see below.

When attempting to use dynamic references:

Parameters: [ssm:dev-param.mybranch] cannot be found.

When attempting to use CloudFormation SSM Parameter Types.

Template format error: Every Default member must be a string.

For the latter, the Default: field specifies the Parameter Store key name. This needs to be generated dynamically from other CloudFormation parameters, e.g. there is a parameter for the environment type so development key names begin with dev- and production keys begin with prod-.

Is there another way to achieve this?

CodePudding user response:

You can't do that without a custom resource or a macro.

  •  Tags:  
  • Related