github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/redshift/resourcePolicy.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 redshift
     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  // Creates a new Amazon Redshift Resource Policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"encoding/json"
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/redshift"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    35  //				"Version": "2012-10-17",
    36  //				"Statement": []map[string]interface{}{
    37  //					map[string]interface{}{
    38  //						"Effect": "Allow",
    39  //						"Principal": map[string]interface{}{
    40  //							"AWS": "arn:aws:iam::12345678901:root",
    41  //						},
    42  //						"Action":   "redshift:CreateInboundIntegration",
    43  //						"Resource": exampleAwsRedshiftCluster.ClusterNamespaceArn,
    44  //						"Sid":      "",
    45  //					},
    46  //				},
    47  //			})
    48  //			if err != nil {
    49  //				return err
    50  //			}
    51  //			json0 := string(tmpJSON0)
    52  //			_, err = redshift.NewResourcePolicy(ctx, "example", &redshift.ResourcePolicyArgs{
    53  //				ResourceArn: pulumi.Any(exampleAwsRedshiftCluster.ClusterNamespaceArn),
    54  //				Policy:      pulumi.String(json0),
    55  //			})
    56  //			if err != nil {
    57  //				return err
    58  //			}
    59  //			return nil
    60  //		})
    61  //	}
    62  //
    63  // ```
    64  // <!--End PulumiCodeChooser -->
    65  //
    66  // ## Import
    67  //
    68  // Using `pulumi import`, import Redshift Resource Policies using the `resource_arn`. For example:
    69  //
    70  // ```sh
    71  // $ pulumi import aws:redshift/resourcePolicy:ResourcePolicy example example
    72  // ```
    73  type ResourcePolicy struct {
    74  	pulumi.CustomResourceState
    75  
    76  	// The content of the resource policy being updated.
    77  	Policy pulumi.StringOutput `pulumi:"policy"`
    78  	// The Amazon Resource Name (ARN) of the account to create or update a resource policy for.
    79  	ResourceArn pulumi.StringOutput `pulumi:"resourceArn"`
    80  }
    81  
    82  // NewResourcePolicy registers a new resource with the given unique name, arguments, and options.
    83  func NewResourcePolicy(ctx *pulumi.Context,
    84  	name string, args *ResourcePolicyArgs, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
    85  	if args == nil {
    86  		return nil, errors.New("missing one or more required arguments")
    87  	}
    88  
    89  	if args.Policy == nil {
    90  		return nil, errors.New("invalid value for required argument 'Policy'")
    91  	}
    92  	if args.ResourceArn == nil {
    93  		return nil, errors.New("invalid value for required argument 'ResourceArn'")
    94  	}
    95  	opts = internal.PkgResourceDefaultOpts(opts)
    96  	var resource ResourcePolicy
    97  	err := ctx.RegisterResource("aws:redshift/resourcePolicy:ResourcePolicy", name, args, &resource, opts...)
    98  	if err != nil {
    99  		return nil, err
   100  	}
   101  	return &resource, nil
   102  }
   103  
   104  // GetResourcePolicy gets an existing ResourcePolicy resource's state with the given name, ID, and optional
   105  // state properties that are used to uniquely qualify the lookup (nil if not required).
   106  func GetResourcePolicy(ctx *pulumi.Context,
   107  	name string, id pulumi.IDInput, state *ResourcePolicyState, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
   108  	var resource ResourcePolicy
   109  	err := ctx.ReadResource("aws:redshift/resourcePolicy:ResourcePolicy", name, id, state, &resource, opts...)
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  	return &resource, nil
   114  }
   115  
   116  // Input properties used for looking up and filtering ResourcePolicy resources.
   117  type resourcePolicyState struct {
   118  	// The content of the resource policy being updated.
   119  	Policy *string `pulumi:"policy"`
   120  	// The Amazon Resource Name (ARN) of the account to create or update a resource policy for.
   121  	ResourceArn *string `pulumi:"resourceArn"`
   122  }
   123  
   124  type ResourcePolicyState struct {
   125  	// The content of the resource policy being updated.
   126  	Policy pulumi.StringPtrInput
   127  	// The Amazon Resource Name (ARN) of the account to create or update a resource policy for.
   128  	ResourceArn pulumi.StringPtrInput
   129  }
   130  
   131  func (ResourcePolicyState) ElementType() reflect.Type {
   132  	return reflect.TypeOf((*resourcePolicyState)(nil)).Elem()
   133  }
   134  
   135  type resourcePolicyArgs struct {
   136  	// The content of the resource policy being updated.
   137  	Policy string `pulumi:"policy"`
   138  	// The Amazon Resource Name (ARN) of the account to create or update a resource policy for.
   139  	ResourceArn string `pulumi:"resourceArn"`
   140  }
   141  
   142  // The set of arguments for constructing a ResourcePolicy resource.
   143  type ResourcePolicyArgs struct {
   144  	// The content of the resource policy being updated.
   145  	Policy pulumi.StringInput
   146  	// The Amazon Resource Name (ARN) of the account to create or update a resource policy for.
   147  	ResourceArn pulumi.StringInput
   148  }
   149  
   150  func (ResourcePolicyArgs) ElementType() reflect.Type {
   151  	return reflect.TypeOf((*resourcePolicyArgs)(nil)).Elem()
   152  }
   153  
   154  type ResourcePolicyInput interface {
   155  	pulumi.Input
   156  
   157  	ToResourcePolicyOutput() ResourcePolicyOutput
   158  	ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput
   159  }
   160  
   161  func (*ResourcePolicy) ElementType() reflect.Type {
   162  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   163  }
   164  
   165  func (i *ResourcePolicy) ToResourcePolicyOutput() ResourcePolicyOutput {
   166  	return i.ToResourcePolicyOutputWithContext(context.Background())
   167  }
   168  
   169  func (i *ResourcePolicy) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   170  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyOutput)
   171  }
   172  
   173  // ResourcePolicyArrayInput is an input type that accepts ResourcePolicyArray and ResourcePolicyArrayOutput values.
   174  // You can construct a concrete instance of `ResourcePolicyArrayInput` via:
   175  //
   176  //	ResourcePolicyArray{ ResourcePolicyArgs{...} }
   177  type ResourcePolicyArrayInput interface {
   178  	pulumi.Input
   179  
   180  	ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput
   181  	ToResourcePolicyArrayOutputWithContext(context.Context) ResourcePolicyArrayOutput
   182  }
   183  
   184  type ResourcePolicyArray []ResourcePolicyInput
   185  
   186  func (ResourcePolicyArray) ElementType() reflect.Type {
   187  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   188  }
   189  
   190  func (i ResourcePolicyArray) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   191  	return i.ToResourcePolicyArrayOutputWithContext(context.Background())
   192  }
   193  
   194  func (i ResourcePolicyArray) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   195  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyArrayOutput)
   196  }
   197  
   198  // ResourcePolicyMapInput is an input type that accepts ResourcePolicyMap and ResourcePolicyMapOutput values.
   199  // You can construct a concrete instance of `ResourcePolicyMapInput` via:
   200  //
   201  //	ResourcePolicyMap{ "key": ResourcePolicyArgs{...} }
   202  type ResourcePolicyMapInput interface {
   203  	pulumi.Input
   204  
   205  	ToResourcePolicyMapOutput() ResourcePolicyMapOutput
   206  	ToResourcePolicyMapOutputWithContext(context.Context) ResourcePolicyMapOutput
   207  }
   208  
   209  type ResourcePolicyMap map[string]ResourcePolicyInput
   210  
   211  func (ResourcePolicyMap) ElementType() reflect.Type {
   212  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   213  }
   214  
   215  func (i ResourcePolicyMap) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   216  	return i.ToResourcePolicyMapOutputWithContext(context.Background())
   217  }
   218  
   219  func (i ResourcePolicyMap) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   220  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyMapOutput)
   221  }
   222  
   223  type ResourcePolicyOutput struct{ *pulumi.OutputState }
   224  
   225  func (ResourcePolicyOutput) ElementType() reflect.Type {
   226  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   227  }
   228  
   229  func (o ResourcePolicyOutput) ToResourcePolicyOutput() ResourcePolicyOutput {
   230  	return o
   231  }
   232  
   233  func (o ResourcePolicyOutput) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   234  	return o
   235  }
   236  
   237  // The content of the resource policy being updated.
   238  func (o ResourcePolicyOutput) Policy() pulumi.StringOutput {
   239  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   240  }
   241  
   242  // The Amazon Resource Name (ARN) of the account to create or update a resource policy for.
   243  func (o ResourcePolicyOutput) ResourceArn() pulumi.StringOutput {
   244  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput)
   245  }
   246  
   247  type ResourcePolicyArrayOutput struct{ *pulumi.OutputState }
   248  
   249  func (ResourcePolicyArrayOutput) ElementType() reflect.Type {
   250  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   251  }
   252  
   253  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   254  	return o
   255  }
   256  
   257  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   258  	return o
   259  }
   260  
   261  func (o ResourcePolicyArrayOutput) Index(i pulumi.IntInput) ResourcePolicyOutput {
   262  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ResourcePolicy {
   263  		return vs[0].([]*ResourcePolicy)[vs[1].(int)]
   264  	}).(ResourcePolicyOutput)
   265  }
   266  
   267  type ResourcePolicyMapOutput struct{ *pulumi.OutputState }
   268  
   269  func (ResourcePolicyMapOutput) ElementType() reflect.Type {
   270  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   271  }
   272  
   273  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   274  	return o
   275  }
   276  
   277  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   278  	return o
   279  }
   280  
   281  func (o ResourcePolicyMapOutput) MapIndex(k pulumi.StringInput) ResourcePolicyOutput {
   282  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ResourcePolicy {
   283  		return vs[0].(map[string]*ResourcePolicy)[vs[1].(string)]
   284  	}).(ResourcePolicyOutput)
   285  }
   286  
   287  func init() {
   288  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyInput)(nil)).Elem(), &ResourcePolicy{})
   289  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyArrayInput)(nil)).Elem(), ResourcePolicyArray{})
   290  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyMapInput)(nil)).Elem(), ResourcePolicyMap{})
   291  	pulumi.RegisterOutputType(ResourcePolicyOutput{})
   292  	pulumi.RegisterOutputType(ResourcePolicyArrayOutput{})
   293  	pulumi.RegisterOutputType(ResourcePolicyMapOutput{})
   294  }