1. Packages
  2. AWS Classic
  3. API Docs
  4. cloudwatch
  5. EventRule

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi

aws.cloudwatch.EventRule

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi

    Provides an EventBridge Rule resource.

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

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const console = new aws.cloudwatch.EventRule("console", {
        name: "capture-aws-sign-in",
        description: "Capture each AWS Console Sign In",
        eventPattern: JSON.stringify({
            "detail-type": ["AWS Console Sign In via CloudTrail"],
        }),
    });
    const awsLogins = new aws.sns.Topic("aws_logins", {name: "aws-console-logins"});
    const sns = new aws.cloudwatch.EventTarget("sns", {
        rule: console.name,
        targetId: "SendToSNS",
        arn: awsLogins.arn,
    });
    const snsTopicPolicy = awsLogins.arn.apply(arn => aws.iam.getPolicyDocumentOutput({
        statements: [{
            effect: "Allow",
            actions: ["SNS:Publish"],
            principals: [{
                type: "Service",
                identifiers: ["events.amazonaws.com"],
            }],
            resources: [arn],
        }],
    }));
    const _default = new aws.sns.TopicPolicy("default", {
        arn: awsLogins.arn,
        policy: snsTopicPolicy.apply(snsTopicPolicy => snsTopicPolicy.json),
    });
    
    import pulumi
    import json
    import pulumi_aws as aws
    
    console = aws.cloudwatch.EventRule("console",
        name="capture-aws-sign-in",
        description="Capture each AWS Console Sign In",
        event_pattern=json.dumps({
            "detail-type": ["AWS Console Sign In via CloudTrail"],
        }))
    aws_logins = aws.sns.Topic("aws_logins", name="aws-console-logins")
    sns = aws.cloudwatch.EventTarget("sns",
        rule=console.name,
        target_id="SendToSNS",
        arn=aws_logins.arn)
    sns_topic_policy = aws_logins.arn.apply(lambda arn: aws.iam.get_policy_document_output(statements=[aws.iam.GetPolicyDocumentStatementArgs(
        effect="Allow",
        actions=["SNS:Publish"],
        principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
            type="Service",
            identifiers=["events.amazonaws.com"],
        )],
        resources=[arn],
    )]))
    default = aws.sns.TopicPolicy("default",
        arn=aws_logins.arn,
        policy=sns_topic_policy.json)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    tmpJSON0, err := json.Marshal(map[string]interface{}{
    "detail-type": []string{
    "AWS Console Sign In via CloudTrail",
    },
    })
    if err != nil {
    return err
    }
    json0 := string(tmpJSON0)
    console, err := cloudwatch.NewEventRule(ctx, "console", &cloudwatch.EventRuleArgs{
    Name: pulumi.String("capture-aws-sign-in"),
    Description: pulumi.String("Capture each AWS Console Sign In"),
    EventPattern: pulumi.String(json0),
    })
    if err != nil {
    return err
    }
    awsLogins, err := sns.NewTopic(ctx, "aws_logins", &sns.TopicArgs{
    Name: pulumi.String("aws-console-logins"),
    })
    if err != nil {
    return err
    }
    _, err = cloudwatch.NewEventTarget(ctx, "sns", &cloudwatch.EventTargetArgs{
    Rule: console.Name,
    TargetId: pulumi.String("SendToSNS"),
    Arn: awsLogins.Arn,
    })
    if err != nil {
    return err
    }
    snsTopicPolicy := awsLogins.Arn.ApplyT(func(arn string) (iam.GetPolicyDocumentResult, error) {
    return iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
    Statements: []iam.GetPolicyDocumentStatement{
    {
    Effect: "Allow",
    Actions: []string{
    "SNS:Publish",
    },
    Principals: []iam.GetPolicyDocumentStatementPrincipal{
    {
    Type: "Service",
    Identifiers: []string{
    "events.amazonaws.com",
    },
    },
    },
    Resources: interface{}{
    arn,
    },
    },
    },
    }, nil), nil
    }).(iam.GetPolicyDocumentResultOutput)
    _, err = sns.NewTopicPolicy(ctx, "default", &sns.TopicPolicyArgs{
    Arn: awsLogins.Arn,
    Policy: snsTopicPolicy.ApplyT(func(snsTopicPolicy iam.GetPolicyDocumentResult) (*string, error) {
    return &snsTopicPolicy.Json, nil
    }).(pulumi.StringPtrOutput),
    })
    if err != nil {
    return err
    }
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var console = new Aws.CloudWatch.EventRule("console", new()
        {
            Name = "capture-aws-sign-in",
            Description = "Capture each AWS Console Sign In",
            EventPattern = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["detail-type"] = new[]
                {
                    "AWS Console Sign In via CloudTrail",
                },
            }),
        });
    
        var awsLogins = new Aws.Sns.Topic("aws_logins", new()
        {
            Name = "aws-console-logins",
        });
    
        var sns = new Aws.CloudWatch.EventTarget("sns", new()
        {
            Rule = console.Name,
            TargetId = "SendToSNS",
            Arn = awsLogins.Arn,
        });
    
        var snsTopicPolicy = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Effect = "Allow",
                    Actions = new[]
                    {
                        "SNS:Publish",
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "Service",
                            Identifiers = new[]
                            {
                                "events.amazonaws.com",
                            },
                        },
                    },
                    Resources = new[]
                    {
                        awsLogins.Arn,
                    },
                },
            },
        });
    
        var @default = new Aws.Sns.TopicPolicy("default", new()
        {
            Arn = awsLogins.Arn,
            Policy = snsTopicPolicy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
    });
    
    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.sns.TopicArgs;
    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()        
                .name("capture-aws-sign-in")
                .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", TopicArgs.builder()        
                .name("aws-console-logins")
                .build());
    
            var sns = new EventTarget("sns", EventTargetArgs.builder()        
                .rule(console.name())
                .targetId("SendToSNS")
                .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());
    
        }
    }
    
    resources:
      console:
        type: aws:cloudwatch:EventRule
        properties:
          name: capture-aws-sign-in
          description: Capture each AWS Console Sign In
          eventPattern:
            fn::toJSON:
              detail-type:
                - AWS Console Sign In via CloudTrail
      sns:
        type: aws:cloudwatch:EventTarget
        properties:
          rule: ${console.name}
          targetId: SendToSNS
          arn: ${awsLogins.arn}
      awsLogins:
        type: aws:sns:Topic
        name: aws_logins
        properties:
          name: aws-console-logins
      default:
        type: aws:sns:TopicPolicy
        properties:
          arn: ${awsLogins.arn}
          policy: ${snsTopicPolicy.json}
    variables:
      snsTopicPolicy:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            statements:
              - effect: Allow
                actions:
                  - SNS:Publish
                principals:
                  - type: Service
                    identifiers:
                      - events.amazonaws.com
                resources:
                  - ${awsLogins.arn}
    

    Create EventRule Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new EventRule(name: string, args?: EventRuleArgs, opts?: CustomResourceOptions);
    @overload
    def EventRule(resource_name: str,
                  args: Optional[EventRuleArgs] = None,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def EventRule(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  description: Optional[str] = None,
                  event_bus_name: Optional[str] = None,
                  event_pattern: Optional[str] = None,
                  is_enabled: Optional[bool] = None,
                  name: Optional[str] = None,
                  name_prefix: Optional[str] = None,
                  role_arn: Optional[str] = None,
                  schedule_expression: Optional[str] = None,
                  state: Optional[str] = None,
                  tags: Optional[Mapping[str, str]] = None)
    func NewEventRule(ctx *Context, name string, args *EventRuleArgs, opts ...ResourceOption) (*EventRule, error)
    public EventRule(string name, EventRuleArgs? args = null, CustomResourceOptions? opts = null)
    public EventRule(String name, EventRuleArgs args)
    public EventRule(String name, EventRuleArgs args, CustomResourceOptions options)
    
    type: aws:cloudwatch:EventRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args EventRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args EventRuleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args EventRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EventRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EventRuleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var eventRuleResource = new Aws.CloudWatch.EventRule("eventRuleResource", new()
    {
        Description = "string",
        EventBusName = "string",
        EventPattern = "string",
        Name = "string",
        NamePrefix = "string",
        RoleArn = "string",
        ScheduleExpression = "string",
        State = "string",
        Tags = 
        {
            { "string", "string" },
        },
    });
    
    example, err := cloudwatch.NewEventRule(ctx, "eventRuleResource", &cloudwatch.EventRuleArgs{
    	Description:        pulumi.String("string"),
    	EventBusName:       pulumi.String("string"),
    	EventPattern:       pulumi.String("string"),
    	Name:               pulumi.String("string"),
    	NamePrefix:         pulumi.String("string"),
    	RoleArn:            pulumi.String("string"),
    	ScheduleExpression: pulumi.String("string"),
    	State:              pulumi.String("string"),
    	Tags: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    })
    
    var eventRuleResource = new EventRule("eventRuleResource", EventRuleArgs.builder()        
        .description("string")
        .eventBusName("string")
        .eventPattern("string")
        .name("string")
        .namePrefix("string")
        .roleArn("string")
        .scheduleExpression("string")
        .state("string")
        .tags(Map.of("string", "string"))
        .build());
    
    event_rule_resource = aws.cloudwatch.EventRule("eventRuleResource",
        description="string",
        event_bus_name="string",
        event_pattern="string",
        name="string",
        name_prefix="string",
        role_arn="string",
        schedule_expression="string",
        state="string",
        tags={
            "string": "string",
        })
    
    const eventRuleResource = new aws.cloudwatch.EventRule("eventRuleResource", {
        description: "string",
        eventBusName: "string",
        eventPattern: "string",
        name: "string",
        namePrefix: "string",
        roleArn: "string",
        scheduleExpression: "string",
        state: "string",
        tags: {
            string: "string",
        },
    });
    
    type: aws:cloudwatch:EventRule
    properties:
        description: string
        eventBusName: string
        eventPattern: string
        name: string
        namePrefix: string
        roleArn: string
        scheduleExpression: string
        state: string
        tags:
            string: string
    

    EventRule Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The EventRule resource accepts the following input properties:

    Description string
    The description of the rule.
    EventBusName string
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    EventPattern string
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    IsEnabled bool
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    Name string
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    RoleArn string
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    ScheduleExpression string
    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.
    State string

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    Tags Dictionary<string, string>
    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.
    Description string
    The description of the rule.
    EventBusName string
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    EventPattern string
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    IsEnabled bool
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    Name string
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    RoleArn string
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    ScheduleExpression string
    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.
    State string

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    Tags map[string]string
    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.
    description String
    The description of the rule.
    eventBusName String
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    eventPattern String
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    isEnabled Boolean
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name String
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    roleArn String
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    scheduleExpression String
    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.
    state String

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags Map<String,String>
    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.
    description string
    The description of the rule.
    eventBusName string
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    eventPattern string
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    isEnabled boolean
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name string
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    namePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    roleArn string
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    scheduleExpression string
    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.
    state string

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags {[key: string]: string}
    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.
    description str
    The description of the rule.
    event_bus_name str
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    event_pattern str
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    is_enabled bool
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name str
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    name_prefix str
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    role_arn str
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    schedule_expression str
    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.
    state str

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags Mapping[str, str]
    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.
    description String
    The description of the rule.
    eventBusName String
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    eventPattern String
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    isEnabled Boolean
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name String
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    roleArn String
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    scheduleExpression String
    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.
    state String

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags Map<String>
    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.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the EventRule resource produces the following output properties:

    Arn string
    The Amazon Resource Name (ARN) of the rule.
    Id string
    The provider-assigned unique ID for this managed resource.
    TagsAll Dictionary<string, string>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    Arn string
    The Amazon Resource Name (ARN) of the rule.
    Id string
    The provider-assigned unique ID for this managed resource.
    TagsAll map[string]string
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn String
    The Amazon Resource Name (ARN) of the rule.
    id String
    The provider-assigned unique ID for this managed resource.
    tagsAll Map<String,String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn string
    The Amazon Resource Name (ARN) of the rule.
    id string
    The provider-assigned unique ID for this managed resource.
    tagsAll {[key: string]: string}
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn str
    The Amazon Resource Name (ARN) of the rule.
    id str
    The provider-assigned unique ID for this managed resource.
    tags_all Mapping[str, str]
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn String
    The Amazon Resource Name (ARN) of the rule.
    id String
    The provider-assigned unique ID for this managed resource.
    tagsAll Map<String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    Look up Existing EventRule Resource

    Get an existing EventRule 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?: EventRuleState, opts?: CustomResourceOptions): EventRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            arn: Optional[str] = None,
            description: Optional[str] = None,
            event_bus_name: Optional[str] = None,
            event_pattern: Optional[str] = None,
            is_enabled: Optional[bool] = None,
            name: Optional[str] = None,
            name_prefix: Optional[str] = None,
            role_arn: Optional[str] = None,
            schedule_expression: Optional[str] = None,
            state: Optional[str] = None,
            tags: Optional[Mapping[str, str]] = None,
            tags_all: Optional[Mapping[str, str]] = None) -> EventRule
    func GetEventRule(ctx *Context, name string, id IDInput, state *EventRuleState, opts ...ResourceOption) (*EventRule, error)
    public static EventRule Get(string name, Input<string> id, EventRuleState? state, CustomResourceOptions? opts = null)
    public static EventRule get(String name, Output<String> id, EventRuleState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    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) of the rule.
    Description string
    The description of the rule.
    EventBusName string
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    EventPattern string
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    IsEnabled bool
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    Name string
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    RoleArn string
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    ScheduleExpression string
    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.
    State string

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    Tags Dictionary<string, string>
    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.
    TagsAll Dictionary<string, string>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    Arn string
    The Amazon Resource Name (ARN) of the rule.
    Description string
    The description of the rule.
    EventBusName string
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    EventPattern string
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    IsEnabled bool
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    Name string
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    RoleArn string
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    ScheduleExpression string
    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.
    State string

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    Tags map[string]string
    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.
    TagsAll map[string]string
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn String
    The Amazon Resource Name (ARN) of the rule.
    description String
    The description of the rule.
    eventBusName String
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    eventPattern String
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    isEnabled Boolean
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name String
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    roleArn String
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    scheduleExpression String
    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.
    state String

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags Map<String,String>
    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.
    tagsAll Map<String,String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn string
    The Amazon Resource Name (ARN) of the rule.
    description string
    The description of the rule.
    eventBusName string
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    eventPattern string
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    isEnabled boolean
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name string
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    namePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    roleArn string
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    scheduleExpression string
    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.
    state string

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags {[key: string]: string}
    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.
    tagsAll {[key: string]: string}
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn str
    The Amazon Resource Name (ARN) of the rule.
    description str
    The description of the rule.
    event_bus_name str
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    event_pattern str
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    is_enabled bool
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name str
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    name_prefix str
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    role_arn str
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    schedule_expression str
    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.
    state str

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags Mapping[str, str]
    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.
    tags_all Mapping[str, str]
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    arn String
    The Amazon Resource Name (ARN) of the rule.
    description String
    The description of the rule.
    eventBusName String
    The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
    eventPattern String
    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. Note: The event pattern size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request. See Amazon EventBridge quotas for details.
    isEnabled Boolean
    Whether the rule should be enabled. Defaults to true. Conflicts with state.

    Deprecated: Use "state" instead

    name String
    The name of the rule. If omitted, this provider will assign a random, unique name. Conflicts with name_prefix.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name. Note: Due to the length of the generated suffix, must be 38 characters or less.
    roleArn String
    The Amazon Resource Name (ARN) associated with the role that is used for target invocation.
    scheduleExpression String
    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.
    state String

    State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED. Conflicts with is_enabled.

    NOTE: The rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS cannot be used in conjunction with the schedule_expression argument.

    tags Map<String>
    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.
    tagsAll Map<String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated: Please use tags instead.

    Import

    Using pulumi import, import EventBridge Rules using the event_bus_name/rule_name (if you omit event_bus_name, the default event bus will be used). For example:

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

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi