Repository navigation
Description
SEE ALSO in aws-sam-cli aws/aws-sam-cli#2150
Description
I have a Condition in my SAM Template to check the ENV Parameter it True. I am trying to pass that into a Timer Event to either be true or false under Enabled. It always sends it as true. Setting that value to either true or false works as expected, but using Enabled: !If [ProdEnv, "false", "false"] or Enabled: !If [ProdEnv, "true", "false"] always sets it to true and enabled.
Steps to reproduce
SAM CLI, version 1.0.0
snipped template:
<SNIP>
Parameters:
ENV:
Type: String
Default: prod
AllowedValues:
- prod
- stage
ProdDbKMSKeyID:
Type: "AWS::SSM::Parameter::Value<String>"
Default: "/db/prod/KMSKeyID"
NonProdKMSKeyID:
Type: "AWS::SSM::Parameter::Value<String>"
Default: "/db/nonprod/KMSKeyID"
VendorsKMSKeyID:
Type: "AWS::SSM::Parameter::Value<String>"
Default: "/vendors-prod-lambda/KMSKeyID"
Conditions:
ProdEnv: !Equals [!Ref ENV, prod]
Environment:
Variables:
app_env: !Ref ENV
dbhost: !Sub "{{resolve:ssm:/db/${ENV}/edw/hostname:1}}"
dbuser: !Sub "{{resolve:ssm:/db/${ENV}/edw/lambda_user:1}}"
dbname: !Sub "{{resolve:ssm:/db/${ENV}/edw/dbname:1}}"
<SNIP>
VpcConfig:
SecurityGroupIds:
- <removed>
SubnetIds:
- <removed>
- <removed>
Events:
Timer:
Type: Schedule
Properties:
Schedule: cron(00 16 ? * MON,WED *)
Description: sFTP
Enabled: !If [ProdEnv, true, false]
Policies:
- AWSLambdaExecute
- VPCAccessPolicy: {}
- KMSDecryptPolicy:
KeyId: !If [ProdEnv, !Ref ProdDbKMSKeyID, !Ref NonProdKMSKeyID]
- KMSDecryptPolicy:
KeyId: !Ref VendorsKMSKeyID
<SNIP>
Observed result
The ENV is set to be stage, other !If work as expected above however the Timer is set to be Enabled.
Now if I skip the !If and just pass a true or false to Enabled it works as expected. So I am not sure if this is just not supported for the Timer or if there is a problem with the transform.
Expected result
I expected the Timer to have been set to false.
Events:
Timer:
Type: Schedule
Properties:
Schedule: cron(00 16 ? * MON,WED *)
Description: sFTP
Enabled: !If [ProdEnv, true, false]
Also tried a !Ref ProdEnv to see if that would pass the True/False it was also always True.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: macOS 10.15.6
sam --version: 1.0.0
Add --debug flag to command you are running
Activity
jfuss commentedon Aug 7, 2020
This is a duplicate of #1329.
Closing