Skip to content

Commit

Permalink
Merge pull request #21906 from ashwgupt/update-cw-eb-target-docs
Browse files Browse the repository at this point in the history
fix: Update the docs for CloudWatch Event Rule Target to mention use …
  • Loading branch information
anGie44 authored Dec 17, 2021
2 parents 5cb5bf6 + 7d35bde commit 149048f
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion website/docs/r/cloudwatch_event_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,59 @@ resource "aws_api_gateway_stage" "example" {
}
```

## Example Cross-Account Event Bus target

```terraform
data "aws_iam_role" "event_bus_invoke_remote_event_bus" {
name = "event-bus-invoke-remote-event-bus"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "events.amazonaws.com"
},
"Effect": "Allow"
}
]
}
EOF
}
data "aws_iam_policy_document" "event_bus_invoke_remote_event_bus" {
statement {
effect = "Allow"
actions = ["events.PutEvents"]
resources = ["arn:aws:events:eu-west-1:1234567890:event-bus/My-Event-Bus"]
}
}
resource "aws_iam_policy" "event_bus_invoke_remote_event_bus" {
name = "event_bus_invoke_remote_event_bus"
policy = data.aws_iam_policy_document.event_bus_invoke_remote_event_bus.json
}
resource "aws_iam_role_policy_attachment" "event_bus_invoke_remote_event_bus" {
role = aws_iam_role.event_bus_invoke_remote_event_bus.name
policy_arn = aws_iam_policy.event_bus_invoke_remote_event_bus.arn
}
resource "aws_cloudwatch_event_rule" "stop_instances" {
name = "StopInstance"
description = "Stop instances nightly"
schedule_expression = "cron(0 0 * * ? *)"
}
resource "aws_cloudwatch_event_target" "stop_instances" {
target_id = "StopInstance"
arn = "arn:aws:events:eu-west-1:1234567890:event-bus/My-Event-Bus"
rule = aws_cloudwatch_event_rule.stop_instances.name
role_arn = aws_iam_role.event_bus_invoke_remote_event_bus.arn
}
```

## Example Input Transformer Usage - JSON Object

```terraform
Expand Down Expand Up @@ -338,7 +391,7 @@ The following arguments are supported:
* `arn` - (Required) The Amazon Resource Name (ARN) of the target.
* `input` - (Optional) Valid JSON text passed to the target. Conflicts with `input_path` and `input_transformer`.
* `input_path` - (Optional) The value of the [JSONPath](http://goessner.net/articles/JsonPath/) that is used for extracting part of the matched event when passing it to the target. Conflicts with `input` and `input_transformer`.
* `role_arn` - (Optional) 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 or target in `arn` is EC2 instance, Kinesis data stream or Step Functions state machine.
* `role_arn` - (Optional) 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 or target in `arn` is EC2 instance, Kinesis data stream, Step Functions state machine, or Event Bus in different account or region.
* `run_command_targets` - (Optional) Parameters used when you are using the rule to invoke Amazon EC2 Run Command. Documented below. A maximum of 5 are allowed.
* `ecs_target` - (Optional) Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed.
* `batch_target` - (Optional) Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed.
Expand Down

0 comments on commit 149048f

Please sign in to comment.