EventTarget
Provides a CloudWatch Event Target resource.
Example SSM Document Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const ssmLifecycleTrust = pulumi.output(aws.iam.getPolicyDocument({
statements: [{
actions: ["sts:AssumeRole"],
principals: [{
identifiers: ["events.amazonaws.com"],
type: "Service",
}],
}],
}, { async: true }));
const stopInstance = new aws.ssm.Document("stop_instance", {
content: ` {
"schemaVersion": "1.2",
"description": "Stop an instance",
"parameters": {
},
"runtimeConfig": {
"aws:runShellScript": {
"properties": [
{
"id": "0.aws:runShellScript",
"runCommand": ["halt"]
}
]
}
}
}
`,
documentType: "Command",
});
const ssmLifecyclePolicyDocument = stopInstance.arn.apply(arn => aws.iam.getPolicyDocument({
statements: [
{
actions: ["ssm:SendCommand"],
conditions: [{
test: "StringEquals",
values: ["*"],
variable: "ec2:ResourceTag/Terminate",
}],
effect: "Allow",
resources: ["arn:aws:ec2:eu-west-1:1234567890:instance/*"],
},
{
actions: ["ssm:SendCommand"],
effect: "Allow",
resources: [arn],
},
],
}, { async: true }));
const ssmLifecycleRole = new aws.iam.Role("ssm_lifecycle", {
assumeRolePolicy: ssmLifecycleTrust.json,
});
const ssmLifecyclePolicy = new aws.iam.Policy("ssm_lifecycle", {
policy: ssmLifecyclePolicyDocument.json,
});
const stopInstancesEventRule = new aws.cloudwatch.EventRule("stop_instances", {
description: "Stop instances nightly",
scheduleExpression: "cron(0 0 * * ? *)",
});
const stopInstancesEventTarget = new aws.cloudwatch.EventTarget("stop_instances", {
arn: stopInstance.arn,
roleArn: ssmLifecycleRole.arn,
rule: stopInstancesEventRule.name,
runCommandTargets: [{
key: "tag:Terminate",
values: ["midnight"],
}],
});import pulumi
import pulumi_aws as aws
ssm_lifecycle_trust = aws.iam.get_policy_document(statements=[{
"actions": ["sts:AssumeRole"],
"principals": [{
"identifiers": ["events.amazonaws.com"],
"type": "Service",
}],
}])
stop_instance = aws.ssm.Document("stopInstance",
content=""" {
"schemaVersion": "1.2",
"description": "Stop an instance",
"parameters": {
},
"runtimeConfig": {
"aws:runShellScript": {
"properties": [
{
"id": "0.aws:runShellScript",
"runCommand": ["halt"]
}
]
}
}
}
""",
document_type="Command")
ssm_lifecycle_policy_document = stop_instance.arn.apply(lambda arn: aws.iam.get_policy_document(statements=[
{
"actions": ["ssm:SendCommand"],
"conditions": [{
"test": "StringEquals",
"values": ["*"],
"variable": "ec2:ResourceTag/Terminate",
}],
"effect": "Allow",
"resources": ["arn:aws:ec2:eu-west-1:1234567890:instance/*"],
},
{
"actions": ["ssm:SendCommand"],
"effect": "Allow",
"resources": [arn],
},
]))
ssm_lifecycle_role = aws.iam.Role("ssmLifecycleRole", assume_role_policy=ssm_lifecycle_trust.json)
ssm_lifecycle_policy = aws.iam.Policy("ssmLifecyclePolicy", policy=ssm_lifecycle_policy_document.json)
stop_instances_event_rule = aws.cloudwatch.EventRule("stopInstancesEventRule",
description="Stop instances nightly",
schedule_expression="cron(0 0 * * ? *)")
stop_instances_event_target = aws.cloudwatch.EventTarget("stopInstancesEventTarget",
arn=stop_instance.arn,
role_arn=ssm_lifecycle_role.arn,
rule=stop_instances_event_rule.name,
run_command_targets=[{
"key": "tag:Terminate",
"values": ["midnight"],
}])using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var ssmLifecycleTrust = Output.Create(Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
{
Statements =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
{
Actions =
{
"sts:AssumeRole",
},
Principals =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
{
Identifiers =
{
"events.amazonaws.com",
},
Type = "Service",
},
},
},
},
}));
var stopInstance = new Aws.Ssm.Document("stopInstance", new Aws.Ssm.DocumentArgs
{
Content = @" {
""schemaVersion"": ""1.2"",
""description"": ""Stop an instance"",
""parameters"": {
},
""runtimeConfig"": {
""aws:runShellScript"": {
""properties"": [
{
""id"": ""0.aws:runShellScript"",
""runCommand"": [""halt""]
}
]
}
}
}
",
DocumentType = "Command",
});
var ssmLifecyclePolicyDocument = stopInstance.Arn.Apply(arn => Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
{
Statements =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
{
Actions =
{
"ssm:SendCommand",
},
Conditions =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionArgs
{
Test = "StringEquals",
Values =
{
"*",
},
Variable = "ec2:ResourceTag/Terminate",
},
},
Effect = "Allow",
Resources =
{
"arn:aws:ec2:eu-west-1:1234567890:instance/*",
},
},
new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
{
Actions =
{
"ssm:SendCommand",
},
Effect = "Allow",
Resources =
{
arn,
},
},
},
}));
var ssmLifecycleRole = new Aws.Iam.Role("ssmLifecycleRole", new Aws.Iam.RoleArgs
{
AssumeRolePolicy = ssmLifecycleTrust.Apply(ssmLifecycleTrust => ssmLifecycleTrust.Json),
});
var ssmLifecyclePolicy = new Aws.Iam.Policy("ssmLifecyclePolicy", new Aws.Iam.PolicyArgs
{
Policy = ssmLifecyclePolicyDocument.Apply(ssmLifecyclePolicyDocument => ssmLifecyclePolicyDocument.Json),
});
var stopInstancesEventRule = new Aws.CloudWatch.EventRule("stopInstancesEventRule", new Aws.CloudWatch.EventRuleArgs
{
Description = "Stop instances nightly",
ScheduleExpression = "cron(0 0 * * ? *)",
});
var stopInstancesEventTarget = new Aws.CloudWatch.EventTarget("stopInstancesEventTarget", new Aws.CloudWatch.EventTargetArgs
{
Arn = stopInstance.Arn,
RoleArn = ssmLifecycleRole.Arn,
Rule = stopInstancesEventRule.Name,
RunCommandTargets =
{
new Aws.CloudWatch.Inputs.EventTargetRunCommandTargetArgs
{
Key = "tag:Terminate",
Values =
{
"midnight",
},
},
},
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ssm"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ssmLifecycleTrust, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
iam.GetPolicyDocumentStatement{
Actions: []string{
"sts:AssumeRole",
},
Principals: []iam.GetPolicyDocumentStatementPrincipal{
iam.GetPolicyDocumentStatementPrincipal{
Identifiers: []string{
"events.amazonaws.com",
},
Type: "Service",
},
},
},
},
}, nil)
if err != nil {
return err
}
stopInstance, err := ssm.NewDocument(ctx, "stopInstance", &ssm.DocumentArgs{
Content: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", " {\n", " \"schemaVersion\": \"1.2\",\n", " \"description\": \"Stop an instance\",\n", " \"parameters\": {\n", "\n", " },\n", " \"runtimeConfig\": {\n", " \"aws:runShellScript\": {\n", " \"properties\": [\n", " {\n", " \"id\": \"0.aws:runShellScript\",\n", " \"runCommand\": [\"halt\"]\n", " }\n", " ]\n", " }\n", " }\n", " }\n", "\n")),
DocumentType: pulumi.String("Command"),
})
if err != nil {
return err
}
ssmLifecycleRole, err := iam.NewRole(ctx, "ssmLifecycleRole", &iam.RoleArgs{
AssumeRolePolicy: pulumi.String(ssmLifecycleTrust.Json),
})
if err != nil {
return err
}
_, err = iam.NewPolicy(ctx, "ssmLifecyclePolicy", &iam.PolicyArgs{
Policy: ssmLifecyclePolicyDocument.ApplyT(func(ssmLifecyclePolicyDocument iam.GetPolicyDocumentResult) (string, error) {
return ssmLifecyclePolicyDocument.Json, nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
stopInstancesEventRule, err := cloudwatch.NewEventRule(ctx, "stopInstancesEventRule", &cloudwatch.EventRuleArgs{
Description: pulumi.String("Stop instances nightly"),
ScheduleExpression: pulumi.String("cron(0 0 * * ? *)"),
})
if err != nil {
return err
}
_, err = cloudwatch.NewEventTarget(ctx, "stopInstancesEventTarget", &cloudwatch.EventTargetArgs{
Arn: stopInstance.Arn,
RoleArn: ssmLifecycleRole.Arn,
Rule: stopInstancesEventRule.Name,
RunCommandTargets: cloudwatch.EventTargetRunCommandTargetArray{
&cloudwatch.EventTargetRunCommandTargetArgs{
Key: pulumi.String("tag:Terminate"),
Values: pulumi.StringArray{
pulumi.String("midnight"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}Example RunCommand Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const stopInstancesEventRule = new aws.cloudwatch.EventRule("stop_instances", {
description: "Stop instances nightly",
scheduleExpression: "cron(0 0 * * ? *)",
});
const stopInstancesEventTarget = new aws.cloudwatch.EventTarget("stop_instances", {
arn: `arn:aws:ssm:${var_aws_region}::document/AWS-RunShellScript`,
input: "{\"commands\":[\"halt\"]}",
roleArn: aws_iam_role_ssm_lifecycle.arn,
rule: stopInstancesEventRule.name,
runCommandTargets: [{
key: "tag:Terminate",
values: ["midnight"],
}],
});import pulumi
import pulumi_aws as aws
stop_instances_event_rule = aws.cloudwatch.EventRule("stopInstancesEventRule",
description="Stop instances nightly",
schedule_expression="cron(0 0 * * ? *)")
stop_instances_event_target = aws.cloudwatch.EventTarget("stopInstancesEventTarget",
arn=f"arn:aws:ssm:{var['aws_region']}::document/AWS-RunShellScript",
input="{\"commands\":[\"halt\"]}",
role_arn=aws_iam_role["ssm_lifecycle"]["arn"],
rule=stop_instances_event_rule.name,
run_command_targets=[{
"key": "tag:Terminate",
"values": ["midnight"],
}])using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var stopInstancesEventRule = new Aws.CloudWatch.EventRule("stopInstancesEventRule", new Aws.CloudWatch.EventRuleArgs
{
Description = "Stop instances nightly",
ScheduleExpression = "cron(0 0 * * ? *)",
});
var stopInstancesEventTarget = new Aws.CloudWatch.EventTarget("stopInstancesEventTarget", new Aws.CloudWatch.EventTargetArgs
{
Arn = $"arn:aws:ssm:{@var.Aws_region}::document/AWS-RunShellScript",
Input = "{\"commands\":[\"halt\"]}",
RoleArn = aws_iam_role.Ssm_lifecycle.Arn,
Rule = stopInstancesEventRule.Name,
RunCommandTargets =
{
new Aws.CloudWatch.Inputs.EventTargetRunCommandTargetArgs
{
Key = "tag:Terminate",
Values =
{
"midnight",
},
},
},
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
stopInstancesEventRule, err := cloudwatch.NewEventRule(ctx, "stopInstancesEventRule", &cloudwatch.EventRuleArgs{
Description: pulumi.String("Stop instances nightly"),
ScheduleExpression: pulumi.String("cron(0 0 * * ? *)"),
})
if err != nil {
return err
}
_, err = cloudwatch.NewEventTarget(ctx, "stopInstancesEventTarget", &cloudwatch.EventTargetArgs{
Arn: pulumi.String(fmt.Sprintf("%v%v%v", "arn:aws:ssm:", _var.Aws_region, "::document/AWS-RunShellScript")),
Input: pulumi.String("{\"commands\":[\"halt\"]}"),
RoleArn: pulumi.String(aws_iam_role.Ssm_lifecycle.Arn),
Rule: stopInstancesEventRule.Name,
RunCommandTargets: cloudwatch.EventTargetRunCommandTargetArray{
&cloudwatch.EventTargetRunCommandTargetArgs{
Key: pulumi.String("tag:Terminate"),
Values: pulumi.StringArray{
pulumi.String("midnight"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}Example ECS Run Task with Role and Task Override Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const ecsEvents = new aws.iam.Role("ecs_events", {
assumeRolePolicy: `{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
`,
});
const ecsEventsRunTaskWithAnyRole = new aws.iam.RolePolicy("ecs_events_run_task_with_any_role", {
policy: aws_ecs_task_definition_task_name.arn.apply(arn => `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ecs:RunTask",
"Resource": "${arn.replace(/:\d+$/, ":*")}"
}
]
}
`),
role: ecsEvents.id,
});
const ecsScheduledTask = new aws.cloudwatch.EventTarget("ecs_scheduled_task", {
arn: aws_ecs_cluster_cluster_name.arn,
ecsTarget: {
taskCount: 1,
taskDefinitionArn: aws_ecs_task_definition_task_name.arn,
},
input: `{
"containerOverrides": [
{
"name": "name-of-container-to-override",
"command": ["bin/console", "scheduled-task"]
}
]
}
`,
roleArn: ecsEvents.arn,
rule: aws_cloudwatch_event_rule_every_hour.name,
});Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var console = new Aws.CloudWatch.EventRule("console", new Aws.CloudWatch.EventRuleArgs
{
Description = "Capture all EC2 scaling events",
EventPattern = @"{
""source"": [
""aws.autoscaling""
],
""detail-type"": [
""EC2 Instance Launch Successful"",
""EC2 Instance Terminate Successful"",
""EC2 Instance Launch Unsuccessful"",
""EC2 Instance Terminate Unsuccessful""
]
}
",
});
var testStream = new Aws.Kinesis.Stream("testStream", new Aws.Kinesis.StreamArgs
{
ShardCount = 1,
});
var yada = new Aws.CloudWatch.EventTarget("yada", new Aws.CloudWatch.EventTargetArgs
{
Arn = testStream.Arn,
Rule = console.Name,
RunCommandTargets =
{
new Aws.CloudWatch.Inputs.EventTargetRunCommandTargetArgs
{
Key = "tag:Name",
Values =
{
"FooBar",
},
},
new Aws.CloudWatch.Inputs.EventTargetRunCommandTargetArgs
{
Key = "InstanceIds",
Values =
{
"i-162058cd308bffec2",
},
},
},
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/kinesis"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
console, err := cloudwatch.NewEventRule(ctx, "console", &cloudwatch.EventRuleArgs{
Description: pulumi.String("Capture all EC2 scaling events"),
EventPattern: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v", "{\n", " \"source\": [\n", " \"aws.autoscaling\"\n", " ],\n", " \"detail-type\": [\n", " \"EC2 Instance Launch Successful\",\n", " \"EC2 Instance Terminate Successful\",\n", " \"EC2 Instance Launch Unsuccessful\",\n", " \"EC2 Instance Terminate Unsuccessful\"\n", " ]\n", "}\n", "\n")),
})
if err != nil {
return err
}
testStream, err := kinesis.NewStream(ctx, "testStream", &kinesis.StreamArgs{
ShardCount: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = cloudwatch.NewEventTarget(ctx, "yada", &cloudwatch.EventTargetArgs{
Arn: testStream.Arn,
Rule: console.Name,
RunCommandTargets: cloudwatch.EventTargetRunCommandTargetArray{
&cloudwatch.EventTargetRunCommandTargetArgs{
Key: pulumi.String("tag:Name"),
Values: pulumi.StringArray{
pulumi.String("FooBar"),
},
},
&cloudwatch.EventTargetRunCommandTargetArgs{
Key: pulumi.String("InstanceIds"),
Values: pulumi.StringArray{
pulumi.String("i-162058cd308bffec2"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
console = aws.cloudwatch.EventRule("console",
description="Capture all EC2 scaling events",
event_pattern="""{
"source": [
"aws.autoscaling"
],
"detail-type": [
"EC2 Instance Launch Successful",
"EC2 Instance Terminate Successful",
"EC2 Instance Launch Unsuccessful",
"EC2 Instance Terminate Unsuccessful"
]
}
""")
test_stream = aws.kinesis.Stream("testStream", shard_count=1)
yada = aws.cloudwatch.EventTarget("yada",
arn=test_stream.arn,
rule=console.name,
run_command_targets=[
{
"key": "tag:Name",
"values": ["FooBar"],
},
{
"key": "InstanceIds",
"values": ["i-162058cd308bffec2"],
},
])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const console = new aws.cloudwatch.EventRule("console", {
description: "Capture all EC2 scaling events",
eventPattern: `{
"source": [
"aws.autoscaling"
],
"detail-type": [
"EC2 Instance Launch Successful",
"EC2 Instance Terminate Successful",
"EC2 Instance Launch Unsuccessful",
"EC2 Instance Terminate Unsuccessful"
]
}
`,
});
const testStream = new aws.kinesis.Stream("test_stream", {
shardCount: 1,
});
const yada = new aws.cloudwatch.EventTarget("yada", {
arn: testStream.arn,
rule: console.name,
runCommandTargets: [
{
key: "tag:Name",
values: ["FooBar"],
},
{
key: "InstanceIds",
values: ["i-162058cd308bffec2"],
},
],
});Create a EventTarget Resource
new EventTarget(name: string, args: EventTargetArgs, opts?: CustomResourceOptions);def EventTarget(resource_name, opts=None, arn=None, batch_target=None, ecs_target=None, input=None, input_path=None, input_transformer=None, kinesis_target=None, role_arn=None, rule=None, run_command_targets=None, sqs_target=None, target_id=None, __props__=None);func NewEventTarget(ctx *Context, name string, args EventTargetArgs, opts ...ResourceOption) (*EventTarget, error)public EventTarget(string name, EventTargetArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args EventTargetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args EventTargetArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args EventTargetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
EventTarget Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The EventTarget resource accepts the following input properties:
- Arn string
The Amazon Resource Name (ARN) associated of the target.
- Rule string
The name of the rule you want to add targets to.
- Batch
Target EventTarget Batch Target Args Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- Ecs
Target EventTarget Ecs Target Args Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- Input string
Valid JSON text passed to the target.
- Input
Path string The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- Input
Transformer EventTarget Input Transformer Args Parameters used when you are providing a custom input to a target based on certain event data.
- Kinesis
Target EventTarget Kinesis Target Args Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- Role
Arn string The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- Run
Command List<EventTargets Target Run Command Target Args> Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- Sqs
Target EventTarget Sqs Target Args Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- Target
Id string The unique target assignment ID. If missing, will generate a random, unique id.
- Arn string
The Amazon Resource Name (ARN) associated of the target.
- Rule string
The name of the rule you want to add targets to.
- Batch
Target EventTarget Batch Target Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- Ecs
Target EventTarget Ecs Target Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- Input string
Valid JSON text passed to the target.
- Input
Path string The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- Input
Transformer EventTarget Input Transformer Parameters used when you are providing a custom input to a target based on certain event data.
- Kinesis
Target EventTarget Kinesis Target Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- Role
Arn string The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- Run
Command []EventTargets Target Run Command Target Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- Sqs
Target EventTarget Sqs Target Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- Target
Id string The unique target assignment ID. If missing, will generate a random, unique id.
- arn string
The Amazon Resource Name (ARN) associated of the target.
- rule string
The name of the rule you want to add targets to.
- batch
Target EventTarget Batch Target Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- ecs
Target EventTarget Ecs Target Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- input string
Valid JSON text passed to the target.
- input
Path string The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- input
Transformer EventTarget Input Transformer Parameters used when you are providing a custom input to a target based on certain event data.
- kinesis
Target EventTarget Kinesis Target Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- role
Arn string The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- run
Command EventTargets Target Run Command Target[] Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- sqs
Target EventTarget Sqs Target Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- target
Id string The unique target assignment ID. If missing, will generate a random, unique id.
- arn str
The Amazon Resource Name (ARN) associated of the target.
- rule str
The name of the rule you want to add targets to.
- batch_
target Dict[EventTarget Batch Target] Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- ecs_
target Dict[EventTarget Ecs Target] Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- input str
Valid JSON text passed to the target.
- input_
path str The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- input_
transformer Dict[EventTarget Input Transformer] Parameters used when you are providing a custom input to a target based on certain event data.
- kinesis_
target Dict[EventTarget Kinesis Target] Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- role_
arn str The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- run_
command_ List[Eventtargets Target Run Command Target] Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- sqs_
target Dict[EventTarget Sqs Target] Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- target_
id str The unique target assignment ID. If missing, will generate a random, unique id.
Outputs
All input properties are implicitly available as output properties. Additionally, the EventTarget resource produces the following output properties:
Look up an Existing EventTarget Resource
Get an existing EventTarget resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: EventTargetState, opts?: CustomResourceOptions): EventTargetstatic get(resource_name, id, opts=None, arn=None, batch_target=None, ecs_target=None, input=None, input_path=None, input_transformer=None, kinesis_target=None, role_arn=None, rule=None, run_command_targets=None, sqs_target=None, target_id=None, __props__=None);func GetEventTarget(ctx *Context, name string, id IDInput, state *EventTargetState, opts ...ResourceOption) (*EventTarget, error)public static EventTarget Get(string name, Input<string> id, EventTargetState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Arn string
The Amazon Resource Name (ARN) associated of the target.
- Batch
Target EventTarget Batch Target Args Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- Ecs
Target EventTarget Ecs Target Args Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- Input string
Valid JSON text passed to the target.
- Input
Path string The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- Input
Transformer EventTarget Input Transformer Args Parameters used when you are providing a custom input to a target based on certain event data.
- Kinesis
Target EventTarget Kinesis Target Args Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- Role
Arn string The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- Rule string
The name of the rule you want to add targets to.
- Run
Command List<EventTargets Target Run Command Target Args> Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- Sqs
Target EventTarget Sqs Target Args Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- Target
Id string The unique target assignment ID. If missing, will generate a random, unique id.
- Arn string
The Amazon Resource Name (ARN) associated of the target.
- Batch
Target EventTarget Batch Target Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- Ecs
Target EventTarget Ecs Target Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- Input string
Valid JSON text passed to the target.
- Input
Path string The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- Input
Transformer EventTarget Input Transformer Parameters used when you are providing a custom input to a target based on certain event data.
- Kinesis
Target EventTarget Kinesis Target Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- Role
Arn string The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- Rule string
The name of the rule you want to add targets to.
- Run
Command []EventTargets Target Run Command Target Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- Sqs
Target EventTarget Sqs Target Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- Target
Id string The unique target assignment ID. If missing, will generate a random, unique id.
- arn string
The Amazon Resource Name (ARN) associated of the target.
- batch
Target EventTarget Batch Target Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- ecs
Target EventTarget Ecs Target Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- input string
Valid JSON text passed to the target.
- input
Path string The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- input
Transformer EventTarget Input Transformer Parameters used when you are providing a custom input to a target based on certain event data.
- kinesis
Target EventTarget Kinesis Target Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- role
Arn string The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- rule string
The name of the rule you want to add targets to.
- run
Command EventTargets Target Run Command Target[] Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- sqs
Target EventTarget Sqs Target Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- target
Id string The unique target assignment ID. If missing, will generate a random, unique id.
- arn str
The Amazon Resource Name (ARN) associated of the target.
- batch_
target Dict[EventTarget Batch Target] Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
- ecs_
target Dict[EventTarget Ecs Target] Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
- input str
Valid JSON text passed to the target.
- input_
path str The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.
- input_
transformer Dict[EventTarget Input Transformer] Parameters used when you are providing a custom input to a target based on certain event data.
- kinesis_
target Dict[EventTarget Kinesis Target] Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.
- role_
arn str The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if
ecs_targetis used.- rule str
The name of the rule you want to add targets to.
- run_
command_ List[Eventtargets Target Run Command Target] Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
- sqs_
target Dict[EventTarget Sqs Target] Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
- target_
id str The unique target assignment ID. If missing, will generate a random, unique id.
Supporting Types
EventTargetBatchTarget
- Job
Definition string The ARN or name of the job definition to use if the event target is an AWS Batch job. This job definition must already exist.
- Job
Name string The name to use for this execution of the job, if the target is an AWS Batch job.
- Array
Size int The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.
- Job
Attempts int The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.
- Job
Definition string The ARN or name of the job definition to use if the event target is an AWS Batch job. This job definition must already exist.
- Job
Name string The name to use for this execution of the job, if the target is an AWS Batch job.
- Array
Size int The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.
- Job
Attempts int The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.
- job
Definition string The ARN or name of the job definition to use if the event target is an AWS Batch job. This job definition must already exist.
- job
Name string The name to use for this execution of the job, if the target is an AWS Batch job.
- array
Size number The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.
- job
Attempts number The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.
- job
Definition str The ARN or name of the job definition to use if the event target is an AWS Batch job. This job definition must already exist.
- job
Name str The name to use for this execution of the job, if the target is an AWS Batch job.
- array
Size float The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.
- job
Attempts float The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.
EventTargetEcsTarget
- Task
Definition stringArn The ARN of the task definition to use if the event target is an Amazon ECS cluster.
- Group string
Specifies an ECS task group for the task. The maximum length is 255 characters.
- Launch
Type string Specifies the launch type on which your task is running. The launch type that you specify here must match one of the launch type (compatibilities) of the target task. Valid values are EC2 or FARGATE.
- Network
Configuration EventTarget Ecs Target Network Configuration Args Use this if the ECS task uses the awsvpc network mode. This specifies the VPC subnets and security groups associated with the task, and whether a public IP address is to be used. Required if launch_type is FARGATE because the awsvpc mode is required for Fargate tasks.
- Platform
Version string Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. This is used only if LaunchType is FARGATE. For more information about valid platform versions, see AWS Fargate Platform Versions.
- Task
Count int The number of tasks to create based on the TaskDefinition. The default is 1.
- Task
Definition stringArn The ARN of the task definition to use if the event target is an Amazon ECS cluster.
- Group string
Specifies an ECS task group for the task. The maximum length is 255 characters.
- Launch
Type string Specifies the launch type on which your task is running. The launch type that you specify here must match one of the launch type (compatibilities) of the target task. Valid values are EC2 or FARGATE.
- Network
Configuration EventTarget Ecs Target Network Configuration Use this if the ECS task uses the awsvpc network mode. This specifies the VPC subnets and security groups associated with the task, and whether a public IP address is to be used. Required if launch_type is FARGATE because the awsvpc mode is required for Fargate tasks.
- Platform
Version string Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. This is used only if LaunchType is FARGATE. For more information about valid platform versions, see AWS Fargate Platform Versions.
- Task
Count int The number of tasks to create based on the TaskDefinition. The default is 1.
- task
Definition stringArn The ARN of the task definition to use if the event target is an Amazon ECS cluster.
- group string
Specifies an ECS task group for the task. The maximum length is 255 characters.
- launch
Type string Specifies the launch type on which your task is running. The launch type that you specify here must match one of the launch type (compatibilities) of the target task. Valid values are EC2 or FARGATE.
- network
Configuration EventTarget Ecs Target Network Configuration Use this if the ECS task uses the awsvpc network mode. This specifies the VPC subnets and security groups associated with the task, and whether a public IP address is to be used. Required if launch_type is FARGATE because the awsvpc mode is required for Fargate tasks.
- platform
Version string Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. This is used only if LaunchType is FARGATE. For more information about valid platform versions, see AWS Fargate Platform Versions.
- task
Count number The number of tasks to create based on the TaskDefinition. The default is 1.
- task
Definition strArn The ARN of the task definition to use if the event target is an Amazon ECS cluster.
- group str
Specifies an ECS task group for the task. The maximum length is 255 characters.
- launch_
type str Specifies the launch type on which your task is running. The launch type that you specify here must match one of the launch type (compatibilities) of the target task. Valid values are EC2 or FARGATE.
- network_
configuration Dict[EventTarget Ecs Target Network Configuration] Use this if the ECS task uses the awsvpc network mode. This specifies the VPC subnets and security groups associated with the task, and whether a public IP address is to be used. Required if launch_type is FARGATE because the awsvpc mode is required for Fargate tasks.
- platform_
version str Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. This is used only if LaunchType is FARGATE. For more information about valid platform versions, see AWS Fargate Platform Versions.
- task
Count float The number of tasks to create based on the TaskDefinition. The default is 1.
EventTargetEcsTargetNetworkConfiguration
- Subnets List<string>
The subnets associated with the task or service.
- Assign
Public boolIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- Security
Groups List<string> The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
- Subnets []string
The subnets associated with the task or service.
- Assign
Public boolIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- Security
Groups []string The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
- subnets string[]
The subnets associated with the task or service.
- assign
Public booleanIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- security
Groups string[] The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
- subnets List[str]
The subnets associated with the task or service.
- assign
Public boolIp Assign a public IP address to the ENI (Fargate launch type only). Valid values are
trueorfalse. Defaultfalse.- security_
groups List[str] The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
EventTargetInputTransformer
- Input
Template string Structure containing the template body.
- Input
Paths Dictionary<string, string> Key value pairs specified in the form of JSONPath (for example, time = $.time)
- Input
Template string Structure containing the template body.
- Input
Paths map[string]string Key value pairs specified in the form of JSONPath (for example, time = $.time)
- input
Template string Structure containing the template body.
- input
Paths {[key: string]: string} Key value pairs specified in the form of JSONPath (for example, time = $.time)
- input
Template str Structure containing the template body.
- input
Paths Dict[str, str] Key value pairs specified in the form of JSONPath (for example, time = $.time)
EventTargetKinesisTarget
- Partition
Key stringPath The JSON path to be extracted from the event and used as the partition key.
- Partition
Key stringPath The JSON path to be extracted from the event and used as the partition key.
- partition
Key stringPath The JSON path to be extracted from the event and used as the partition key.
- partition
Key strPath The JSON path to be extracted from the event and used as the partition key.
EventTargetRunCommandTarget
- Key string
Can be either
tag:tag-keyorInstanceIds.- Values List<string>
If Key is
tag:tag-key, Values is a list of tag values. If Key isInstanceIds, Values is a list of Amazon EC2 instance IDs.
EventTargetSqsTarget
- Message
Group stringId The FIFO message group ID to use as the target.
- Message
Group stringId The FIFO message group ID to use as the target.
- message
Group stringId The FIFO message group ID to use as the target.
- message
Group strId The FIFO message group ID to use as the target.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.