EventRuleArgs

data class EventRuleArgs(val description: Output<String>? = null, val eventBusName: Output<String>? = null, val eventPattern: Output<String>? = null, val isEnabled: Output<Boolean>? = null, val name: Output<String>? = null, val namePrefix: Output<String>? = null, val roleArn: Output<String>? = null, val scheduleExpression: Output<String>? = null, val tags: Output<Map<String, String>>? = null) : ConvertibleToJava<EventRuleArgs>

Provides an EventBridge Rule resource.

Note: EventBridge was formerly known as CloudWatch Events. The functionality is identical.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.EventRule;
import com.pulumi.aws.cloudwatch.EventRuleArgs;
import com.pulumi.aws.sns.Topic;
import com.pulumi.aws.cloudwatch.EventTarget;
import com.pulumi.aws.cloudwatch.EventTargetArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.sns.TopicPolicy;
import com.pulumi.aws.sns.TopicPolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var console = new EventRule("console", EventRuleArgs.builder()
.description("Capture each AWS Console Sign In")
.eventPattern(serializeJson(
jsonObject(
jsonProperty("detail-type", jsonArray("AWS Console Sign In via CloudTrail"))
)))
.build());
var awsLogins = new Topic("awsLogins");
var sns = new EventTarget("sns", EventTargetArgs.builder()
.rule(console.name())
.arn(awsLogins.arn())
.build());
final var snsTopicPolicy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.actions("SNS:Publish")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("events.amazonaws.com")
.build())
.resources(awsLogins.arn())
.build())
.build());
var default_ = new TopicPolicy("default", TopicPolicyArgs.builder()
.arn(awsLogins.arn())
.policy(snsTopicPolicy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(snsTopicPolicy -> snsTopicPolicy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
}
}

Import

EventBridge Rules can be imported using the event_bus_name/rule_name (if you omit event_bus_name, the default event bus will be used), e.g.,

$ pulumi import aws:cloudwatch/eventRule:EventRule console example-event-bus/capture-console-sign-in

Constructors

Link copied to clipboard
constructor(description: Output<String>? = null, eventBusName: Output<String>? = null, eventPattern: Output<String>? = null, isEnabled: Output<Boolean>? = null, name: Output<String>? = null, namePrefix: Output<String>? = null, roleArn: Output<String>? = null, scheduleExpression: Output<String>? = null, tags: Output<Map<String, String>>? = null)

Properties

Link copied to clipboard
val description: Output<String>? = null

The description of the rule.

Link copied to clipboard
val eventBusName: Output<String>? = null

The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.

Link copied to clipboard
val eventPattern: Output<String>? = null

The event pattern described a JSON object. At least one of schedule_expression or event_pattern is required. See full documentation of Events and Event Patterns in EventBridge for details.

Link copied to clipboard
val isEnabled: Output<Boolean>? = null

Whether the rule should be enabled (defaults to true).

Link copied to clipboard
val name: Output<String>? = null

The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.

Link copied to clipboard
val namePrefix: Output<String>? = null

Creates a unique name beginning with the specified prefix. Conflicts with name.

Link copied to clipboard
val roleArn: Output<String>? = null

The Amazon Resource Name (ARN) associated with the role that is used for target invocation.

Link copied to clipboard
val scheduleExpression: Output<String>? = null

The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of schedule_expression or event_pattern is required. Can only be used on the default event bus. For more information, refer to the AWS documentation Schedule Expressions for Rules.

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

A map of tags to assign to the resource. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Functions

Link copied to clipboard
open override fun toJava(): EventRuleArgs