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

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.

BatchTarget EventTargetBatchTargetArgs

Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.

EcsTarget EventTargetEcsTargetArgs

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.

InputPath string

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.

InputTransformer EventTargetInputTransformerArgs

Parameters used when you are providing a custom input to a target based on certain event data.

KinesisTarget EventTargetKinesisTargetArgs

Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.

RoleArn string

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if ecs_target is used.

RunCommandTargets List<EventTargetRunCommandTargetArgs>

Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.

SqsTarget EventTargetSqsTargetArgs

Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.

TargetId 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.

BatchTarget EventTargetBatchTarget

Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.

EcsTarget EventTargetEcsTarget

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.

InputPath string

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.

InputTransformer EventTargetInputTransformer

Parameters used when you are providing a custom input to a target based on certain event data.

KinesisTarget EventTargetKinesisTarget

Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.

RoleArn string

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if ecs_target is used.

RunCommandTargets []EventTargetRunCommandTarget

Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.

SqsTarget EventTargetSqsTarget

Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.

TargetId 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.

batchTarget EventTargetBatchTarget

Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.

ecsTarget EventTargetEcsTarget

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.

inputPath string

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.

inputTransformer EventTargetInputTransformer

Parameters used when you are providing a custom input to a target based on certain event data.

kinesisTarget EventTargetKinesisTarget

Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.

roleArn string

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if ecs_target is used.

runCommandTargets EventTargetRunCommandTarget[]

Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.

sqsTarget EventTargetSqsTarget

Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.

targetId 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[EventTargetBatchTarget]

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[EventTargetEcsTarget]

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[EventTargetInputTransformer]

Parameters used when you are providing a custom input to a target based on certain event data.

kinesis_target Dict[EventTargetKinesisTarget]

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_target is used.

run_command_targets List[EventTargetRunCommandTarget]

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[EventTargetSqsTarget]

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:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

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): EventTarget
static 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.

BatchTarget EventTargetBatchTargetArgs

Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.

EcsTarget EventTargetEcsTargetArgs

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.

InputPath string

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.

InputTransformer EventTargetInputTransformerArgs

Parameters used when you are providing a custom input to a target based on certain event data.

KinesisTarget EventTargetKinesisTargetArgs

Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.

RoleArn string

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if ecs_target is used.

Rule string

The name of the rule you want to add targets to.

RunCommandTargets List<EventTargetRunCommandTargetArgs>

Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.

SqsTarget EventTargetSqsTargetArgs

Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.

TargetId 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.

BatchTarget EventTargetBatchTarget

Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.

EcsTarget EventTargetEcsTarget

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.

InputPath string

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.

InputTransformer EventTargetInputTransformer

Parameters used when you are providing a custom input to a target based on certain event data.

KinesisTarget EventTargetKinesisTarget

Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.

RoleArn string

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if ecs_target is used.

Rule string

The name of the rule you want to add targets to.

RunCommandTargets []EventTargetRunCommandTarget

Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.

SqsTarget EventTargetSqsTarget

Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.

TargetId 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.

batchTarget EventTargetBatchTarget

Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.

ecsTarget EventTargetEcsTarget

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.

inputPath string

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target.

inputTransformer EventTargetInputTransformer

Parameters used when you are providing a custom input to a target based on certain event data.

kinesisTarget EventTargetKinesisTarget

Parameters used when you are using the rule to invoke an Amazon Kinesis Stream. Documented below. A maximum of 1 are allowed.

roleArn string

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. Required if ecs_target is used.

rule string

The name of the rule you want to add targets to.

runCommandTargets EventTargetRunCommandTarget[]

Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.

sqsTarget EventTargetSqsTarget

Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.

targetId 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[EventTargetBatchTarget]

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[EventTargetEcsTarget]

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[EventTargetInputTransformer]

Parameters used when you are providing a custom input to a target based on certain event data.

kinesis_target Dict[EventTargetKinesisTarget]

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_target is used.

rule str

The name of the rule you want to add targets to.

run_command_targets List[EventTargetRunCommandTarget]

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[EventTargetSqsTarget]

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

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

JobDefinition 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.

JobName string

The name to use for this execution of the job, if the target is an AWS Batch job.

