x-events

x-events:
  event-logical-name:
    Properties: {}
    Services: {}

Define an AWS EventBride rule to create Scheduled Tasks with the defined services.

See also

See to Create ECS Scheduled tasks using AWS EventsBridge for a step by step example.

Services

There we define the tasks we want to deploy at specific times or events.

Services syntax for rules
Services:
<service_family_name>:
  TaskCount: <N>
  DeleteDefaultService: True/False (default. False)

TaskCount

Same property as for ECS Parameters of the Task Rule target definition itself, this allows you to set a specific number of tasks.

Required: Yes.

Hint

Not using deploy/replicas on purpose, because of the DeleteDefaultService option

DeleteDefaultService

Custom setting, this allows you to NOT define a ECS Service along with the task, therefore you will only get the TaskDefinition created.

Properties

You can find all the properties on the AWS CFN Events Rules definitions .

Note

You do not need to define Targets to point to the services defined in docker-compose. Refer to Services for that.

JSON Schema

Model

x-events

x-events.spec.json

x-events specification

type

object

properties

  • Properties

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

type

object

  • Settings

x-resources.common.spec.json#/definitions/Settings

  • Services

#/definitions/ServicesDef

  • MacroParameters

type

object

additionalProperties

False

definitions

  • ServicesDef

oneOf

#/definitions/ServicesMappingDef

#/definitions/ServicesListDef

  • ServicesListDef

type

array

items

type

object

properties

  • name

Name of the service defined in services

type

string

  • TaskCount

Number of containers to start on event

type

number

minimum

1

  • DeleteDefaultService

Whether or also create the ECS Service

type

boolean

  • ServicesMappingDef

type

object

patternProperties

  • [\x20-\x7E]+$

properties

  • TaskCount

Number of containers to start on event

type

number

minimum

1

  • DeleteDefaultService

Whether or also create the ECS Service

type

boolean

additionalProperties

False

Definition

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "id": "x-events.spec.json",
  "$id": "x-events.spec.json",
  "title": "x-events",
  "description": "x-events specification",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "Properties": {
      "type": "object",
      "description": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html"
    },
    "Settings": {
      "$ref": "x-resources.common.spec.json#/definitions/Settings"
    },
    "Services": {
      "$ref": "#/definitions/ServicesDef"
    },
    "MacroParameters": {
      "type": "object"
    }
  },
  "definitions": {
    "ServicesDef": {
      "oneOf": [
        {
          "$ref": "#/definitions/ServicesMappingDef"
        },
        {
          "$ref": "#/definitions/ServicesListDef"
        }
      ]
    },
    "ServicesListDef": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "TaskCount"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the service defined in services"
          },
          "TaskCount": {
            "type": "number",
            "minimum": 1,
            "description": "Number of containers to start on event"
          },
          "DeleteDefaultService": {
            "type": "boolean",
            "description": "Whether or also create the ECS Service"
          }
        }
      }
    },
    "ServicesMappingDef": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "[\\x20-\\x7E]+$": {
          "properties": {
            "TaskCount": {
              "type": "number",
              "minimum": 1,
              "description": "Number of containers to start on event"
            },
            "DeleteDefaultService": {
              "type": "boolean",
              "description": "Whether or also create the ECS Service"
            }
          }
        }
      }
    }
  }
}

Test files

You can find the test files here to use as reference for your use-case.