Repository navigation
Description
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]
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
jwalsh2me commentedon Aug 1, 2020
Also tried a
!Ref ProdEnvto see if that would pass the True/False it was also always True.timoschilling commentedon Aug 3, 2020
I think it isn't a bug in SAM CLI it's a bug in https://github.com/awslabs/serverless-application-model
jwalsh2me commentedon Aug 3, 2020
Thanks @timoschilling will open up an issue there and link it back here.
jwalsh2me commentedon Aug 3, 2020
Moved to -->. aws/serverless-application-model#1676
jfuss commentedon Aug 7, 2020
Closing in favor of aws/serverless-application-model#1676