github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/oam/sinkPolicy.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 oam
     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  // Resource for managing an AWS CloudWatch Observability Access Manager Sink Policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"encoding/json"
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/oam"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			example, err := oam.NewSink(ctx, "example", &oam.SinkArgs{
    37  //				Name: pulumi.String("ExampleSink"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    43  //				"Version": "2012-10-17",
    44  //				"Statement": []map[string]interface{}{
    45  //					map[string]interface{}{
    46  //						"Action": []string{
    47  //							"oam:CreateLink",
    48  //							"oam:UpdateLink",
    49  //						},
    50  //						"Effect":   "Allow",
    51  //						"Resource": "*",
    52  //						"Principal": map[string]interface{}{
    53  //							"AWS": []string{
    54  //								"1111111111111",
    55  //								"222222222222",
    56  //							},
    57  //						},
    58  //						"Condition": map[string]interface{}{
    59  //							"ForAllValues:StringEquals": map[string]interface{}{
    60  //								"oam:ResourceTypes": []string{
    61  //									"AWS::CloudWatch::Metric",
    62  //									"AWS::Logs::LogGroup",
    63  //								},
    64  //							},
    65  //						},
    66  //					},
    67  //				},
    68  //			})
    69  //			if err != nil {
    70  //				return err
    71  //			}
    72  //			json0 := string(tmpJSON0)
    73  //			_, err = oam.NewSinkPolicy(ctx, "example", &oam.SinkPolicyArgs{
    74  //				SinkIdentifier: example.ID(),
    75  //				Policy:         pulumi.String(json0),
    76  //			})
    77  //			if err != nil {
    78  //				return err
    79  //			}
    80  //			return nil
    81  //		})
    82  //	}
    83  //
    84  // ```
    85  // <!--End PulumiCodeChooser -->
    86  //
    87  // ## Import
    88  //
    89  // Using `pulumi import`, import CloudWatch Observability Access Manager Sink Policy using the `sink_identifier`. For example:
    90  //
    91  // ```sh
    92  // $ pulumi import aws:oam/sinkPolicy:SinkPolicy example arn:aws:oam:us-west-2:123456789012:sink/sink-id
    93  // ```
    94  type SinkPolicy struct {
    95  	pulumi.CustomResourceState
    96  
    97  	// ARN of the Sink.
    98  	Arn pulumi.StringOutput `pulumi:"arn"`
    99  	// JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
   100  	Policy pulumi.StringOutput `pulumi:"policy"`
   101  	// ID string that AWS generated as part of the sink ARN.
   102  	SinkId pulumi.StringOutput `pulumi:"sinkId"`
   103  	// ARN of the sink to attach this policy to.
   104  	SinkIdentifier pulumi.StringOutput `pulumi:"sinkIdentifier"`
   105  }
   106  
   107  // NewSinkPolicy registers a new resource with the given unique name, arguments, and options.
   108  func NewSinkPolicy(ctx *pulumi.Context,
   109  	name string, args *SinkPolicyArgs, opts ...pulumi.ResourceOption) (*SinkPolicy, error) {
   110  	if args == nil {
   111  		return nil, errors.New("missing one or more required arguments")
   112  	}
   113  
   114  	if args.Policy == nil {
   115  		return nil, errors.New("invalid value for required argument 'Policy'")
   116  	}
   117  	if args.SinkIdentifier == nil {
   118  		return nil, errors.New("invalid value for required argument 'SinkIdentifier'")
   119  	}
   120  	opts = internal.PkgResourceDefaultOpts(opts)
   121  	var resource SinkPolicy
   122  	err := ctx.RegisterResource("aws:oam/sinkPolicy:SinkPolicy", name, args, &resource, opts...)
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  	return &resource, nil
   127  }
   128  
   129  // GetSinkPolicy gets an existing SinkPolicy resource's state with the given name, ID, and optional
   130  // state properties that are used to uniquely qualify the lookup (nil if not required).
   131  func GetSinkPolicy(ctx *pulumi.Context,
   132  	name string, id pulumi.IDInput, state *SinkPolicyState, opts ...pulumi.ResourceOption) (*SinkPolicy, error) {
   133  	var resource SinkPolicy
   134  	err := ctx.ReadResource("aws:oam/sinkPolicy:SinkPolicy", name, id, state, &resource, opts...)
   135  	if err != nil {
   136  		return nil, err
   137  	}
   138  	return &resource, nil
   139  }
   140  
   141  // Input properties used for looking up and filtering SinkPolicy resources.
   142  type sinkPolicyState struct {
   143  	// ARN of the Sink.
   144  	Arn *string `pulumi:"arn"`
   145  	// JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
   146  	Policy *string `pulumi:"policy"`
   147  	// ID string that AWS generated as part of the sink ARN.
   148  	SinkId *string `pulumi:"sinkId"`
   149  	// ARN of the sink to attach this policy to.
   150  	SinkIdentifier *string `pulumi:"sinkIdentifier"`
   151  }
   152  
   153  type SinkPolicyState struct {
   154  	// ARN of the Sink.
   155  	Arn pulumi.StringPtrInput
   156  	// JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
   157  	Policy pulumi.StringPtrInput
   158  	// ID string that AWS generated as part of the sink ARN.
   159  	SinkId pulumi.StringPtrInput
   160  	// ARN of the sink to attach this policy to.
   161  	SinkIdentifier pulumi.StringPtrInput
   162  }
   163  
   164  func (SinkPolicyState) ElementType() reflect.Type {
   165  	return reflect.TypeOf((*sinkPolicyState)(nil)).Elem()
   166  }
   167  
   168  type sinkPolicyArgs struct {
   169  	// JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
   170  	Policy string `pulumi:"policy"`
   171  	// ARN of the sink to attach this policy to.
   172  	SinkIdentifier string `pulumi:"sinkIdentifier"`
   173  }
   174  
   175  // The set of arguments for constructing a SinkPolicy resource.
   176  type SinkPolicyArgs struct {
   177  	// JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
   178  	Policy pulumi.StringInput
   179  	// ARN of the sink to attach this policy to.
   180  	SinkIdentifier pulumi.StringInput
   181  }
   182  
   183  func (SinkPolicyArgs) ElementType() reflect.Type {
   184  	return reflect.TypeOf((*sinkPolicyArgs)(nil)).Elem()
   185  }
   186  
   187  type SinkPolicyInput interface {
   188  	pulumi.Input
   189  
   190  	ToSinkPolicyOutput() SinkPolicyOutput
   191  	ToSinkPolicyOutputWithContext(ctx context.Context) SinkPolicyOutput
   192  }
   193  
   194  func (*SinkPolicy) ElementType() reflect.Type {
   195  	return reflect.TypeOf((**SinkPolicy)(nil)).Elem()
   196  }
   197  
   198  func (i *SinkPolicy) ToSinkPolicyOutput() SinkPolicyOutput {
   199  	return i.ToSinkPolicyOutputWithContext(context.Background())
   200  }
   201  
   202  func (i *SinkPolicy) ToSinkPolicyOutputWithContext(ctx context.Context) SinkPolicyOutput {
   203  	return pulumi.ToOutputWithContext(ctx, i).(SinkPolicyOutput)
   204  }
   205  
   206  // SinkPolicyArrayInput is an input type that accepts SinkPolicyArray and SinkPolicyArrayOutput values.
   207  // You can construct a concrete instance of `SinkPolicyArrayInput` via:
   208  //
   209  //	SinkPolicyArray{ SinkPolicyArgs{...} }
   210  type SinkPolicyArrayInput interface {
   211  	pulumi.Input
   212  
   213  	ToSinkPolicyArrayOutput() SinkPolicyArrayOutput
   214  	ToSinkPolicyArrayOutputWithContext(context.Context) SinkPolicyArrayOutput
   215  }
   216  
   217  type SinkPolicyArray []SinkPolicyInput
   218  
   219  func (SinkPolicyArray) ElementType() reflect.Type {
   220  	return reflect.TypeOf((*[]*SinkPolicy)(nil)).Elem()
   221  }
   222  
   223  func (i SinkPolicyArray) ToSinkPolicyArrayOutput() SinkPolicyArrayOutput {
   224  	return i.ToSinkPolicyArrayOutputWithContext(context.Background())
   225  }
   226  
   227  func (i SinkPolicyArray) ToSinkPolicyArrayOutputWithContext(ctx context.Context) SinkPolicyArrayOutput {
   228  	return pulumi.ToOutputWithContext(ctx, i).(SinkPolicyArrayOutput)
   229  }
   230  
   231  // SinkPolicyMapInput is an input type that accepts SinkPolicyMap and SinkPolicyMapOutput values.
   232  // You can construct a concrete instance of `SinkPolicyMapInput` via:
   233  //
   234  //	SinkPolicyMap{ "key": SinkPolicyArgs{...} }
   235  type SinkPolicyMapInput interface {
   236  	pulumi.Input
   237  
   238  	ToSinkPolicyMapOutput() SinkPolicyMapOutput
   239  	ToSinkPolicyMapOutputWithContext(context.Context) SinkPolicyMapOutput
   240  }
   241  
   242  type SinkPolicyMap map[string]SinkPolicyInput
   243  
   244  func (SinkPolicyMap) ElementType() reflect.Type {
   245  	return reflect.TypeOf((*map[string]*SinkPolicy)(nil)).Elem()
   246  }
   247  
   248  func (i SinkPolicyMap) ToSinkPolicyMapOutput() SinkPolicyMapOutput {
   249  	return i.ToSinkPolicyMapOutputWithContext(context.Background())
   250  }
   251  
   252  func (i SinkPolicyMap) ToSinkPolicyMapOutputWithContext(ctx context.Context) SinkPolicyMapOutput {
   253  	return pulumi.ToOutputWithContext(ctx, i).(SinkPolicyMapOutput)
   254  }
   255  
   256  type SinkPolicyOutput struct{ *pulumi.OutputState }
   257  
   258  func (SinkPolicyOutput) ElementType() reflect.Type {
   259  	return reflect.TypeOf((**SinkPolicy)(nil)).Elem()
   260  }
   261  
   262  func (o SinkPolicyOutput) ToSinkPolicyOutput() SinkPolicyOutput {
   263  	return o
   264  }
   265  
   266  func (o SinkPolicyOutput) ToSinkPolicyOutputWithContext(ctx context.Context) SinkPolicyOutput {
   267  	return o
   268  }
   269  
   270  // ARN of the Sink.
   271  func (o SinkPolicyOutput) Arn() pulumi.StringOutput {
   272  	return o.ApplyT(func(v *SinkPolicy) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   273  }
   274  
   275  // JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
   276  func (o SinkPolicyOutput) Policy() pulumi.StringOutput {
   277  	return o.ApplyT(func(v *SinkPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   278  }
   279  
   280  // ID string that AWS generated as part of the sink ARN.
   281  func (o SinkPolicyOutput) SinkId() pulumi.StringOutput {
   282  	return o.ApplyT(func(v *SinkPolicy) pulumi.StringOutput { return v.SinkId }).(pulumi.StringOutput)
   283  }
   284  
   285  // ARN of the sink to attach this policy to.
   286  func (o SinkPolicyOutput) SinkIdentifier() pulumi.StringOutput {
   287  	return o.ApplyT(func(v *SinkPolicy) pulumi.StringOutput { return v.SinkIdentifier }).(pulumi.StringOutput)
   288  }
   289  
   290  type SinkPolicyArrayOutput struct{ *pulumi.OutputState }
   291  
   292  func (SinkPolicyArrayOutput) ElementType() reflect.Type {
   293  	return reflect.TypeOf((*[]*SinkPolicy)(nil)).Elem()
   294  }
   295  
   296  func (o SinkPolicyArrayOutput) ToSinkPolicyArrayOutput() SinkPolicyArrayOutput {
   297  	return o
   298  }
   299  
   300  func (o SinkPolicyArrayOutput) ToSinkPolicyArrayOutputWithContext(ctx context.Context) SinkPolicyArrayOutput {
   301  	return o
   302  }
   303  
   304  func (o SinkPolicyArrayOutput) Index(i pulumi.IntInput) SinkPolicyOutput {
   305  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SinkPolicy {
   306  		return vs[0].([]*SinkPolicy)[vs[1].(int)]
   307  	}).(SinkPolicyOutput)
   308  }
   309  
   310  type SinkPolicyMapOutput struct{ *pulumi.OutputState }
   311  
   312  func (SinkPolicyMapOutput) ElementType() reflect.Type {
   313  	return reflect.TypeOf((*map[string]*SinkPolicy)(nil)).Elem()
   314  }
   315  
   316  func (o SinkPolicyMapOutput) ToSinkPolicyMapOutput() SinkPolicyMapOutput {
   317  	return o
   318  }
   319  
   320  func (o SinkPolicyMapOutput) ToSinkPolicyMapOutputWithContext(ctx context.Context) SinkPolicyMapOutput {
   321  	return o
   322  }
   323  
   324  func (o SinkPolicyMapOutput) MapIndex(k pulumi.StringInput) SinkPolicyOutput {
   325  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SinkPolicy {
   326  		return vs[0].(map[string]*SinkPolicy)[vs[1].(string)]
   327  	}).(SinkPolicyOutput)
   328  }
   329  
   330  func init() {
   331  	pulumi.RegisterInputType(reflect.TypeOf((*SinkPolicyInput)(nil)).Elem(), &SinkPolicy{})
   332  	pulumi.RegisterInputType(reflect.TypeOf((*SinkPolicyArrayInput)(nil)).Elem(), SinkPolicyArray{})
   333  	pulumi.RegisterInputType(reflect.TypeOf((*SinkPolicyMapInput)(nil)).Elem(), SinkPolicyMap{})
   334  	pulumi.RegisterOutputType(SinkPolicyOutput{})
   335  	pulumi.RegisterOutputType(SinkPolicyArrayOutput{})
   336  	pulumi.RegisterOutputType(SinkPolicyMapOutput{})
   337  }