NotificationRule
Provides a CodeStar Notifications Rule.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var code = new Aws.CodeCommit.Repository("code", new Aws.CodeCommit.RepositoryArgs
{
RepositoryName = "example-code-repo",
});
var notif = new Aws.Sns.Topic("notif", new Aws.Sns.TopicArgs
{
});
var notifAccess = notif.Arn.Apply(arn => Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
{
Statements =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
{
Actions =
{
"sns:Publish",
},
Principals =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
{
Type = "Service",
Identifiers =
{
"codestar-notifications.amazonaws.com",
},
},
},
Resources =
{
arn,
},
},
},
}));
var @default = new Aws.Sns.TopicPolicy("default", new Aws.Sns.TopicPolicyArgs
{
Arn = notif.Arn,
Policy = notifAccess.Apply(notifAccess => notifAccess.Json),
});
var commits = new Aws.CodeStarNotifications.NotificationRule("commits", new Aws.CodeStarNotifications.NotificationRuleArgs
{
DetailType = "BASIC",
EventTypeIds =
{
"codecommit-repository-comments-on-commits",
},
Resource = code.Arn,
Targets =
{
new Aws.CodeStarNotifications.Inputs.NotificationRuleTargetArgs
{
Address = notif.Arn,
},
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codecommit"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codestarnotifications"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
code, err := codecommit.NewRepository(ctx, "code", &codecommit.RepositoryArgs{
RepositoryName: pulumi.String("example-code-repo"),
})
if err != nil {
return err
}
notif, err := sns.NewTopic(ctx, "notif", nil)
if err != nil {
return err
}
_, err = sns.NewTopicPolicy(ctx, "_default", &sns.TopicPolicyArgs{
Arn: notif.Arn,
Policy: notifAccess.ApplyT(func(notifAccess iam.GetPolicyDocumentResult) (string, error) {
return notifAccess.Json, nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
_, err = codestarnotifications.NewNotificationRule(ctx, "commits", &codestarnotifications.NotificationRuleArgs{
DetailType: pulumi.String("BASIC"),
EventTypeIds: pulumi.StringArray{
pulumi.String("codecommit-repository-comments-on-commits"),
},
Resource: code.Arn,
Targets: codestarnotifications.NotificationRuleTargetArray{
&codestarnotifications.NotificationRuleTargetArgs{
Address: notif.Arn,
},
},
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
code = aws.codecommit.Repository("code", repository_name="example-code-repo")
notif = aws.sns.Topic("notif")
notif_access = notif.arn.apply(lambda arn: aws.iam.get_policy_document(statements=[{
"actions": ["sns:Publish"],
"principals": [{
"type": "Service",
"identifiers": ["codestar-notifications.amazonaws.com"],
}],
"resources": [arn],
}]))
default = aws.sns.TopicPolicy("default",
arn=notif.arn,
policy=notif_access.json)
commits = aws.codestarnotifications.NotificationRule("commits",
detail_type="BASIC",
event_type_ids=["codecommit-repository-comments-on-commits"],
resource=code.arn,
targets=[{
"address": notif.arn,
}])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const code = new aws.codecommit.Repository("code", {repositoryName: "example-code-repo"});
const notif = new aws.sns.Topic("notif", {});
const notifAccess = notif.arn.apply(arn => aws.iam.getPolicyDocument({
statements: [{
actions: ["sns:Publish"],
principals: [{
type: "Service",
identifiers: ["codestar-notifications.amazonaws.com"],
}],
resources: [arn],
}],
}));
const _default = new aws.sns.TopicPolicy("default", {
arn: notif.arn,
policy: notifAccess.json,
});
const commits = new aws.codestarnotifications.NotificationRule("commits", {
detailType: "BASIC",
eventTypeIds: ["codecommit-repository-comments-on-commits"],
resource: code.arn,
targets: [{
address: notif.arn,
}],
});Create a NotificationRule Resource
new NotificationRule(name: string, args: NotificationRuleArgs, opts?: CustomResourceOptions);def NotificationRule(resource_name, opts=None, detail_type=None, event_type_ids=None, name=None, resource=None, status=None, tags=None, targets=None, __props__=None);func NewNotificationRule(ctx *Context, name string, args NotificationRuleArgs, opts ...ResourceOption) (*NotificationRule, error)public NotificationRule(string name, NotificationRuleArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args NotificationRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args NotificationRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NotificationRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
NotificationRule Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The NotificationRule resource accepts the following input properties:
- Detail
Type string The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- Event
Type List<string>Ids A list of event types associated with this notification rule. For list of allowed events see here.
- Resource string
The ARN of the resource to associate with the notification rule.
- Name string
The name of notification rule.
- Status string
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- Dictionary<string, string>
A map of tags to assign to the resource.
- Targets
List<Notification
Rule Target Args> Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
- Detail
Type string The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- Event
Type []stringIds A list of event types associated with this notification rule. For list of allowed events see here.
- Resource string
The ARN of the resource to associate with the notification rule.
- Name string
The name of notification rule.
- Status string
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- map[string]string
A map of tags to assign to the resource.
- Targets
[]Notification
Rule Target Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
- detail
Type string The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- event
Type string[]Ids A list of event types associated with this notification rule. For list of allowed events see here.
- resource string
The ARN of the resource to associate with the notification rule.
- name string
The name of notification rule.
- status string
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- {[key: string]: string}
A map of tags to assign to the resource.
- targets
Notification
Rule Target[] Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
- detail_
type str The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- event_
type_ List[str]ids A list of event types associated with this notification rule. For list of allowed events see here.
- resource str
The ARN of the resource to associate with the notification rule.
- name str
The name of notification rule.
- status str
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- Dict[str, str]
A map of tags to assign to the resource.
- targets
List[Notification
Rule Target] Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
Outputs
All input properties are implicitly available as output properties. Additionally, the NotificationRule resource produces the following output properties:
Look up an Existing NotificationRule Resource
Get an existing NotificationRule 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?: NotificationRuleState, opts?: CustomResourceOptions): NotificationRulestatic get(resource_name, id, opts=None, arn=None, detail_type=None, event_type_ids=None, name=None, resource=None, status=None, tags=None, targets=None, __props__=None);func GetNotificationRule(ctx *Context, name string, id IDInput, state *NotificationRuleState, opts ...ResourceOption) (*NotificationRule, error)public static NotificationRule Get(string name, Input<string> id, NotificationRuleState? state, CustomResourceOptions? opts = null)- 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.
The following state arguments are supported:
- Arn string
The codestar notification rule ARN.
- Detail
Type string The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- Event
Type List<string>Ids A list of event types associated with this notification rule. For list of allowed events see here.
- Name string
The name of notification rule.
- Resource string
The ARN of the resource to associate with the notification rule.
- Status string
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- Dictionary<string, string>
A map of tags to assign to the resource.
- Targets
List<Notification
Rule Target Args> Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
- Arn string
The codestar notification rule ARN.
- Detail
Type string The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- Event
Type []stringIds A list of event types associated with this notification rule. For list of allowed events see here.
- Name string
The name of notification rule.
- Resource string
The ARN of the resource to associate with the notification rule.
- Status string
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- map[string]string
A map of tags to assign to the resource.
- Targets
[]Notification
Rule Target Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
- arn string
The codestar notification rule ARN.
- detail
Type string The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- event
Type string[]Ids A list of event types associated with this notification rule. For list of allowed events see here.
- name string
The name of notification rule.
- resource string
The ARN of the resource to associate with the notification rule.
- status string
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- {[key: string]: string}
A map of tags to assign to the resource.
- targets
Notification
Rule Target[] Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
- arn str
The codestar notification rule ARN.
- detail_
type str The level of detail to include in the notifications for this resource. Possible values are
BASICandFULL.- event_
type_ List[str]ids A list of event types associated with this notification rule. For list of allowed events see here.
- name str
The name of notification rule.
- resource str
The ARN of the resource to associate with the notification rule.
- status str
The status of the notification rule. Possible values are
ENABLEDandDISABLED, default isENABLED.- Dict[str, str]
A map of tags to assign to the resource.
- targets
List[Notification
Rule Target] Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
Supporting Types
NotificationRuleTarget
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.