github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3control/bucketPolicy.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 Control Bucket Policy. 16 // 17 // > This functionality is for managing [S3 on Outposts](https://docs.aws.amazon.com/AmazonS3/latest/dev/S3onOutposts.html). To manage S3 Bucket Policies in an AWS Partition, see the `s3.BucketPolicy` resource. 18 // 19 // ## Example 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/s3control" 30 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 31 // 32 // ) 33 // 34 // func main() { 35 // pulumi.Run(func(ctx *pulumi.Context) error { 36 // tmpJSON0, err := json.Marshal(map[string]interface{}{ 37 // "Id": "testBucketPolicy", 38 // "Statement": []map[string]interface{}{ 39 // map[string]interface{}{ 40 // "Action": "s3-outposts:PutBucketLifecycleConfiguration", 41 // "Effect": "Deny", 42 // "Principal": map[string]interface{}{ 43 // "AWS": "*", 44 // }, 45 // "Resource": exampleAwsS3controlBucket.Arn, 46 // "Sid": "statement1", 47 // }, 48 // }, 49 // "Version": "2012-10-17", 50 // }) 51 // if err != nil { 52 // return err 53 // } 54 // json0 := string(tmpJSON0) 55 // _, err = s3control.NewBucketPolicy(ctx, "example", &s3control.BucketPolicyArgs{ 56 // Bucket: pulumi.Any(exampleAwsS3controlBucket.Arn), 57 // Policy: pulumi.String(json0), 58 // }) 59 // if err != nil { 60 // return err 61 // } 62 // return nil 63 // }) 64 // } 65 // 66 // ``` 67 // <!--End PulumiCodeChooser --> 68 // 69 // ## Import 70 // 71 // Using `pulumi import`, import S3 Control Bucket Policies using the Amazon Resource Name (ARN). For example: 72 // 73 // ```sh 74 // $ pulumi import aws:s3control/bucketPolicy:BucketPolicy example arn:aws:s3-outposts:us-east-1:123456789012:outpost/op-12345678/bucket/example 75 // ``` 76 type BucketPolicy struct { 77 pulumi.CustomResourceState 78 79 // Amazon Resource Name (ARN) of the bucket. 80 Bucket pulumi.StringOutput `pulumi:"bucket"` 81 // JSON string of the resource policy. 82 Policy pulumi.StringOutput `pulumi:"policy"` 83 } 84 85 // NewBucketPolicy registers a new resource with the given unique name, arguments, and options. 86 func NewBucketPolicy(ctx *pulumi.Context, 87 name string, args *BucketPolicyArgs, opts ...pulumi.ResourceOption) (*BucketPolicy, error) { 88 if args == nil { 89 return nil, errors.New("missing one or more required arguments") 90 } 91 92 if args.Bucket == nil { 93 return nil, errors.New("invalid value for required argument 'Bucket'") 94 } 95 if args.Policy == nil { 96 return nil, errors.New("invalid value for required argument 'Policy'") 97 } 98 opts = internal.PkgResourceDefaultOpts(opts) 99 var resource BucketPolicy 100 err := ctx.RegisterResource("aws:s3control/bucketPolicy:BucketPolicy", name, args, &resource, opts...) 101 if err != nil { 102 return nil, err 103 } 104 return &resource, nil 105 } 106 107 // GetBucketPolicy gets an existing BucketPolicy resource's state with the given name, ID, and optional 108 // state properties that are used to uniquely qualify the lookup (nil if not required). 109 func GetBucketPolicy(ctx *pulumi.Context, 110 name string, id pulumi.IDInput, state *BucketPolicyState, opts ...pulumi.ResourceOption) (*BucketPolicy, error) { 111 var resource BucketPolicy 112 err := ctx.ReadResource("aws:s3control/bucketPolicy:BucketPolicy", name, id, state, &resource, opts...) 113 if err != nil { 114 return nil, err 115 } 116 return &resource, nil 117 } 118 119 // Input properties used for looking up and filtering BucketPolicy resources. 120 type bucketPolicyState struct { 121 // Amazon Resource Name (ARN) of the bucket. 122 Bucket *string `pulumi:"bucket"` 123 // JSON string of the resource policy. 124 Policy *string `pulumi:"policy"` 125 } 126 127 type BucketPolicyState struct { 128 // Amazon Resource Name (ARN) of the bucket. 129 Bucket pulumi.StringPtrInput 130 // JSON string of the resource policy. 131 Policy pulumi.StringPtrInput 132 } 133 134 func (BucketPolicyState) ElementType() reflect.Type { 135 return reflect.TypeOf((*bucketPolicyState)(nil)).Elem() 136 } 137 138 type bucketPolicyArgs struct { 139 // Amazon Resource Name (ARN) of the bucket. 140 Bucket string `pulumi:"bucket"` 141 // JSON string of the resource policy. 142 Policy string `pulumi:"policy"` 143 } 144 145 // The set of arguments for constructing a BucketPolicy resource. 146 type BucketPolicyArgs struct { 147 // Amazon Resource Name (ARN) of the bucket. 148 Bucket pulumi.StringInput 149 // JSON string of the resource policy. 150 Policy pulumi.StringInput 151 } 152 153 func (BucketPolicyArgs) ElementType() reflect.Type { 154 return reflect.TypeOf((*bucketPolicyArgs)(nil)).Elem() 155 } 156 157 type BucketPolicyInput interface { 158 pulumi.Input 159 160 ToBucketPolicyOutput() BucketPolicyOutput 161 ToBucketPolicyOutputWithContext(ctx context.Context) BucketPolicyOutput 162 } 163 164 func (*BucketPolicy) ElementType() reflect.Type { 165 return reflect.TypeOf((**BucketPolicy)(nil)).Elem() 166 } 167 168 func (i *BucketPolicy) ToBucketPolicyOutput() BucketPolicyOutput { 169 return i.ToBucketPolicyOutputWithContext(context.Background()) 170 } 171 172 func (i *BucketPolicy) ToBucketPolicyOutputWithContext(ctx context.Context) BucketPolicyOutput { 173 return pulumi.ToOutputWithContext(ctx, i).(BucketPolicyOutput) 174 } 175 176 // BucketPolicyArrayInput is an input type that accepts BucketPolicyArray and BucketPolicyArrayOutput values. 177 // You can construct a concrete instance of `BucketPolicyArrayInput` via: 178 // 179 // BucketPolicyArray{ BucketPolicyArgs{...} } 180 type BucketPolicyArrayInput interface { 181 pulumi.Input 182 183 ToBucketPolicyArrayOutput() BucketPolicyArrayOutput 184 ToBucketPolicyArrayOutputWithContext(context.Context) BucketPolicyArrayOutput 185 } 186 187 type BucketPolicyArray []BucketPolicyInput 188 189 func (BucketPolicyArray) ElementType() reflect.Type { 190 return reflect.TypeOf((*[]*BucketPolicy)(nil)).Elem() 191 } 192 193 func (i BucketPolicyArray) ToBucketPolicyArrayOutput() BucketPolicyArrayOutput { 194 return i.ToBucketPolicyArrayOutputWithContext(context.Background()) 195 } 196 197 func (i BucketPolicyArray) ToBucketPolicyArrayOutputWithContext(ctx context.Context) BucketPolicyArrayOutput { 198 return pulumi.ToOutputWithContext(ctx, i).(BucketPolicyArrayOutput) 199 } 200 201 // BucketPolicyMapInput is an input type that accepts BucketPolicyMap and BucketPolicyMapOutput values. 202 // You can construct a concrete instance of `BucketPolicyMapInput` via: 203 // 204 // BucketPolicyMap{ "key": BucketPolicyArgs{...} } 205 type BucketPolicyMapInput interface { 206 pulumi.Input 207 208 ToBucketPolicyMapOutput() BucketPolicyMapOutput 209 ToBucketPolicyMapOutputWithContext(context.Context) BucketPolicyMapOutput 210 } 211 212 type BucketPolicyMap map[string]BucketPolicyInput 213 214 func (BucketPolicyMap) ElementType() reflect.Type { 215 return reflect.TypeOf((*map[string]*BucketPolicy)(nil)).Elem() 216 } 217 218 func (i BucketPolicyMap) ToBucketPolicyMapOutput() BucketPolicyMapOutput { 219 return i.ToBucketPolicyMapOutputWithContext(context.Background()) 220 } 221 222 func (i BucketPolicyMap) ToBucketPolicyMapOutputWithContext(ctx context.Context) BucketPolicyMapOutput { 223 return pulumi.ToOutputWithContext(ctx, i).(BucketPolicyMapOutput) 224 } 225 226 type BucketPolicyOutput struct{ *pulumi.OutputState } 227 228 func (BucketPolicyOutput) ElementType() reflect.Type { 229 return reflect.TypeOf((**BucketPolicy)(nil)).Elem() 230 } 231 232 func (o BucketPolicyOutput) ToBucketPolicyOutput() BucketPolicyOutput { 233 return o 234 } 235 236 func (o BucketPolicyOutput) ToBucketPolicyOutputWithContext(ctx context.Context) BucketPolicyOutput { 237 return o 238 } 239 240 // Amazon Resource Name (ARN) of the bucket. 241 func (o BucketPolicyOutput) Bucket() pulumi.StringOutput { 242 return o.ApplyT(func(v *BucketPolicy) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput) 243 } 244 245 // JSON string of the resource policy. 246 func (o BucketPolicyOutput) Policy() pulumi.StringOutput { 247 return o.ApplyT(func(v *BucketPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 248 } 249 250 type BucketPolicyArrayOutput struct{ *pulumi.OutputState } 251 252 func (BucketPolicyArrayOutput) ElementType() reflect.Type { 253 return reflect.TypeOf((*[]*BucketPolicy)(nil)).Elem() 254 } 255 256 func (o BucketPolicyArrayOutput) ToBucketPolicyArrayOutput() BucketPolicyArrayOutput { 257 return o 258 } 259 260 func (o BucketPolicyArrayOutput) ToBucketPolicyArrayOutputWithContext(ctx context.Context) BucketPolicyArrayOutput { 261 return o 262 } 263 264 func (o BucketPolicyArrayOutput) Index(i pulumi.IntInput) BucketPolicyOutput { 265 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketPolicy { 266 return vs[0].([]*BucketPolicy)[vs[1].(int)] 267 }).(BucketPolicyOutput) 268 } 269 270 type BucketPolicyMapOutput struct{ *pulumi.OutputState } 271 272 func (BucketPolicyMapOutput) ElementType() reflect.Type { 273 return reflect.TypeOf((*map[string]*BucketPolicy)(nil)).Elem() 274 } 275 276 func (o BucketPolicyMapOutput) ToBucketPolicyMapOutput() BucketPolicyMapOutput { 277 return o 278 } 279 280 func (o BucketPolicyMapOutput) ToBucketPolicyMapOutputWithContext(ctx context.Context) BucketPolicyMapOutput { 281 return o 282 } 283 284 func (o BucketPolicyMapOutput) MapIndex(k pulumi.StringInput) BucketPolicyOutput { 285 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketPolicy { 286 return vs[0].(map[string]*BucketPolicy)[vs[1].(string)] 287 }).(BucketPolicyOutput) 288 } 289 290 func init() { 291 pulumi.RegisterInputType(reflect.TypeOf((*BucketPolicyInput)(nil)).Elem(), &BucketPolicy{}) 292 pulumi.RegisterInputType(reflect.TypeOf((*BucketPolicyArrayInput)(nil)).Elem(), BucketPolicyArray{}) 293 pulumi.RegisterInputType(reflect.TypeOf((*BucketPolicyMapInput)(nil)).Elem(), BucketPolicyMap{}) 294 pulumi.RegisterOutputType(BucketPolicyOutput{}) 295 pulumi.RegisterOutputType(BucketPolicyArrayOutput{}) 296 pulumi.RegisterOutputType(BucketPolicyMapOutput{}) 297 }