aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Serverless Application Conditional Creation

Open bbernays opened this issue 6 years ago • 2 comments

Description: It seems that Conditional attribute is not being respected for AWS::Serverless::Application

Steps to reproduce the issue:

  1. Define AWS::Serverless::Application pointing to non-public application in us-east-2
  2. Add conditional statement that evaluates to False
  3. run sam build --region us-west-2

Observed result: I get the following error: samcli.commands.validate.lib.exceptions.InvalidSamDocumentException: [InvalidResourceException('<APPLICATION NAME>', 'Application with id arn:aws:serverlessrepo:us-east-2:<ACCOUNT>:applications/<APPLICATION NAME> could not be found.')] ('<APPLICATION NAME>', 'Application with id arn:aws:serverlessrepo:us-east-2:<ACCOUNT>:applications/<APPLICATION NAME> could not be found.')

Expected result: The expected result would be for the application to be ignored and not built

bbernays avatar Mar 25 '19 12:03 bbernays

How is your conditional statement defined? Is it based on Intrinsics?

sriram-mv avatar Mar 27 '19 15:03 sriram-mv

Below is resource we are trying to deploy

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Conditions:
  IsProdEnv: !Equals [!Ref "AWS::AccountId", <ACCOUNT-NUMBER-1>]
Resources:
  CouponGeneration:
    Type: AWS::Serverless::Application
    Condition: IsProdEnv
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:<REGION>:<ACCOUNT-NUMBER-1>:applications/<APPLICATION-NAME>
        SemanticVersion: <VERSION>

bbernays avatar Mar 29 '19 12:03 bbernays