serverless-aws-alias
serverless-aws-alias copied to clipboard
AWS Conditions is not defined / missing in alias stack
I'm trying to use AWS Conditions in order to create conditional Resources.
Conditions generally work like this in your serverless.yaml
:
...
resources:
Conditions:
IsProdCondition:
Fn::Equals: [ '${self:custom.stage}', 'prod' ]
Resources:
MyResource:
Type: AWS::S3::Bucket
Condition: IsProdCondition
...
Unfortunately that doesn't work with the Alias plugin 😢
While the Conditions
section properly appears in the cloudformation-template-update-stack.json
stack, it's missing in the cloudformation-template-update-alias-stack.json
one. This causes an error during deployment:
Template format error: Condition IsProdCondition is not defined.
The simplest solution should be to copy the Conditions
section in both stack JSONs. Then it's accessible in both cases and even if might not always be necessary, it doesn't hurt to have a superfluous condition defined either.
Conditions should be defined outside of resources between Parameters and Resources