ArraySize int

The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.

JobAttempts int

The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.

JobDefinition 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.

JobName string

The name to use for this execution of the job, if the target is an AWS Batch job.

ArraySize int

The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.

JobAttempts int

The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.

jobDefinition 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.

jobName string

The name to use for this execution of the job, if the target is an AWS Batch job.

arraySize number

The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.

jobAttempts number

The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.

jobDefinition 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.

jobName str

The name to use for this execution of the job, if the target is an AWS Batch job.

arraySize float

The size of the array, if this is an array batch job. Valid values are integers between 2 and 10,000.

jobAttempts float

The number of times to attempt to retry, if the job fails. Valid values are 1 to 10.

EventTargetEcsTarget

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

TaskDefinitionArn string

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.

LaunchType 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.

NetworkConfiguration EventTargetEcsTargetNetworkConfigurationArgs

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.

PlatformVersion 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.

TaskCount int

The number of tasks to create based on the TaskDefinition. The default is 1.

TaskDefinitionArn string

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.

LaunchType 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.

NetworkConfiguration EventTargetEcsTargetNetworkConfiguration

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.

PlatformVersion 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.

TaskCount int

The number of tasks to create based on the TaskDefinition. The default is 1.

taskDefinitionArn string

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.

launchType 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.

networkConfiguration EventTargetEcsTargetNetworkConfiguration

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.

platformVersion 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.

taskCount number

The number of tasks to create based on the TaskDefinition. The default is 1.

taskDefinitionArn str

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[EventTargetEcsTargetNetworkConfiguration]

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.

taskCount float

The number of tasks to create based on the TaskDefinition. The default is 1.

EventTargetEcsTargetNetworkConfiguration

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Subnets List<string>

The subnets associated with the task or service.

AssignPublicIp bool

Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false.

SecurityGroups 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.

AssignPublicIp bool

Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false.

SecurityGroups []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.

assignPublicIp boolean

Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false.

securityGroups 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.

assignPublicIp bool

Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false.

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

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

InputTemplate string

Structure containing the template body.

InputPaths Dictionary<string, string>

Key value pairs specified in the form of JSONPath (for example, time = $.time)

InputTemplate string

Structure containing the template body.

InputPaths map[string]string

Key value pairs specified in the form of JSONPath (for example, time = $.time)

inputTemplate string

Structure containing the template body.

inputPaths {[key: string]: string}

Key value pairs specified in the form of JSONPath (for example, time = $.time)

inputTemplate str

Structure containing the template body.

inputPaths Dict[str, str]

Key value pairs specified in the form of JSONPath (for example, time = $.time)

EventTargetKinesisTarget

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

PartitionKeyPath string

The JSON path to be extracted from the event and used as the partition key.

PartitionKeyPath string

The JSON path to be extracted from the event and used as the partition key.

partitionKeyPath string

The JSON path to be extracted from the event and used as the partition key.

partitionKeyPath str

The JSON path to be extracted from the event and used as the partition key.

EventTargetRunCommandTarget

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Key string

Can be either tag:tag-key or InstanceIds.

Values List<string>

If Key is tag:tag-key, Values is a list of tag values. If Key is InstanceIds, Values is a list of Amazon EC2 instance IDs.

Key string

Can be either tag:tag-key or InstanceIds.

Values []string

If Key is tag:tag-key, Values is a list of tag values. If Key is InstanceIds, Values is a list of Amazon EC2 instance IDs.

key string

Can be either tag:tag-key or InstanceIds.

values string[]

If Key is tag:tag-key, Values is a list of tag values. If Key is InstanceIds, Values is a list of Amazon EC2 instance IDs.

key str

Can be either tag:tag-key or InstanceIds.

values List[str]

If Key is tag:tag-key, Values is a list of tag values. If Key is InstanceIds, Values is a list of Amazon EC2 instance IDs.

EventTargetSqsTarget

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

MessageGroupId string

The FIFO message group ID to use as the target.

MessageGroupId string

The FIFO message group ID to use as the target.

messageGroupId string

The FIFO message group ID to use as the target.

messageGroupId str

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 aws Terraform Provider.