I have created cfn template to trigger cloudwatch event periodically to run an ecs task with Fargate launch type. The CW rule looks like below:
sfECSScheduleEventRule:
Type: AWS::Events::Rule
Description: ''
Properties:
State: ENABLED
ScheduleExpression: rate(1 minute)
Name: !Sub sf-eventrule-ecs-${WPRegion}-${WPEnv}
Targets:
- Id: !Sub sf-ecs-target-task-${WPRegion}-${WPEnv}
Arn: !GetAtt
- ECSCluster
- Arn
RoleArn: !GetAtt
- ECSTaskExecutionRole
- Arn
EcsParameters:
#arn:aws:ecs:ap-northeast-1:448965722616:task-definition/fargate-task-jp-stg:latest
TaskDefinitionArn: !Ref sfECSTaskDefinition
TaskCount: !Ref ECSTaskDesiredCount
LaunchType: FARGATE
PlatformVersion: 'LATEST'
NetworkConfiguration:
AwsVpcConfiguration:
AssignPublicIp: DISABLED
Subnets:
- !Ref sfPrivateSubnet1
When I create the stack, I find the rule's target is like below:
Which fails to trigger the task. But when I change task revision from 4 to Latest manually, then it works. Task executes periodically.
How I can change the rule So that it points to the latest?