Class ScheduledEc2TaskProps
The properties for the ScheduledEc2Task task.
Inheritance
Namespace: Amazon.CDK.AWS.ECS.Patterns
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ScheduledEc2TaskProps : Object, IScheduledEc2TaskProps, IScheduledTaskBaseProps
Syntax (vb)
Public Class ScheduledEc2TaskProps
Inherits Object
Implements IScheduledEc2TaskProps, IScheduledTaskBaseProps
Remarks
ExampleMetadata: infused
Examples
// Instantiate an Amazon EC2 Task to run at a scheduled interval
Cluster cluster;
var ecsScheduledTask = new ScheduledEc2Task(this, "ScheduledTask", new ScheduledEc2TaskProps {
Cluster = cluster,
ScheduledEc2TaskImageOptions = new ScheduledEc2TaskImageOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryLimitMiB = 256,
Environment = new Dictionary<string, string> { { "name", "TRIGGER" }, { "value", "CloudWatch Events" } }
},
Schedule = Schedule.Expression("rate(1 minute)"),
Enabled = true,
RuleName = "sample-scheduled-task-rule"
});
Synopsis
Constructors
ScheduledEc2TaskProps() |
Properties
Cluster | The name of the cluster that hosts the service. |
DesiredTaskCount | The desired number of instantiations of the task definition to keep running on the service. |
Enabled | Indicates whether the rule is enabled. |
PropagateTags | Specifies whether to propagate the tags from the task definition to the task. |
RuleName | A name for the rule. |
Schedule | The schedule or rate (frequency) that determines when CloudWatch Events runs the rule. |
ScheduledEc2TaskDefinitionOptions | The properties to define if using an existing TaskDefinition in this construct. |
ScheduledEc2TaskImageOptions | The properties to define if the construct is to create a TaskDefinition. |
SecurityGroups | Existing security groups to use for your service. |
SubnetSelection | In what subnets to place the task's ENIs. |
Tags | The metadata that you apply to the task to help you categorize and organize them. |
Vpc | The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. |
Constructors
ScheduledEc2TaskProps()
public ScheduledEc2TaskProps()
Properties
Cluster
The name of the cluster that hosts the service.
public ICluster Cluster { get; set; }
Property Value
Remarks
If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc.
Default: - create a new cluster; if both cluster and vpc are omitted, a new VPC will be created for you.
DesiredTaskCount
The desired number of instantiations of the task definition to keep running on the service.
public Nullable<double> DesiredTaskCount { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
Default: 1
Enabled
Indicates whether the rule is enabled.
public Nullable<bool> Enabled { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
PropagateTags
Specifies whether to propagate the tags from the task definition to the task.
public Nullable<PropagatedTagSource> PropagateTags { get; set; }
Property Value
System.Nullable<PropagatedTagSource>
Remarks
If no value is specified, the tags are not propagated.
Default: - Tags will not be propagated
RuleName
A name for the rule.
public string RuleName { get; set; }
Property Value
System.String
Remarks
Default: - AWS CloudFormation generates a unique physical ID and uses that ID for the rule name. For more information, see Name Type.
Schedule
The schedule or rate (frequency) that determines when CloudWatch Events runs the rule.
public Schedule Schedule { get; set; }
Property Value
Remarks
For more information, see Schedule Expression Syntax for Rules in the Amazon CloudWatch User Guide.
ScheduledEc2TaskDefinitionOptions
The properties to define if using an existing TaskDefinition in this construct.
public IScheduledEc2TaskDefinitionOptions ScheduledEc2TaskDefinitionOptions { get; set; }
Property Value
IScheduledEc2TaskDefinitionOptions
Remarks
ScheduledEc2TaskDefinitionOptions or ScheduledEc2TaskImageOptions must be defined, but not both.
Default: none
ScheduledEc2TaskImageOptions
The properties to define if the construct is to create a TaskDefinition.
public IScheduledEc2TaskImageOptions ScheduledEc2TaskImageOptions { get; set; }
Property Value
Remarks
ScheduledEc2TaskDefinitionOptions or ScheduledEc2TaskImageOptions must be defined, but not both.
Default: none
SecurityGroups
Existing security groups to use for your service.
public ISecurityGroup[] SecurityGroups { get; set; }
Property Value
Remarks
Default: - a new security group will be created.
SubnetSelection
In what subnets to place the task's ENIs.
public ISubnetSelection SubnetSelection { get; set; }
Property Value
Remarks
(Only applicable in case the TaskDefinition is configured for AwsVpc networking)
Default: Private subnets
Tags
The metadata that you apply to the task to help you categorize and organize them.
public ITag[] Tags { get; set; }
Property Value
ITag[]
Remarks
Each tag consists of a key and an optional value, both of which you define.
Default: - No tags are applied to the task
Vpc
The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed.
public IVpc Vpc { get; set; }
Property Value
Remarks
If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster.
Default: - uses the VPC defined in the cluster or creates a new VPC.