libZSservicesZSamazonka-cloudwatch-eventsZSamazonka-cloudwatch-events
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.CloudWatchEvents.PutRule

Description

Creates or updates the specified rule. Rules are enabled by default, or based on value of the state. You can disable a rule using DisableRule.

A single rule watches for events from a single event bus. Events generated by Amazon Web Services services go to your account's default event bus. Events generated by SaaS partner services or applications go to the matching partner event bus. If you have custom applications or services, you can specify whether their events go to your default event bus or a custom event bus that you have created. For more information, see CreateEventBus.

If you are updating an existing rule, the rule is replaced with what you specify in this PutRule command. If you omit arguments in PutRule, the old values for those arguments are not kept. Instead, they are replaced with null values.

When you create or update a rule, incoming events might not immediately start matching to new or updated rules. Allow a short period of time for changes to take effect.

A rule must contain at least an EventPattern or ScheduleExpression. Rules with EventPatterns are triggered when a matching event is observed. Rules with ScheduleExpressions self-trigger based on the given schedule. A rule can have both an EventPattern and a ScheduleExpression, in which case the rule triggers on matching events as well as on a schedule.

When you initially create a rule, you can optionally assign one or more tags to the rule. Tags can help you organize and categorize your resources. You can also use them to scope user permissions, by granting a user permission to access or change only rules with certain tag values. To use the PutRule operation and assign tags, you must have both the events:PutRule and events:TagResource permissions.

If you are updating an existing rule, any tags you specify in the PutRule operation are ignored. To update the tags of an existing rule, use TagResource and UntagResource.

Most services in Amazon Web Services treat : or / as the same character in Amazon Resource Names (ARNs). However, EventBridge uses an exact match in event patterns and rules. Be sure to use the correct ARN characters when creating event patterns so that they match the ARN syntax in the event you want to match.

In EventBridge, it is possible to create rules that lead to infinite loops, where a rule is fired repeatedly. For example, a rule might detect that ACLs have changed on an S3 bucket, and trigger software to change them to the desired state. If the rule is not written carefully, the subsequent change to the ACLs fires the rule again, creating an infinite loop.

To prevent this, write the rules so that the triggered actions do not re-fire the same rule. For example, your rule could fire only if ACLs are found to be in a bad state, instead of after any change.

An infinite loop can quickly cause higher than expected charges. We recommend that you use budgeting, which alerts you when charges exceed your specified limit. For more information, see Managing Your Costs with Budgets.

Synopsis

Creating a Request

data PutRule Source #

See: newPutRule smart constructor.

Constructors

PutRule' 

Fields

  • eventPattern :: Maybe Text

    The event pattern. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.

  • state :: Maybe RuleState

    Indicates whether the rule is enabled or disabled.

  • eventBusName :: Maybe Text

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

  • scheduleExpression :: Maybe Text

    The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".

  • description :: Maybe Text

    A description of the rule.

  • tags :: Maybe [Tag]

    The list of key-value pairs to associate with the rule.

  • roleArn :: Maybe Text

    The Amazon Resource Name (ARN) of the IAM role associated with the rule.

    If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a RoleArn with proper permissions in the Target structure, instead of here in this parameter.

  • name :: Text

    The name of the rule that you are creating or updating.

Instances

Instances details
Eq PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Methods

(==) :: PutRule -> PutRule -> Bool #

(/=) :: PutRule -> PutRule -> Bool #

Read PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Show PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Generic PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Associated Types

type Rep PutRule :: Type -> Type #

Methods

from :: PutRule -> Rep PutRule x #

to :: Rep PutRule x -> PutRule #

NFData PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Methods

rnf :: PutRule -> () #

Hashable PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Methods

hashWithSalt :: Int -> PutRule -> Int #

hash :: PutRule -> Int #

ToJSON PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

AWSRequest PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Associated Types

type AWSResponse PutRule #

ToHeaders PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Methods

toHeaders :: PutRule -> [Header] #

ToPath PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Methods

toPath :: PutRule -> ByteString #

ToQuery PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

type Rep PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

type AWSResponse PutRule Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

newPutRule Source #

Create a value of PutRule with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:eventPattern:PutRule', putRule_eventPattern - The event pattern. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.

$sel:state:PutRule', putRule_state - Indicates whether the rule is enabled or disabled.

$sel:eventBusName:PutRule', putRule_eventBusName - The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.

$sel:scheduleExpression:PutRule', putRule_scheduleExpression - The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".

$sel:description:PutRule', putRule_description - A description of the rule.

$sel:tags:PutRule', putRule_tags - The list of key-value pairs to associate with the rule.

$sel:roleArn:PutRule', putRule_roleArn - The Amazon Resource Name (ARN) of the IAM role associated with the rule.

If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a RoleArn with proper permissions in the Target structure, instead of here in this parameter.

$sel:name:PutRule', putRule_name - The name of the rule that you are creating or updating.

Request Lenses

putRule_eventPattern :: Lens' PutRule (Maybe Text) Source #

The event pattern. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.

putRule_state :: Lens' PutRule (Maybe RuleState) Source #

Indicates whether the rule is enabled or disabled.

putRule_eventBusName :: Lens' PutRule (Maybe Text) Source #

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

putRule_scheduleExpression :: Lens' PutRule (Maybe Text) Source #

The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".

putRule_description :: Lens' PutRule (Maybe Text) Source #

A description of the rule.

putRule_tags :: Lens' PutRule (Maybe [Tag]) Source #

The list of key-value pairs to associate with the rule.

putRule_roleArn :: Lens' PutRule (Maybe Text) Source #

The Amazon Resource Name (ARN) of the IAM role associated with the rule.

If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a RoleArn with proper permissions in the Target structure, instead of here in this parameter.

putRule_name :: Lens' PutRule Text Source #

The name of the rule that you are creating or updating.

Destructuring the Response

data PutRuleResponse Source #

See: newPutRuleResponse smart constructor.

Constructors

PutRuleResponse' 

Fields

Instances

Instances details
Eq PutRuleResponse Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Read PutRuleResponse Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Show PutRuleResponse Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Generic PutRuleResponse Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Associated Types

type Rep PutRuleResponse :: Type -> Type #

NFData PutRuleResponse Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

Methods

rnf :: PutRuleResponse -> () #

type Rep PutRuleResponse Source # 
Instance details

Defined in Amazonka.CloudWatchEvents.PutRule

type Rep PutRuleResponse = D1 ('MetaData "PutRuleResponse" "Amazonka.CloudWatchEvents.PutRule" "libZSservicesZSamazonka-cloudwatch-eventsZSamazonka-cloudwatch-events" 'False) (C1 ('MetaCons "PutRuleResponse'" 'PrefixI 'True) (S1 ('MetaSel ('Just "ruleArn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "httpStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)))

newPutRuleResponse Source #

Create a value of PutRuleResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:ruleArn:PutRuleResponse', putRuleResponse_ruleArn - The Amazon Resource Name (ARN) of the rule.

$sel:httpStatus:PutRuleResponse', putRuleResponse_httpStatus - The response's http status code.

Response Lenses

putRuleResponse_ruleArn :: Lens' PutRuleResponse (Maybe Text) Source #

The Amazon Resource Name (ARN) of the rule.

putRuleResponse_httpStatus :: Lens' PutRuleResponse Int Source #

The response's http status code.