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