Skip to content

Instantly share code, notes, and snippets.

@vanbrands
Last active May 14, 2019 01:59
Show Gist options
  • Save vanbrands/5f92338f41d6437906ac36d800133505 to your computer and use it in GitHub Desktop.
Save vanbrands/5f92338f41d6437906ac36d800133505 to your computer and use it in GitHub Desktop.
[AWS Ticket Cloudformation & ECS] #aws #ebanx

Cannot trigger a Fargate Task with a CloudWatch event using CloudFormation.

NetworkConfiguration and LaunchType are not supported.

Cloudformation Template:

ScheduleExample:
  Type: AWS::Events::Rule
  Properties:
    Description: Run every 1 hour.
    ScheduleExpression: "rate(1 hour)"
    State: ENABLED
    Targets:

      - Arn: !GetAtt ECSCluster.Arn
        Id: 'Target Example'
        RoleArn: !GetAtt ECSEventRole.Arn
        EcsParameters:
          TaskCount: 1
          TaskDefinitionArn: !Ref TaskDefinition
          LaunchType: FARGATE
          NetworkConfiguration:
            awsvpcConfiguration:
              AssignPublicIp: ENABLED
              SecurityGroups: [...]
              Subnets: [...]

Status Reason

Encountered unsupported property LaunchType
Encountered unsupported property NetworkConfiguration

CloudWatch Event API ECS Parameters:

https://docs.aws.amazon.com/AmazonCloudWatchEvents/latest/APIReference/API_EcsParameters.html

  • Group
  • LaunchType
  • NetworkConfiguration
  • PlatformVersion
  • TaskCount
  • TaskDefinitionArn

AWS::Events::Rule ECS Parameters:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-ecsparameters.html

  • TaskCount
  • TaskDefinitionArn

Only Solutions?

  • Configure NetworkConfiguration and LaunchType using the console.
  • CloudWatch Event triggering a Lambda that makes a run_task API request to ECS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment