Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to "and" two conditions together in AWS cloudformation

I wish to deploy an AWS resource using cloudformation, but only in specific environments. At the top of my yaml file I have two conditions defined below, where Environment is a parameter that can take different values:

Conditions:
  notInDevelopment:
    !Not [ !Equals [!Ref Environment, development]]
  notInStaging:
    !Not [ !Equals [!Ref Environment, staging]]

When writing the AWS resource, I understand you can specify one condition like Condition: notInDevelopment, but is there a way to "AND/&&" two conditions together such that the resource is deployed when the environment is not development, and is not staging?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, CloudFormation has Fn::And. So you can do:

MyAndCondition: !And
  - !Condition notInDevelopment
  - !Condition notInStaging
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading