serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

AWS Conditions is not defined / missing in alias stack #124

Open arabold opened 6 years ago

arabold commented 6 years ago

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.

tanyingwang commented 1 year ago

Conditions should be defined outside of resources between Parameters and Resources