github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/codestarnotifications/notificationRule.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package codestarnotifications
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides a CodeStar Notifications Rule.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codecommit"
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codestarnotifications"
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  // func main() {
    33  // pulumi.Run(func(ctx *pulumi.Context) error {
    34  // code, err := codecommit.NewRepository(ctx, "code", &codecommit.RepositoryArgs{
    35  // RepositoryName: pulumi.String("example-code-repo"),
    36  // })
    37  // if err != nil {
    38  // return err
    39  // }
    40  // notif, err := sns.NewTopic(ctx, "notif", &sns.TopicArgs{
    41  // Name: pulumi.String("notification"),
    42  // })
    43  // if err != nil {
    44  // return err
    45  // }
    46  // notifAccess := notif.Arn.ApplyT(func(arn string) (iam.GetPolicyDocumentResult, error) {
    47  // return iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
    48  // Statements: []iam.GetPolicyDocumentStatement{
    49  // {
    50  // Actions: []string{
    51  // "sns:Publish",
    52  // },
    53  // Principals: []iam.GetPolicyDocumentStatementPrincipal{
    54  // {
    55  // Type: "Service",
    56  // Identifiers: []string{
    57  // "codestar-notifications.amazonaws.com",
    58  // },
    59  // },
    60  // },
    61  // Resources: interface{}{
    62  // arn,
    63  // },
    64  // },
    65  // },
    66  // }, nil), nil
    67  // }).(iam.GetPolicyDocumentResultOutput)
    68  // _, err = sns.NewTopicPolicy(ctx, "default", &sns.TopicPolicyArgs{
    69  // Arn: notif.Arn,
    70  // Policy: notifAccess.ApplyT(func(notifAccess iam.GetPolicyDocumentResult) (*string, error) {
    71  // return &notifAccess.Json, nil
    72  // }).(pulumi.StringPtrOutput),
    73  // })
    74  // if err != nil {
    75  // return err
    76  // }
    77  // _, err = codestarnotifications.NewNotificationRule(ctx, "commits", &codestarnotifications.NotificationRuleArgs{
    78  // DetailType: pulumi.String("BASIC"),
    79  // EventTypeIds: pulumi.StringArray{
    80  // pulumi.String("codecommit-repository-comments-on-commits"),
    81  // },
    82  // Name: pulumi.String("example-code-repo-commits"),
    83  // Resource: code.Arn,
    84  // Targets: codestarnotifications.NotificationRuleTargetArray{
    85  // &codestarnotifications.NotificationRuleTargetArgs{
    86  // Address: notif.Arn,
    87  // },
    88  // },
    89  // })
    90  // if err != nil {
    91  // return err
    92  // }
    93  // return nil
    94  // })
    95  // }
    96  // ```
    97  // <!--End PulumiCodeChooser -->
    98  //
    99  // ## Import
   100  //
   101  // Using `pulumi import`, import CodeStar notification rule using the ARN. For example:
   102  //
   103  // ```sh
   104  // $ pulumi import aws:codestarnotifications/notificationRule:NotificationRule foo arn:aws:codestar-notifications:us-west-1:0123456789:notificationrule/2cdc68a3-8f7c-4893-b6a5-45b362bd4f2b
   105  // ```
   106  type NotificationRule struct {
   107  	pulumi.CustomResourceState
   108  
   109  	// The codestar notification rule ARN.
   110  	Arn pulumi.StringOutput `pulumi:"arn"`
   111  	// The level of detail to include in the notifications for this resource. Possible values are `BASIC` and `FULL`.
   112  	DetailType pulumi.StringOutput `pulumi:"detailType"`
   113  	// A list of event types associated with this notification rule.
   114  	// For list of allowed events see [here](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#concepts-api).
   115  	EventTypeIds pulumi.StringArrayOutput `pulumi:"eventTypeIds"`
   116  	// The name of notification rule.
   117  	Name pulumi.StringOutput `pulumi:"name"`
   118  	// The ARN of the resource to associate with the notification rule.
   119  	Resource pulumi.StringOutput `pulumi:"resource"`
   120  	// The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`.
   121  	Status pulumi.StringPtrOutput `pulumi:"status"`
   122  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   123  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   124  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   125  	//
   126  	// Deprecated: Please use `tags` instead.
   127  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   128  	// Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
   129  	Targets NotificationRuleTargetArrayOutput `pulumi:"targets"`
   130  }
   131  
   132  // NewNotificationRule registers a new resource with the given unique name, arguments, and options.
   133  func NewNotificationRule(ctx *pulumi.Context,
   134  	name string, args *NotificationRuleArgs, opts ...pulumi.ResourceOption) (*NotificationRule, error) {
   135  	if args == nil {
   136  		return nil, errors.New("missing one or more required arguments")
   137  	}
   138  
   139  	if args.DetailType == nil {
   140  		return nil, errors.New("invalid value for required argument 'DetailType'")
   141  	}
   142  	if args.EventTypeIds == nil {
   143  		return nil, errors.New("invalid value for required argument 'EventTypeIds'")
   144  	}
   145  	if args.Resource == nil {
   146  		return nil, errors.New("invalid value for required argument 'Resource'")
   147  	}
   148  	opts = internal.PkgResourceDefaultOpts(opts)
   149  	var resource NotificationRule
   150  	err := ctx.RegisterResource("aws:codestarnotifications/notificationRule:NotificationRule", name, args, &resource, opts...)
   151  	if err != nil {
   152  		return nil, err
   153  	}
   154  	return &resource, nil
   155  }
   156  
   157  // GetNotificationRule gets an existing NotificationRule resource's state with the given name, ID, and optional
   158  // state properties that are used to uniquely qualify the lookup (nil if not required).
   159  func GetNotificationRule(ctx *pulumi.Context,
   160  	name string, id pulumi.IDInput, state *NotificationRuleState, opts ...pulumi.ResourceOption) (*NotificationRule, error) {
   161  	var resource NotificationRule
   162  	err := ctx.ReadResource("aws:codestarnotifications/notificationRule:NotificationRule", name, id, state, &resource, opts...)
   163  	if err != nil {
   164  		return nil, err
   165  	}
   166  	return &resource, nil
   167  }
   168  
   169  // Input properties used for looking up and filtering NotificationRule resources.
   170  type notificationRuleState struct {
   171  	// The codestar notification rule ARN.
   172  	Arn *string `pulumi:"arn"`
   173  	// The level of detail to include in the notifications for this resource. Possible values are `BASIC` and `FULL`.
   174  	DetailType *string `pulumi:"detailType"`
   175  	// A list of event types associated with this notification rule.
   176  	// For list of allowed events see [here](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#concepts-api).
   177  	EventTypeIds []string `pulumi:"eventTypeIds"`
   178  	// The name of notification rule.
   179  	Name *string `pulumi:"name"`
   180  	// The ARN of the resource to associate with the notification rule.
   181  	Resource *string `pulumi:"resource"`
   182  	// The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`.
   183  	Status *string `pulumi:"status"`
   184  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   185  	Tags map[string]string `pulumi:"tags"`
   186  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   187  	//
   188  	// Deprecated: Please use `tags` instead.
   189  	TagsAll map[string]string `pulumi:"tagsAll"`
   190  	// Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
   191  	Targets []NotificationRuleTarget `pulumi:"targets"`
   192  }
   193  
   194  type NotificationRuleState struct {
   195  	// The codestar notification rule ARN.
   196  	Arn pulumi.StringPtrInput
   197  	// The level of detail to include in the notifications for this resource. Possible values are `BASIC` and `FULL`.
   198  	DetailType pulumi.StringPtrInput
   199  	// A list of event types associated with this notification rule.
   200  	// For list of allowed events see [here](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#concepts-api).
   201  	EventTypeIds pulumi.StringArrayInput
   202  	// The name of notification rule.
   203  	Name pulumi.StringPtrInput
   204  	// The ARN of the resource to associate with the notification rule.
   205  	Resource pulumi.StringPtrInput
   206  	// The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`.
   207  	Status pulumi.StringPtrInput
   208  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   209  	Tags pulumi.StringMapInput
   210  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   211  	//
   212  	// Deprecated: Please use `tags` instead.
   213  	TagsAll pulumi.StringMapInput
   214  	// Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
   215  	Targets NotificationRuleTargetArrayInput
   216  }
   217  
   218  func (NotificationRuleState) ElementType() reflect.Type {
   219  	return reflect.TypeOf((*notificationRuleState)(nil)).Elem()
   220  }
   221  
   222  type notificationRuleArgs struct {
   223  	// The level of detail to include in the notifications for this resource. Possible values are `BASIC` and `FULL`.
   224  	DetailType string `pulumi:"detailType"`
   225  	// A list of event types associated with this notification rule.
   226  	// For list of allowed events see [here](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#concepts-api).
   227  	EventTypeIds []string `pulumi:"eventTypeIds"`
   228  	// The name of notification rule.
   229  	Name *string `pulumi:"name"`
   230  	// The ARN of the resource to associate with the notification rule.
   231  	Resource string `pulumi:"resource"`
   232  	// The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`.
   233  	Status *string `pulumi:"status"`
   234  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   235  	Tags map[string]string `pulumi:"tags"`
   236  	// Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
   237  	Targets []NotificationRuleTarget `pulumi:"targets"`
   238  }
   239  
   240  // The set of arguments for constructing a NotificationRule resource.
   241  type NotificationRuleArgs struct {
   242  	// The level of detail to include in the notifications for this resource. Possible values are `BASIC` and `FULL`.
   243  	DetailType pulumi.StringInput
   244  	// A list of event types associated with this notification rule.
   245  	// For list of allowed events see [here](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#concepts-api).
   246  	EventTypeIds pulumi.StringArrayInput
   247  	// The name of notification rule.
   248  	Name pulumi.StringPtrInput
   249  	// The ARN of the resource to associate with the notification rule.
   250  	Resource pulumi.StringInput
   251  	// The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`.
   252  	Status pulumi.StringPtrInput
   253  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   254  	Tags pulumi.StringMapInput
   255  	// Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
   256  	Targets NotificationRuleTargetArrayInput
   257  }
   258  
   259  func (NotificationRuleArgs) ElementType() reflect.Type {
   260  	return reflect.TypeOf((*notificationRuleArgs)(nil)).Elem()
   261  }
   262  
   263  type NotificationRuleInput interface {
   264  	pulumi.Input
   265  
   266  	ToNotificationRuleOutput() NotificationRuleOutput
   267  	ToNotificationRuleOutputWithContext(ctx context.Context) NotificationRuleOutput
   268  }
   269  
   270  func (*NotificationRule) ElementType() reflect.Type {
   271  	return reflect.TypeOf((**NotificationRule)(nil)).Elem()
   272  }
   273  
   274  func (i *NotificationRule) ToNotificationRuleOutput() NotificationRuleOutput {
   275  	return i.ToNotificationRuleOutputWithContext(context.Background())
   276  }
   277  
   278  func (i *NotificationRule) ToNotificationRuleOutputWithContext(ctx context.Context) NotificationRuleOutput {
   279  	return pulumi.ToOutputWithContext(ctx, i).(NotificationRuleOutput)
   280  }
   281  
   282  // NotificationRuleArrayInput is an input type that accepts NotificationRuleArray and NotificationRuleArrayOutput values.
   283  // You can construct a concrete instance of `NotificationRuleArrayInput` via:
   284  //
   285  //	NotificationRuleArray{ NotificationRuleArgs{...} }
   286  type NotificationRuleArrayInput interface {
   287  	pulumi.Input
   288  
   289  	ToNotificationRuleArrayOutput() NotificationRuleArrayOutput
   290  	ToNotificationRuleArrayOutputWithContext(context.Context) NotificationRuleArrayOutput
   291  }
   292  
   293  type NotificationRuleArray []NotificationRuleInput
   294  
   295  func (NotificationRuleArray) ElementType() reflect.Type {
   296  	return reflect.TypeOf((*[]*NotificationRule)(nil)).Elem()
   297  }
   298  
   299  func (i NotificationRuleArray) ToNotificationRuleArrayOutput() NotificationRuleArrayOutput {
   300  	return i.ToNotificationRuleArrayOutputWithContext(context.Background())
   301  }
   302  
   303  func (i NotificationRuleArray) ToNotificationRuleArrayOutputWithContext(ctx context.Context) NotificationRuleArrayOutput {
   304  	return pulumi.ToOutputWithContext(ctx, i).(NotificationRuleArrayOutput)
   305  }
   306  
   307  // NotificationRuleMapInput is an input type that accepts NotificationRuleMap and NotificationRuleMapOutput values.
   308  // You can construct a concrete instance of `NotificationRuleMapInput` via:
   309  //
   310  //	NotificationRuleMap{ "key": NotificationRuleArgs{...} }
   311  type NotificationRuleMapInput interface {
   312  	pulumi.Input
   313  
   314  	ToNotificationRuleMapOutput() NotificationRuleMapOutput
   315  	ToNotificationRuleMapOutputWithContext(context.Context) NotificationRuleMapOutput
   316  }
   317  
   318  type NotificationRuleMap map[string]NotificationRuleInput
   319  
   320  func (NotificationRuleMap) ElementType() reflect.Type {
   321  	return reflect.TypeOf((*map[string]*NotificationRule)(nil)).Elem()
   322  }
   323  
   324  func (i NotificationRuleMap) ToNotificationRuleMapOutput() NotificationRuleMapOutput {
   325  	return i.ToNotificationRuleMapOutputWithContext(context.Background())
   326  }
   327  
   328  func (i NotificationRuleMap) ToNotificationRuleMapOutputWithContext(ctx context.Context) NotificationRuleMapOutput {
   329  	return pulumi.ToOutputWithContext(ctx, i).(NotificationRuleMapOutput)
   330  }
   331  
   332  type NotificationRuleOutput struct{ *pulumi.OutputState }
   333  
   334  func (NotificationRuleOutput) ElementType() reflect.Type {
   335  	return reflect.TypeOf((**NotificationRule)(nil)).Elem()
   336  }
   337  
   338  func (o NotificationRuleOutput) ToNotificationRuleOutput() NotificationRuleOutput {
   339  	return o
   340  }
   341  
   342  func (o NotificationRuleOutput) ToNotificationRuleOutputWithContext(ctx context.Context) NotificationRuleOutput {
   343  	return o
   344  }
   345  
   346  // The codestar notification rule ARN.
   347  func (o NotificationRuleOutput) Arn() pulumi.StringOutput {
   348  	return o.ApplyT(func(v *NotificationRule) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   349  }
   350  
   351  // The level of detail to include in the notifications for this resource. Possible values are `BASIC` and `FULL`.
   352  func (o NotificationRuleOutput) DetailType() pulumi.StringOutput {
   353  	return o.ApplyT(func(v *NotificationRule) pulumi.StringOutput { return v.DetailType }).(pulumi.StringOutput)
   354  }
   355  
   356  // A list of event types associated with this notification rule.
   357  // For list of allowed events see [here](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#concepts-api).
   358  func (o NotificationRuleOutput) EventTypeIds() pulumi.StringArrayOutput {
   359  	return o.ApplyT(func(v *NotificationRule) pulumi.StringArrayOutput { return v.EventTypeIds }).(pulumi.StringArrayOutput)
   360  }
   361  
   362  // The name of notification rule.
   363  func (o NotificationRuleOutput) Name() pulumi.StringOutput {
   364  	return o.ApplyT(func(v *NotificationRule) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   365  }
   366  
   367  // The ARN of the resource to associate with the notification rule.
   368  func (o NotificationRuleOutput) Resource() pulumi.StringOutput {
   369  	return o.ApplyT(func(v *NotificationRule) pulumi.StringOutput { return v.Resource }).(pulumi.StringOutput)
   370  }
   371  
   372  // The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`.
   373  func (o NotificationRuleOutput) Status() pulumi.StringPtrOutput {
   374  	return o.ApplyT(func(v *NotificationRule) pulumi.StringPtrOutput { return v.Status }).(pulumi.StringPtrOutput)
   375  }
   376  
   377  // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   378  func (o NotificationRuleOutput) Tags() pulumi.StringMapOutput {
   379  	return o.ApplyT(func(v *NotificationRule) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   380  }
   381  
   382  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   383  //
   384  // Deprecated: Please use `tags` instead.
   385  func (o NotificationRuleOutput) TagsAll() pulumi.StringMapOutput {
   386  	return o.ApplyT(func(v *NotificationRule) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   387  }
   388  
   389  // Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.
   390  func (o NotificationRuleOutput) Targets() NotificationRuleTargetArrayOutput {
   391  	return o.ApplyT(func(v *NotificationRule) NotificationRuleTargetArrayOutput { return v.Targets }).(NotificationRuleTargetArrayOutput)
   392  }
   393  
   394  type NotificationRuleArrayOutput struct{ *pulumi.OutputState }
   395  
   396  func (NotificationRuleArrayOutput) ElementType() reflect.Type {
   397  	return reflect.TypeOf((*[]*NotificationRule)(nil)).Elem()
   398  }
   399  
   400  func (o NotificationRuleArrayOutput) ToNotificationRuleArrayOutput() NotificationRuleArrayOutput {
   401  	return o
   402  }
   403  
   404  func (o NotificationRuleArrayOutput) ToNotificationRuleArrayOutputWithContext(ctx context.Context) NotificationRuleArrayOutput {
   405  	return o
   406  }
   407  
   408  func (o NotificationRuleArrayOutput) Index(i pulumi.IntInput) NotificationRuleOutput {
   409  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *NotificationRule {
   410  		return vs[0].([]*NotificationRule)[vs[1].(int)]
   411  	}).(NotificationRuleOutput)
   412  }
   413  
   414  type NotificationRuleMapOutput struct{ *pulumi.OutputState }
   415  
   416  func (NotificationRuleMapOutput) ElementType() reflect.Type {
   417  	return reflect.TypeOf((*map[string]*NotificationRule)(nil)).Elem()
   418  }
   419  
   420  func (o NotificationRuleMapOutput) ToNotificationRuleMapOutput() NotificationRuleMapOutput {
   421  	return o
   422  }
   423  
   424  func (o NotificationRuleMapOutput) ToNotificationRuleMapOutputWithContext(ctx context.Context) NotificationRuleMapOutput {
   425  	return o
   426  }
   427  
   428  func (o NotificationRuleMapOutput) MapIndex(k pulumi.StringInput) NotificationRuleOutput {
   429  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *NotificationRule {
   430  		return vs[0].(map[string]*NotificationRule)[vs[1].(string)]
   431  	}).(NotificationRuleOutput)
   432  }
   433  
   434  func init() {
   435  	pulumi.RegisterInputType(reflect.TypeOf((*NotificationRuleInput)(nil)).Elem(), &NotificationRule{})
   436  	pulumi.RegisterInputType(reflect.TypeOf((*NotificationRuleArrayInput)(nil)).Elem(), NotificationRuleArray{})
   437  	pulumi.RegisterInputType(reflect.TypeOf((*NotificationRuleMapInput)(nil)).Elem(), NotificationRuleMap{})
   438  	pulumi.RegisterOutputType(NotificationRuleOutput{})
   439  	pulumi.RegisterOutputType(NotificationRuleArrayOutput{})
   440  	pulumi.RegisterOutputType(NotificationRuleMapOutput{})
   441  }