aws.notifications.EventRule
Explore with Pulumi AI
Resource for managing an AWS User Notifications Event Rule.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.notifications.NotificationConfiguration("example", {
name: "example",
description: "example configuration",
});
const exampleEventRule = new aws.notifications.EventRule("example", {
eventPattern: JSON.stringify({
detail: {
state: {
value: ["ALARM"],
},
},
}),
eventType: "CloudWatch Alarm State Change",
notificationConfigurationArn: example.arn,
regions: [
"us-east-1",
"us-west-2",
],
source: "aws.cloudwatch",
});
import pulumi
import json
import pulumi_aws as aws
example = aws.notifications.NotificationConfiguration("example",
name="example",
description="example configuration")
example_event_rule = aws.notifications.EventRule("example",
event_pattern=json.dumps({
"detail": {
"state": {
"value": ["ALARM"],
},
},
}),
event_type="CloudWatch Alarm State Change",
notification_configuration_arn=example.arn,
regions=[
"us-east-1",
"us-west-2",
],
source="aws.cloudwatch")
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/notifications"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := notifications.NewNotificationConfiguration(ctx, "example", ¬ifications.NotificationConfigurationArgs{
Name: pulumi.String("example"),
Description: pulumi.String("example configuration"),
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"detail": map[string]interface{}{
"state": map[string]interface{}{
"value": []string{
"ALARM",
},
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = notifications.NewEventRule(ctx, "example", ¬ifications.EventRuleArgs{
EventPattern: pulumi.String(json0),
EventType: pulumi.String("CloudWatch Alarm State Change"),
NotificationConfigurationArn: example.Arn,
Regions: pulumi.StringArray{
pulumi.String("us-east-1"),
pulumi.String("us-west-2"),
},
Source: pulumi.String("aws.cloudwatch"),
})
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 example = new Aws.Notifications.NotificationConfiguration("example", new()
{
Name = "example",
Description = "example configuration",
});
var exampleEventRule = new Aws.Notifications.EventRule("example", new()
{
EventPattern = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["detail"] = new Dictionary<string, object?>
{
["state"] = new Dictionary<string, object?>
{
["value"] = new[]
{
"ALARM",
},
},
},
}),
EventType = "CloudWatch Alarm State Change",
NotificationConfigurationArn = example.Arn,
Regions = new[]
{
"us-east-1",
"us-west-2",
},
Source = "aws.cloudwatch",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.notifications.NotificationConfiguration;
import com.pulumi.aws.notifications.NotificationConfigurationArgs;
import com.pulumi.aws.notifications.EventRule;
import com.pulumi.aws.notifications.EventRuleArgs;
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 example = new NotificationConfiguration("example", NotificationConfigurationArgs.builder()
.name("example")
.description("example configuration")
.build());
var exampleEventRule = new EventRule("exampleEventRule", EventRuleArgs.builder()
.eventPattern(serializeJson(
jsonObject(
jsonProperty("detail", jsonObject(
jsonProperty("state", jsonObject(
jsonProperty("value", jsonArray("ALARM"))
))
))
)))
.eventType("CloudWatch Alarm State Change")
.notificationConfigurationArn(example.arn())
.regions(
"us-east-1",
"us-west-2")
.source("aws.cloudwatch")
.build());
}
}
resources:
example:
type: aws:notifications:NotificationConfiguration
properties:
name: example
description: example configuration
exampleEventRule:
type: aws:notifications:EventRule
name: example
properties:
eventPattern:
fn::toJSON:
detail:
state:
value:
- ALARM
eventType: CloudWatch Alarm State Change
notificationConfigurationArn: ${example.arn}
regions:
- us-east-1
- us-west-2
source: aws.cloudwatch
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: EventRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def EventRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
event_type: Optional[str] = None,
notification_configuration_arn: Optional[str] = None,
regions: Optional[Sequence[str]] = None,
source: Optional[str] = None,
event_pattern: Optional[str] = None)
func NewEventRule(ctx *Context, name string, args EventRuleArgs, opts ...ResourceOption) (*EventRule, error)
public EventRule(string name, EventRuleArgs args, CustomResourceOptions? opts = null)
public EventRule(String name, EventRuleArgs args)
public EventRule(String name, EventRuleArgs args, CustomResourceOptions options)
type: aws:notifications: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.
Constructor example
The following reference example uses placeholder values for all input properties.
var awsEventRuleResource = new Aws.Notifications.EventRule("awsEventRuleResource", new()
{
EventType = "string",
NotificationConfigurationArn = "string",
Regions = new[]
{
"string",
},
Source = "string",
EventPattern = "string",
});
example, err := notifications.NewEventRule(ctx, "awsEventRuleResource", ¬ifications.EventRuleArgs{
EventType: pulumi.String("string"),
NotificationConfigurationArn: pulumi.String("string"),
Regions: pulumi.StringArray{
pulumi.String("string"),
},
Source: pulumi.String("string"),
EventPattern: pulumi.String("string"),
})
var awsEventRuleResource = new com.pulumi.aws.notifications.EventRule("awsEventRuleResource", com.pulumi.aws.notifications.EventRuleArgs.builder()
.eventType("string")
.notificationConfigurationArn("string")
.regions("string")
.source("string")
.eventPattern("string")
.build());
aws_event_rule_resource = aws.notifications.EventRule("awsEventRuleResource",
event_type="string",
notification_configuration_arn="string",
regions=["string"],
source="string",
event_pattern="string")
const awsEventRuleResource = new aws.notifications.EventRule("awsEventRuleResource", {
eventType: "string",
notificationConfigurationArn: "string",
regions: ["string"],
source: "string",
eventPattern: "string",
});
type: aws:notifications:EventRule
properties:
eventPattern: string
eventType: string
notificationConfigurationArn: string
regions:
- string
source: 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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The EventRule resource accepts the following input properties:
- Event
Type string - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - Notification
Configuration stringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - Regions List<string>
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - Source string
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- Event
Pattern string - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- Event
Type string - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - Notification
Configuration stringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - Regions []string
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - Source string
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- Event
Pattern string - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event
Type String - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification
Configuration StringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions List<String>
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source String
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- event
Pattern String - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event
Type string - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification
Configuration stringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions string[]
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source string
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- event
Pattern string - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event_
type str - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification_
configuration_ strarn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions Sequence[str]
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source str
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- event_
pattern str - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event
Type String - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification
Configuration StringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions List<String>
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source String
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- event
Pattern String - JSON string defining the event pattern to match. Maximum length is 4096 characters.
Outputs
All input properties are implicitly available as output properties. Additionally, the EventRule resource produces the following output properties:
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,
event_pattern: Optional[str] = None,
event_type: Optional[str] = None,
notification_configuration_arn: Optional[str] = None,
regions: Optional[Sequence[str]] = None,
source: Optional[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)
resources: _: type: aws:notifications:EventRule get: id: ${id}
- 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.
- Arn string
- ARN of the Event Rule.
- Event
Pattern string - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- Event
Type string - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - Notification
Configuration stringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - Regions List<string>
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - Source string
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- Arn string
- ARN of the Event Rule.
- Event
Pattern string - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- Event
Type string - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - Notification
Configuration stringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - Regions []string
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - Source string
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- arn String
- ARN of the Event Rule.
- event
Pattern String - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event
Type String - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification
Configuration StringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions List<String>
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source String
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- arn string
- ARN of the Event Rule.
- event
Pattern string - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event
Type string - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification
Configuration stringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions string[]
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source string
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- arn str
- ARN of the Event Rule.
- event_
pattern str - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event_
type str - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification_
configuration_ strarn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions Sequence[str]
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source str
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
- arn String
- ARN of the Event Rule.
- event
Pattern String - JSON string defining the event pattern to match. Maximum length is 4096 characters.
- event
Type String - Type of event to match. Must be between 1 and 128 characters, and match the pattern
([a-zA-Z0-9 \-\(\)])+
. - notification
Configuration StringArn - ARN of the notification configuration to associate with this event rule. Must match the pattern
arn:aws:notifications::[0-9]{12}:configuration/[a-z0-9]{27}
. - regions List<String>
- Set of AWS regions where the event rule will be applied. Each region must be between 2 and 25 characters, and match the pattern
([a-z]{1,2})-([a-z]{1,15}-)+([0-9])
. - source String
Source of the event. Must be between 1 and 36 characters, and match the pattern
aws.([a-z0-9\-])+
.The following arguments are optional:
Import
Using pulumi import
, import User Notifications Event Rule using the arn
. For example:
$ pulumi import aws:notifications/eventRule:EventRule example arn:aws:notifications::123456789012:configuration/abc123def456ghi789jkl012mno345/rule/abc123def456ghi789jkl012mno345
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.