Defining resources conditionally based on environment
Two important things:
- During a stack update, you can't update conditions by themselves. You can update conditions only when you include changes that add, modify, or delete resources.
- Where to put conditions: see How to use conditions overview
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Parameters: Environment: Type: String AllowedValues: - acc - prod Conditions: # <-- define conditions here IsProd: !Equals - !Ref Environment - prod Resources: Main: Type: AWS::Serverless::Function Events: PeriodicTrigger: Type: Schedule Properties: Schedule: rate(5 minutes) Input: !If [ IsProd, '"foo"', '"bar"' ] # 🎉 # ... CodeUri, etc...