github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/dynamodb/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 dynamodb
     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 DynamoDB Resource Policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := dynamodb.NewResourcePolicy(ctx, "example", &dynamodb.ResourcePolicyArgs{
    35  //				ResourceArn: pulumi.Any(exampleAwsDynamodbTable.Arn),
    36  //				Policy:      pulumi.Any(test.Json),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			return nil
    42  //		})
    43  //	}
    44  //
    45  // ```
    46  // <!--End PulumiCodeChooser -->
    47  //
    48  // ## Import
    49  //
    50  // Using `pulumi import`, import DynamoDB Resource Policy using the `example_id_arg`. For example:
    51  //
    52  // ```sh
    53  // $ pulumi import aws:dynamodb/resourcePolicy:ResourcePolicy example arn:aws:dynamodb:us-east-1:1234567890:table/my-table
    54  // ```
    55  type ResourcePolicy struct {
    56  	pulumi.CustomResourceState
    57  
    58  	// Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future.
    59  	ConfirmRemoveSelfResourceAccess pulumi.BoolOutput `pulumi:"confirmRemoveSelfResourceAccess"`
    60  	// n Amazon Web Services resource-based policy document in JSON format. The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that you should keep in mind while attaching a resource-based policy, see Resource-based policy considerations.
    61  	//
    62  	// The following arguments are optional:
    63  	Policy pulumi.StringOutput `pulumi:"policy"`
    64  	// The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams. You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the Resource field of a given Statement in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple Statement fields in your policy document.
    65  	ResourceArn pulumi.StringOutput `pulumi:"resourceArn"`
    66  	// A unique string that represents the revision ID of the policy. If you are comparing revision IDs, make sure to always use string comparison logic.
    67  	RevisionId pulumi.StringOutput `pulumi:"revisionId"`
    68  }
    69  
    70  // NewResourcePolicy registers a new resource with the given unique name, arguments, and options.
    71  func NewResourcePolicy(ctx *pulumi.Context,
    72  	name string, args *ResourcePolicyArgs, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
    73  	if args == nil {
    74  		return nil, errors.New("missing one or more required arguments")
    75  	}
    76  
    77  	if args.Policy == nil {
    78  		return nil, errors.New("invalid value for required argument 'Policy'")
    79  	}
    80  	if args.ResourceArn == nil {
    81  		return nil, errors.New("invalid value for required argument 'ResourceArn'")
    82  	}
    83  	opts = internal.PkgResourceDefaultOpts(opts)
    84  	var resource ResourcePolicy
    85  	err := ctx.RegisterResource("aws:dynamodb/resourcePolicy:ResourcePolicy", name, args, &resource, opts...)
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  	return &resource, nil
    90  }
    91  
    92  // GetResourcePolicy gets an existing ResourcePolicy resource's state with the given name, ID, and optional
    93  // state properties that are used to uniquely qualify the lookup (nil if not required).
    94  func GetResourcePolicy(ctx *pulumi.Context,
    95  	name string, id pulumi.IDInput, state *ResourcePolicyState, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
    96  	var resource ResourcePolicy
    97  	err := ctx.ReadResource("aws:dynamodb/resourcePolicy:ResourcePolicy", name, id, state, &resource, opts...)
    98  	if err != nil {
    99  		return nil, err
   100  	}
   101  	return &resource, nil
   102  }
   103  
   104  // Input properties used for looking up and filtering ResourcePolicy resources.
   105  type resourcePolicyState struct {
   106  	// Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future.
   107  	ConfirmRemoveSelfResourceAccess *bool `pulumi:"confirmRemoveSelfResourceAccess"`
   108  	// n Amazon Web Services resource-based policy document in JSON format. The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that you should keep in mind while attaching a resource-based policy, see Resource-based policy considerations.
   109  	//
   110  	// The following arguments are optional:
   111  	Policy *string `pulumi:"policy"`
   112  	// The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams. You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the Resource field of a given Statement in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple Statement fields in your policy document.
   113  	ResourceArn *string `pulumi:"resourceArn"`
   114  	// A unique string that represents the revision ID of the policy. If you are comparing revision IDs, make sure to always use string comparison logic.
   115  	RevisionId *string `pulumi:"revisionId"`
   116  }
   117  
   118  type ResourcePolicyState struct {
   119  	// Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future.
   120  	ConfirmRemoveSelfResourceAccess pulumi.BoolPtrInput
   121  	// n Amazon Web Services resource-based policy document in JSON format. The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that you should keep in mind while attaching a resource-based policy, see Resource-based policy considerations.
   122  	//
   123  	// The following arguments are optional:
   124  	Policy pulumi.StringPtrInput
   125  	// The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams. You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the Resource field of a given Statement in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple Statement fields in your policy document.
   126  	ResourceArn pulumi.StringPtrInput
   127  	// A unique string that represents the revision ID of the policy. If you are comparing revision IDs, make sure to always use string comparison logic.
   128  	RevisionId pulumi.StringPtrInput
   129  }
   130  
   131  func (ResourcePolicyState) ElementType() reflect.Type {
   132  	return reflect.TypeOf((*resourcePolicyState)(nil)).Elem()
   133  }
   134  
   135  type resourcePolicyArgs struct {
   136  	// Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future.
   137  	ConfirmRemoveSelfResourceAccess *bool `pulumi:"confirmRemoveSelfResourceAccess"`
   138  	// n Amazon Web Services resource-based policy document in JSON format. The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that you should keep in mind while attaching a resource-based policy, see Resource-based policy considerations.
   139  	//
   140  	// The following arguments are optional:
   141  	Policy string `pulumi:"policy"`
   142  	// The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams. You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the Resource field of a given Statement in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple Statement fields in your policy document.
   143  	ResourceArn string `pulumi:"resourceArn"`
   144  }
   145  
   146  // The set of arguments for constructing a ResourcePolicy resource.
   147  type ResourcePolicyArgs struct {
   148  	// Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future.
   149  	ConfirmRemoveSelfResourceAccess pulumi.BoolPtrInput
   150  	// n Amazon Web Services resource-based policy document in JSON format. The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that you should keep in mind while attaching a resource-based policy, see Resource-based policy considerations.
   151  	//
   152  	// The following arguments are optional:
   153  	Policy pulumi.StringInput
   154  	// The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams. You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the Resource field of a given Statement in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple Statement fields in your policy document.
   155  	ResourceArn pulumi.StringInput
   156  }
   157  
   158  func (ResourcePolicyArgs) ElementType() reflect.Type {
   159  	return reflect.TypeOf((*resourcePolicyArgs)(nil)).Elem()
   160  }
   161  
   162  type ResourcePolicyInput interface {
   163  	pulumi.Input
   164  
   165  	ToResourcePolicyOutput() ResourcePolicyOutput
   166  	ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput
   167  }
   168  
   169  func (*ResourcePolicy) ElementType() reflect.Type {
   170  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   171  }
   172  
   173  func (i *ResourcePolicy) ToResourcePolicyOutput() ResourcePolicyOutput {
   174  	return i.ToResourcePolicyOutputWithContext(context.Background())
   175  }
   176  
   177  func (i *ResourcePolicy) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   178  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyOutput)
   179  }
   180  
   181  // ResourcePolicyArrayInput is an input type that accepts ResourcePolicyArray and ResourcePolicyArrayOutput values.
   182  // You can construct a concrete instance of `ResourcePolicyArrayInput` via:
   183  //
   184  //	ResourcePolicyArray{ ResourcePolicyArgs{...} }
   185  type ResourcePolicyArrayInput interface {
   186  	pulumi.Input
   187  
   188  	ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput
   189  	ToResourcePolicyArrayOutputWithContext(context.Context) ResourcePolicyArrayOutput
   190  }
   191  
   192  type ResourcePolicyArray []ResourcePolicyInput
   193  
   194  func (ResourcePolicyArray) ElementType() reflect.Type {
   195  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   196  }
   197  
   198  func (i ResourcePolicyArray) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   199  	return i.ToResourcePolicyArrayOutputWithContext(context.Background())
   200  }
   201  
   202  func (i ResourcePolicyArray) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   203  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyArrayOutput)
   204  }
   205  
   206  // ResourcePolicyMapInput is an input type that accepts ResourcePolicyMap and ResourcePolicyMapOutput values.
   207  // You can construct a concrete instance of `ResourcePolicyMapInput` via:
   208  //
   209  //	ResourcePolicyMap{ "key": ResourcePolicyArgs{...} }
   210  type ResourcePolicyMapInput interface {
   211  	pulumi.Input
   212  
   213  	ToResourcePolicyMapOutput() ResourcePolicyMapOutput
   214  	ToResourcePolicyMapOutputWithContext(context.Context) ResourcePolicyMapOutput
   215  }
   216  
   217  type ResourcePolicyMap map[string]ResourcePolicyInput
   218  
   219  func (ResourcePolicyMap) ElementType() reflect.Type {
   220  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   221  }
   222  
   223  func (i ResourcePolicyMap) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   224  	return i.ToResourcePolicyMapOutputWithContext(context.Background())
   225  }
   226  
   227  func (i ResourcePolicyMap) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   228  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyMapOutput)
   229  }
   230  
   231  type ResourcePolicyOutput struct{ *pulumi.OutputState }
   232  
   233  func (ResourcePolicyOutput) ElementType() reflect.Type {
   234  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   235  }
   236  
   237  func (o ResourcePolicyOutput) ToResourcePolicyOutput() ResourcePolicyOutput {
   238  	return o
   239  }
   240  
   241  func (o ResourcePolicyOutput) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   242  	return o
   243  }
   244  
   245  // Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future.
   246  func (o ResourcePolicyOutput) ConfirmRemoveSelfResourceAccess() pulumi.BoolOutput {
   247  	return o.ApplyT(func(v *ResourcePolicy) pulumi.BoolOutput { return v.ConfirmRemoveSelfResourceAccess }).(pulumi.BoolOutput)
   248  }
   249  
   250  // n Amazon Web Services resource-based policy document in JSON format. The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that you should keep in mind while attaching a resource-based policy, see Resource-based policy considerations.
   251  //
   252  // The following arguments are optional:
   253  func (o ResourcePolicyOutput) Policy() pulumi.StringOutput {
   254  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   255  }
   256  
   257  // The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams. You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the Resource field of a given Statement in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple Statement fields in your policy document.
   258  func (o ResourcePolicyOutput) ResourceArn() pulumi.StringOutput {
   259  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput)
   260  }
   261  
   262  // A unique string that represents the revision ID of the policy. If you are comparing revision IDs, make sure to always use string comparison logic.
   263  func (o ResourcePolicyOutput) RevisionId() pulumi.StringOutput {
   264  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.RevisionId }).(pulumi.StringOutput)
   265  }
   266  
   267  type ResourcePolicyArrayOutput struct{ *pulumi.OutputState }
   268  
   269  func (ResourcePolicyArrayOutput) ElementType() reflect.Type {
   270  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   271  }
   272  
   273  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   274  	return o
   275  }
   276  
   277  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   278  	return o
   279  }
   280  
   281  func (o ResourcePolicyArrayOutput) Index(i pulumi.IntInput) ResourcePolicyOutput {
   282  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ResourcePolicy {
   283  		return vs[0].([]*ResourcePolicy)[vs[1].(int)]
   284  	}).(ResourcePolicyOutput)
   285  }
   286  
   287  type ResourcePolicyMapOutput struct{ *pulumi.OutputState }
   288  
   289  func (ResourcePolicyMapOutput) ElementType() reflect.Type {
   290  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   291  }
   292  
   293  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   294  	return o
   295  }
   296  
   297  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   298  	return o
   299  }
   300  
   301  func (o ResourcePolicyMapOutput) MapIndex(k pulumi.StringInput) ResourcePolicyOutput {
   302  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ResourcePolicy {
   303  		return vs[0].(map[string]*ResourcePolicy)[vs[1].(string)]
   304  	}).(ResourcePolicyOutput)
   305  }
   306  
   307  func init() {
   308  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyInput)(nil)).Elem(), &ResourcePolicy{})
   309  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyArrayInput)(nil)).Elem(), ResourcePolicyArray{})
   310  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyMapInput)(nil)).Elem(), ResourcePolicyMap{})
   311  	pulumi.RegisterOutputType(ResourcePolicyOutput{})
   312  	pulumi.RegisterOutputType(ResourcePolicyArrayOutput{})
   313  	pulumi.RegisterOutputType(ResourcePolicyMapOutput{})
   314  }