简体   繁体   中英

Is it possible in CloudFormation to share Conditions definition across nested stack?

Let's say I want to declare several conditions that are, actually, can be used across nested resources (in CloudFormation). Here is a very simple example:

Parameters:
  EnvType:
    Type: String
    Description: Environment type.
    Default: test
    AllowedValues: [test, dev]
    ConstraintDescription : Must specify test or dev.

Conditions:
  CreateTestEnvResources: !Equals [!Ref EnvType, test]
  CreateDevEnvResources: !Equals [!Ref EnvType, dev]

Is it possible somehow to pass through this declaration across nested stack resources ( AWS::CloudFormation::Stack )? Or the only way is to use EnvType and make declaration in every Stack?

Or the only way is to use EnvType and make declaration in every Stack?

Sadly, this is the only way. But if you really would like to eliminate this step, you could possibly develop a macro in CloudFormation for that. Nevertheless, the re-declaration of EnvType in each nested stack is still the most readable and easiest to debug and implement way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM