aws-sam-cli
aws-sam-cli copied to clipboard
Serverless Application Conditional Creation
Description:
It seems that Conditional attribute is not being respected for AWS::Serverless::Application
Steps to reproduce the issue:
- Define
AWS::Serverless::Applicationpointing to non-public application in us-east-2 - Add conditional statement that evaluates to False
- 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
How is your conditional statement defined? Is it based on Intrinsics?
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>