github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3control/accessPointPolicy.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 s3control
     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 resource to manage an S3 Access Point resource policy.
    16  //
    17  // > **NOTE on Access Points and Access Point Policies:** The provider provides both a standalone Access Point Policy resource and an Access Point resource with a resource policy defined in-line. You cannot use an Access Point with in-line resource policy in conjunction with an Access Point Policy resource. Doing so will cause a conflict of policies and will overwrite the access point's resource policy.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"encoding/json"
    28  //	"fmt"
    29  //
    30  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3control"
    32  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    33  //
    34  // )
    35  //
    36  //	func main() {
    37  //		pulumi.Run(func(ctx *pulumi.Context) error {
    38  //			example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
    39  //				Bucket: pulumi.String("example"),
    40  //			})
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			exampleAccessPoint, err := s3.NewAccessPoint(ctx, "example", &s3.AccessPointArgs{
    45  //				Bucket: example.ID(),
    46  //				Name:   pulumi.String("example"),
    47  //				PublicAccessBlockConfiguration: &s3.AccessPointPublicAccessBlockConfigurationArgs{
    48  //					BlockPublicAcls:       pulumi.Bool(true),
    49  //					BlockPublicPolicy:     pulumi.Bool(false),
    50  //					IgnorePublicAcls:      pulumi.Bool(true),
    51  //					RestrictPublicBuckets: pulumi.Bool(false),
    52  //				},
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			_, err = s3control.NewAccessPointPolicy(ctx, "example", &s3control.AccessPointPolicyArgs{
    58  //				AccessPointArn: exampleAccessPoint.Arn,
    59  //				Policy: exampleAccessPoint.Arn.ApplyT(func(arn string) (pulumi.String, error) {
    60  //					var _zero pulumi.String
    61  //					tmpJSON0, err := json.Marshal(map[string]interface{}{
    62  //						"Version": "2008-10-17",
    63  //						"Statement": []map[string]interface{}{
    64  //							map[string]interface{}{
    65  //								"Effect": "Allow",
    66  //								"Action": "s3:GetObjectTagging",
    67  //								"Principal": map[string]interface{}{
    68  //									"AWS": "*",
    69  //								},
    70  //								"Resource": fmt.Sprintf("%v/object/*", arn),
    71  //							},
    72  //						},
    73  //					})
    74  //					if err != nil {
    75  //						return _zero, err
    76  //					}
    77  //					json0 := string(tmpJSON0)
    78  //					return pulumi.String(json0), nil
    79  //				}).(pulumi.StringOutput),
    80  //			})
    81  //			if err != nil {
    82  //				return err
    83  //			}
    84  //			return nil
    85  //		})
    86  //	}
    87  //
    88  // ```
    89  // <!--End PulumiCodeChooser -->
    90  //
    91  // ## Import
    92  //
    93  // Using `pulumi import`, import Access Point policies using the `access_point_arn`. For example:
    94  //
    95  // ```sh
    96  // $ pulumi import aws:s3control/accessPointPolicy:AccessPointPolicy example arn:aws:s3:us-west-2:123456789012:accesspoint/example
    97  // ```
    98  type AccessPointPolicy struct {
    99  	pulumi.CustomResourceState
   100  
   101  	// The ARN of the access point that you want to associate with the specified policy.
   102  	AccessPointArn pulumi.StringOutput `pulumi:"accessPointArn"`
   103  	// Indicates whether this access point currently has a policy that allows public access.
   104  	HasPublicAccessPolicy pulumi.BoolOutput `pulumi:"hasPublicAccessPolicy"`
   105  	// The policy that you want to apply to the specified access point.
   106  	Policy pulumi.StringOutput `pulumi:"policy"`
   107  }
   108  
   109  // NewAccessPointPolicy registers a new resource with the given unique name, arguments, and options.
   110  func NewAccessPointPolicy(ctx *pulumi.Context,
   111  	name string, args *AccessPointPolicyArgs, opts ...pulumi.ResourceOption) (*AccessPointPolicy, error) {
   112  	if args == nil {
   113  		return nil, errors.New("missing one or more required arguments")
   114  	}
   115  
   116  	if args.AccessPointArn == nil {
   117  		return nil, errors.New("invalid value for required argument 'AccessPointArn'")
   118  	}
   119  	if args.Policy == nil {
   120  		return nil, errors.New("invalid value for required argument 'Policy'")
   121  	}
   122  	opts = internal.PkgResourceDefaultOpts(opts)
   123  	var resource AccessPointPolicy
   124  	err := ctx.RegisterResource("aws:s3control/accessPointPolicy:AccessPointPolicy", name, args, &resource, opts...)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	return &resource, nil
   129  }
   130  
   131  // GetAccessPointPolicy gets an existing AccessPointPolicy resource's state with the given name, ID, and optional
   132  // state properties that are used to uniquely qualify the lookup (nil if not required).
   133  func GetAccessPointPolicy(ctx *pulumi.Context,
   134  	name string, id pulumi.IDInput, state *AccessPointPolicyState, opts ...pulumi.ResourceOption) (*AccessPointPolicy, error) {
   135  	var resource AccessPointPolicy
   136  	err := ctx.ReadResource("aws:s3control/accessPointPolicy:AccessPointPolicy", name, id, state, &resource, opts...)
   137  	if err != nil {
   138  		return nil, err
   139  	}
   140  	return &resource, nil
   141  }
   142  
   143  // Input properties used for looking up and filtering AccessPointPolicy resources.
   144  type accessPointPolicyState struct {
   145  	// The ARN of the access point that you want to associate with the specified policy.
   146  	AccessPointArn *string `pulumi:"accessPointArn"`
   147  	// Indicates whether this access point currently has a policy that allows public access.
   148  	HasPublicAccessPolicy *bool `pulumi:"hasPublicAccessPolicy"`
   149  	// The policy that you want to apply to the specified access point.
   150  	Policy *string `pulumi:"policy"`
   151  }
   152  
   153  type AccessPointPolicyState struct {
   154  	// The ARN of the access point that you want to associate with the specified policy.
   155  	AccessPointArn pulumi.StringPtrInput
   156  	// Indicates whether this access point currently has a policy that allows public access.
   157  	HasPublicAccessPolicy pulumi.BoolPtrInput
   158  	// The policy that you want to apply to the specified access point.
   159  	Policy pulumi.StringPtrInput
   160  }
   161  
   162  func (AccessPointPolicyState) ElementType() reflect.Type {
   163  	return reflect.TypeOf((*accessPointPolicyState)(nil)).Elem()
   164  }
   165  
   166  type accessPointPolicyArgs struct {
   167  	// The ARN of the access point that you want to associate with the specified policy.
   168  	AccessPointArn string `pulumi:"accessPointArn"`
   169  	// The policy that you want to apply to the specified access point.
   170  	Policy string `pulumi:"policy"`
   171  }
   172  
   173  // The set of arguments for constructing a AccessPointPolicy resource.
   174  type AccessPointPolicyArgs struct {
   175  	// The ARN of the access point that you want to associate with the specified policy.
   176  	AccessPointArn pulumi.StringInput
   177  	// The policy that you want to apply to the specified access point.
   178  	Policy pulumi.StringInput
   179  }
   180  
   181  func (AccessPointPolicyArgs) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*accessPointPolicyArgs)(nil)).Elem()
   183  }
   184  
   185  type AccessPointPolicyInput interface {
   186  	pulumi.Input
   187  
   188  	ToAccessPointPolicyOutput() AccessPointPolicyOutput
   189  	ToAccessPointPolicyOutputWithContext(ctx context.Context) AccessPointPolicyOutput
   190  }
   191  
   192  func (*AccessPointPolicy) ElementType() reflect.Type {
   193  	return reflect.TypeOf((**AccessPointPolicy)(nil)).Elem()
   194  }
   195  
   196  func (i *AccessPointPolicy) ToAccessPointPolicyOutput() AccessPointPolicyOutput {
   197  	return i.ToAccessPointPolicyOutputWithContext(context.Background())
   198  }
   199  
   200  func (i *AccessPointPolicy) ToAccessPointPolicyOutputWithContext(ctx context.Context) AccessPointPolicyOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(AccessPointPolicyOutput)
   202  }
   203  
   204  // AccessPointPolicyArrayInput is an input type that accepts AccessPointPolicyArray and AccessPointPolicyArrayOutput values.
   205  // You can construct a concrete instance of `AccessPointPolicyArrayInput` via:
   206  //
   207  //	AccessPointPolicyArray{ AccessPointPolicyArgs{...} }
   208  type AccessPointPolicyArrayInput interface {
   209  	pulumi.Input
   210  
   211  	ToAccessPointPolicyArrayOutput() AccessPointPolicyArrayOutput
   212  	ToAccessPointPolicyArrayOutputWithContext(context.Context) AccessPointPolicyArrayOutput
   213  }
   214  
   215  type AccessPointPolicyArray []AccessPointPolicyInput
   216  
   217  func (AccessPointPolicyArray) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*[]*AccessPointPolicy)(nil)).Elem()
   219  }
   220  
   221  func (i AccessPointPolicyArray) ToAccessPointPolicyArrayOutput() AccessPointPolicyArrayOutput {
   222  	return i.ToAccessPointPolicyArrayOutputWithContext(context.Background())
   223  }
   224  
   225  func (i AccessPointPolicyArray) ToAccessPointPolicyArrayOutputWithContext(ctx context.Context) AccessPointPolicyArrayOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(AccessPointPolicyArrayOutput)
   227  }
   228  
   229  // AccessPointPolicyMapInput is an input type that accepts AccessPointPolicyMap and AccessPointPolicyMapOutput values.
   230  // You can construct a concrete instance of `AccessPointPolicyMapInput` via:
   231  //
   232  //	AccessPointPolicyMap{ "key": AccessPointPolicyArgs{...} }
   233  type AccessPointPolicyMapInput interface {
   234  	pulumi.Input
   235  
   236  	ToAccessPointPolicyMapOutput() AccessPointPolicyMapOutput
   237  	ToAccessPointPolicyMapOutputWithContext(context.Context) AccessPointPolicyMapOutput
   238  }
   239  
   240  type AccessPointPolicyMap map[string]AccessPointPolicyInput
   241  
   242  func (AccessPointPolicyMap) ElementType() reflect.Type {
   243  	return reflect.TypeOf((*map[string]*AccessPointPolicy)(nil)).Elem()
   244  }
   245  
   246  func (i AccessPointPolicyMap) ToAccessPointPolicyMapOutput() AccessPointPolicyMapOutput {
   247  	return i.ToAccessPointPolicyMapOutputWithContext(context.Background())
   248  }
   249  
   250  func (i AccessPointPolicyMap) ToAccessPointPolicyMapOutputWithContext(ctx context.Context) AccessPointPolicyMapOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(AccessPointPolicyMapOutput)
   252  }
   253  
   254  type AccessPointPolicyOutput struct{ *pulumi.OutputState }
   255  
   256  func (AccessPointPolicyOutput) ElementType() reflect.Type {
   257  	return reflect.TypeOf((**AccessPointPolicy)(nil)).Elem()
   258  }
   259  
   260  func (o AccessPointPolicyOutput) ToAccessPointPolicyOutput() AccessPointPolicyOutput {
   261  	return o
   262  }
   263  
   264  func (o AccessPointPolicyOutput) ToAccessPointPolicyOutputWithContext(ctx context.Context) AccessPointPolicyOutput {
   265  	return o
   266  }
   267  
   268  // The ARN of the access point that you want to associate with the specified policy.
   269  func (o AccessPointPolicyOutput) AccessPointArn() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *AccessPointPolicy) pulumi.StringOutput { return v.AccessPointArn }).(pulumi.StringOutput)
   271  }
   272  
   273  // Indicates whether this access point currently has a policy that allows public access.
   274  func (o AccessPointPolicyOutput) HasPublicAccessPolicy() pulumi.BoolOutput {
   275  	return o.ApplyT(func(v *AccessPointPolicy) pulumi.BoolOutput { return v.HasPublicAccessPolicy }).(pulumi.BoolOutput)
   276  }
   277  
   278  // The policy that you want to apply to the specified access point.
   279  func (o AccessPointPolicyOutput) Policy() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *AccessPointPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   281  }
   282  
   283  type AccessPointPolicyArrayOutput struct{ *pulumi.OutputState }
   284  
   285  func (AccessPointPolicyArrayOutput) ElementType() reflect.Type {
   286  	return reflect.TypeOf((*[]*AccessPointPolicy)(nil)).Elem()
   287  }
   288  
   289  func (o AccessPointPolicyArrayOutput) ToAccessPointPolicyArrayOutput() AccessPointPolicyArrayOutput {
   290  	return o
   291  }
   292  
   293  func (o AccessPointPolicyArrayOutput) ToAccessPointPolicyArrayOutputWithContext(ctx context.Context) AccessPointPolicyArrayOutput {
   294  	return o
   295  }
   296  
   297  func (o AccessPointPolicyArrayOutput) Index(i pulumi.IntInput) AccessPointPolicyOutput {
   298  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *AccessPointPolicy {
   299  		return vs[0].([]*AccessPointPolicy)[vs[1].(int)]
   300  	}).(AccessPointPolicyOutput)
   301  }
   302  
   303  type AccessPointPolicyMapOutput struct{ *pulumi.OutputState }
   304  
   305  func (AccessPointPolicyMapOutput) ElementType() reflect.Type {
   306  	return reflect.TypeOf((*map[string]*AccessPointPolicy)(nil)).Elem()
   307  }
   308  
   309  func (o AccessPointPolicyMapOutput) ToAccessPointPolicyMapOutput() AccessPointPolicyMapOutput {
   310  	return o
   311  }
   312  
   313  func (o AccessPointPolicyMapOutput) ToAccessPointPolicyMapOutputWithContext(ctx context.Context) AccessPointPolicyMapOutput {
   314  	return o
   315  }
   316  
   317  func (o AccessPointPolicyMapOutput) MapIndex(k pulumi.StringInput) AccessPointPolicyOutput {
   318  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *AccessPointPolicy {
   319  		return vs[0].(map[string]*AccessPointPolicy)[vs[1].(string)]
   320  	}).(AccessPointPolicyOutput)
   321  }
   322  
   323  func init() {
   324  	pulumi.RegisterInputType(reflect.TypeOf((*AccessPointPolicyInput)(nil)).Elem(), &AccessPointPolicy{})
   325  	pulumi.RegisterInputType(reflect.TypeOf((*AccessPointPolicyArrayInput)(nil)).Elem(), AccessPointPolicyArray{})
   326  	pulumi.RegisterInputType(reflect.TypeOf((*AccessPointPolicyMapInput)(nil)).Elem(), AccessPointPolicyMap{})
   327  	pulumi.RegisterOutputType(AccessPointPolicyOutput{})
   328  	pulumi.RegisterOutputType(AccessPointPolicyArrayOutput{})
   329  	pulumi.RegisterOutputType(AccessPointPolicyMapOutput{})
   330  }