79592311

Date: 2025-04-25 10:24:15
Score: 1
Natty:
Report link

For an AWS SAM template, I used a CloudFormation condition like so:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Example

Parameters:
  Environment:
    Type: String
    Description: Deployment environment
    Default: prd

Conditions:
  IsProd:
    Fn::Equals:
      - !Ref Environment
      - prd

Resources:
  ExampleScheduledFunction:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ScheduleEvent:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: "cron(0 3 ? * MON *)"
            State:
              Fn::If:
                - IsProd
                - ENABLED
                - DISABLED

Reference:

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Zoey