github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudfront/function.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 cloudfront 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 CloudFront Function resource. With CloudFront Functions in Amazon CloudFront, you can write lightweight functions in JavaScript for high-scale, latency-sensitive CDN customizations. 16 // 17 // See [CloudFront Functions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html) 18 // 19 // > **NOTE:** You cannot delete a function if it’s associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function. 20 // 21 // ## Example Usage 22 // 23 // ## Import 24 // 25 // Using `pulumi import`, import CloudFront Functions using the `name`. For example: 26 // 27 // ```sh 28 // $ pulumi import aws:cloudfront/function:Function test my_test_function 29 // ``` 30 type Function struct { 31 pulumi.CustomResourceState 32 33 // Amazon Resource Name (ARN) identifying your CloudFront Function. 34 Arn pulumi.StringOutput `pulumi:"arn"` 35 // Source code of the function 36 Code pulumi.StringOutput `pulumi:"code"` 37 // Comment. 38 Comment pulumi.StringPtrOutput `pulumi:"comment"` 39 // ETag hash of the function. This is the value for the `DEVELOPMENT` stage of the function. 40 Etag pulumi.StringOutput `pulumi:"etag"` 41 // List of `cloudfront.KeyValueStore` ARNs to be associated to the function. AWS limits associations to on key value store per function. 42 KeyValueStoreAssociations pulumi.StringArrayOutput `pulumi:"keyValueStoreAssociations"` 43 // ETag hash of any `LIVE` stage of the function. 44 LiveStageEtag pulumi.StringOutput `pulumi:"liveStageEtag"` 45 // Unique name for your CloudFront Function. 46 Name pulumi.StringOutput `pulumi:"name"` 47 // Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`. 48 Publish pulumi.BoolPtrOutput `pulumi:"publish"` 49 // Identifier of the function's runtime. Valid values are `cloudfront-js-1.0` and `cloudfront-js-2.0`. 50 // 51 // The following arguments are optional: 52 Runtime pulumi.StringOutput `pulumi:"runtime"` 53 // Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`. 54 Status pulumi.StringOutput `pulumi:"status"` 55 } 56 57 // NewFunction registers a new resource with the given unique name, arguments, and options. 58 func NewFunction(ctx *pulumi.Context, 59 name string, args *FunctionArgs, opts ...pulumi.ResourceOption) (*Function, error) { 60 if args == nil { 61 return nil, errors.New("missing one or more required arguments") 62 } 63 64 if args.Code == nil { 65 return nil, errors.New("invalid value for required argument 'Code'") 66 } 67 if args.Runtime == nil { 68 return nil, errors.New("invalid value for required argument 'Runtime'") 69 } 70 opts = internal.PkgResourceDefaultOpts(opts) 71 var resource Function 72 err := ctx.RegisterResource("aws:cloudfront/function:Function", name, args, &resource, opts...) 73 if err != nil { 74 return nil, err 75 } 76 return &resource, nil 77 } 78 79 // GetFunction gets an existing Function resource's state with the given name, ID, and optional 80 // state properties that are used to uniquely qualify the lookup (nil if not required). 81 func GetFunction(ctx *pulumi.Context, 82 name string, id pulumi.IDInput, state *FunctionState, opts ...pulumi.ResourceOption) (*Function, error) { 83 var resource Function 84 err := ctx.ReadResource("aws:cloudfront/function:Function", name, id, state, &resource, opts...) 85 if err != nil { 86 return nil, err 87 } 88 return &resource, nil 89 } 90 91 // Input properties used for looking up and filtering Function resources. 92 type functionState struct { 93 // Amazon Resource Name (ARN) identifying your CloudFront Function. 94 Arn *string `pulumi:"arn"` 95 // Source code of the function 96 Code *string `pulumi:"code"` 97 // Comment. 98 Comment *string `pulumi:"comment"` 99 // ETag hash of the function. This is the value for the `DEVELOPMENT` stage of the function. 100 Etag *string `pulumi:"etag"` 101 // List of `cloudfront.KeyValueStore` ARNs to be associated to the function. AWS limits associations to on key value store per function. 102 KeyValueStoreAssociations []string `pulumi:"keyValueStoreAssociations"` 103 // ETag hash of any `LIVE` stage of the function. 104 LiveStageEtag *string `pulumi:"liveStageEtag"` 105 // Unique name for your CloudFront Function. 106 Name *string `pulumi:"name"` 107 // Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`. 108 Publish *bool `pulumi:"publish"` 109 // Identifier of the function's runtime. Valid values are `cloudfront-js-1.0` and `cloudfront-js-2.0`. 110 // 111 // The following arguments are optional: 112 Runtime *string `pulumi:"runtime"` 113 // Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`. 114 Status *string `pulumi:"status"` 115 } 116 117 type FunctionState struct { 118 // Amazon Resource Name (ARN) identifying your CloudFront Function. 119 Arn pulumi.StringPtrInput 120 // Source code of the function 121 Code pulumi.StringPtrInput 122 // Comment. 123 Comment pulumi.StringPtrInput 124 // ETag hash of the function. This is the value for the `DEVELOPMENT` stage of the function. 125 Etag pulumi.StringPtrInput 126 // List of `cloudfront.KeyValueStore` ARNs to be associated to the function. AWS limits associations to on key value store per function. 127 KeyValueStoreAssociations pulumi.StringArrayInput 128 // ETag hash of any `LIVE` stage of the function. 129 LiveStageEtag pulumi.StringPtrInput 130 // Unique name for your CloudFront Function. 131 Name pulumi.StringPtrInput 132 // Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`. 133 Publish pulumi.BoolPtrInput 134 // Identifier of the function's runtime. Valid values are `cloudfront-js-1.0` and `cloudfront-js-2.0`. 135 // 136 // The following arguments are optional: 137 Runtime pulumi.StringPtrInput 138 // Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`. 139 Status pulumi.StringPtrInput 140 } 141 142 func (FunctionState) ElementType() reflect.Type { 143 return reflect.TypeOf((*functionState)(nil)).Elem() 144 } 145 146 type functionArgs struct { 147 // Source code of the function 148 Code string `pulumi:"code"` 149 // Comment. 150 Comment *string `pulumi:"comment"` 151 // List of `cloudfront.KeyValueStore` ARNs to be associated to the function. AWS limits associations to on key value store per function. 152 KeyValueStoreAssociations []string `pulumi:"keyValueStoreAssociations"` 153 // Unique name for your CloudFront Function. 154 Name *string `pulumi:"name"` 155 // Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`. 156 Publish *bool `pulumi:"publish"` 157 // Identifier of the function's runtime. Valid values are `cloudfront-js-1.0` and `cloudfront-js-2.0`. 158 // 159 // The following arguments are optional: 160 Runtime string `pulumi:"runtime"` 161 } 162 163 // The set of arguments for constructing a Function resource. 164 type FunctionArgs struct { 165 // Source code of the function 166 Code pulumi.StringInput 167 // Comment. 168 Comment pulumi.StringPtrInput 169 // List of `cloudfront.KeyValueStore` ARNs to be associated to the function. AWS limits associations to on key value store per function. 170 KeyValueStoreAssociations pulumi.StringArrayInput 171 // Unique name for your CloudFront Function. 172 Name pulumi.StringPtrInput 173 // Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`. 174 Publish pulumi.BoolPtrInput 175 // Identifier of the function's runtime. Valid values are `cloudfront-js-1.0` and `cloudfront-js-2.0`. 176 // 177 // The following arguments are optional: 178 Runtime pulumi.StringInput 179 } 180 181 func (FunctionArgs) ElementType() reflect.Type { 182 return reflect.TypeOf((*functionArgs)(nil)).Elem() 183 } 184 185 type FunctionInput interface { 186 pulumi.Input 187 188 ToFunctionOutput() FunctionOutput 189 ToFunctionOutputWithContext(ctx context.Context) FunctionOutput 190 } 191 192 func (*Function) ElementType() reflect.Type { 193 return reflect.TypeOf((**Function)(nil)).Elem() 194 } 195 196 func (i *Function) ToFunctionOutput() FunctionOutput { 197 return i.ToFunctionOutputWithContext(context.Background()) 198 } 199 200 func (i *Function) ToFunctionOutputWithContext(ctx context.Context) FunctionOutput { 201 return pulumi.ToOutputWithContext(ctx, i).(FunctionOutput) 202 } 203 204 // FunctionArrayInput is an input type that accepts FunctionArray and FunctionArrayOutput values. 205 // You can construct a concrete instance of `FunctionArrayInput` via: 206 // 207 // FunctionArray{ FunctionArgs{...} } 208 type FunctionArrayInput interface { 209 pulumi.Input 210 211 ToFunctionArrayOutput() FunctionArrayOutput 212 ToFunctionArrayOutputWithContext(context.Context) FunctionArrayOutput 213 } 214 215 type FunctionArray []FunctionInput 216 217 func (FunctionArray) ElementType() reflect.Type { 218 return reflect.TypeOf((*[]*Function)(nil)).Elem() 219 } 220 221 func (i FunctionArray) ToFunctionArrayOutput() FunctionArrayOutput { 222 return i.ToFunctionArrayOutputWithContext(context.Background()) 223 } 224 225 func (i FunctionArray) ToFunctionArrayOutputWithContext(ctx context.Context) FunctionArrayOutput { 226 return pulumi.ToOutputWithContext(ctx, i).(FunctionArrayOutput) 227 } 228 229 // FunctionMapInput is an input type that accepts FunctionMap and FunctionMapOutput values. 230 // You can construct a concrete instance of `FunctionMapInput` via: 231 // 232 // FunctionMap{ "key": FunctionArgs{...} } 233 type FunctionMapInput interface { 234 pulumi.Input 235 236 ToFunctionMapOutput() FunctionMapOutput 237 ToFunctionMapOutputWithContext(context.Context) FunctionMapOutput 238 } 239 240 type FunctionMap map[string]FunctionInput 241 242 func (FunctionMap) ElementType() reflect.Type { 243 return reflect.TypeOf((*map[string]*Function)(nil)).Elem() 244 } 245 246 func (i FunctionMap) ToFunctionMapOutput() FunctionMapOutput { 247 return i.ToFunctionMapOutputWithContext(context.Background()) 248 } 249 250 func (i FunctionMap) ToFunctionMapOutputWithContext(ctx context.Context) FunctionMapOutput { 251 return pulumi.ToOutputWithContext(ctx, i).(FunctionMapOutput) 252 } 253 254 type FunctionOutput struct{ *pulumi.OutputState } 255 256 func (FunctionOutput) ElementType() reflect.Type { 257 return reflect.TypeOf((**Function)(nil)).Elem() 258 } 259 260 func (o FunctionOutput) ToFunctionOutput() FunctionOutput { 261 return o 262 } 263 264 func (o FunctionOutput) ToFunctionOutputWithContext(ctx context.Context) FunctionOutput { 265 return o 266 } 267 268 // Amazon Resource Name (ARN) identifying your CloudFront Function. 269 func (o FunctionOutput) Arn() pulumi.StringOutput { 270 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 271 } 272 273 // Source code of the function 274 func (o FunctionOutput) Code() pulumi.StringOutput { 275 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Code }).(pulumi.StringOutput) 276 } 277 278 // Comment. 279 func (o FunctionOutput) Comment() pulumi.StringPtrOutput { 280 return o.ApplyT(func(v *Function) pulumi.StringPtrOutput { return v.Comment }).(pulumi.StringPtrOutput) 281 } 282 283 // ETag hash of the function. This is the value for the `DEVELOPMENT` stage of the function. 284 func (o FunctionOutput) Etag() pulumi.StringOutput { 285 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput) 286 } 287 288 // List of `cloudfront.KeyValueStore` ARNs to be associated to the function. AWS limits associations to on key value store per function. 289 func (o FunctionOutput) KeyValueStoreAssociations() pulumi.StringArrayOutput { 290 return o.ApplyT(func(v *Function) pulumi.StringArrayOutput { return v.KeyValueStoreAssociations }).(pulumi.StringArrayOutput) 291 } 292 293 // ETag hash of any `LIVE` stage of the function. 294 func (o FunctionOutput) LiveStageEtag() pulumi.StringOutput { 295 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.LiveStageEtag }).(pulumi.StringOutput) 296 } 297 298 // Unique name for your CloudFront Function. 299 func (o FunctionOutput) Name() pulumi.StringOutput { 300 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 301 } 302 303 // Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`. 304 func (o FunctionOutput) Publish() pulumi.BoolPtrOutput { 305 return o.ApplyT(func(v *Function) pulumi.BoolPtrOutput { return v.Publish }).(pulumi.BoolPtrOutput) 306 } 307 308 // Identifier of the function's runtime. Valid values are `cloudfront-js-1.0` and `cloudfront-js-2.0`. 309 // 310 // The following arguments are optional: 311 func (o FunctionOutput) Runtime() pulumi.StringOutput { 312 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Runtime }).(pulumi.StringOutput) 313 } 314 315 // Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`. 316 func (o FunctionOutput) Status() pulumi.StringOutput { 317 return o.ApplyT(func(v *Function) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput) 318 } 319 320 type FunctionArrayOutput struct{ *pulumi.OutputState } 321 322 func (FunctionArrayOutput) ElementType() reflect.Type { 323 return reflect.TypeOf((*[]*Function)(nil)).Elem() 324 } 325 326 func (o FunctionArrayOutput) ToFunctionArrayOutput() FunctionArrayOutput { 327 return o 328 } 329 330 func (o FunctionArrayOutput) ToFunctionArrayOutputWithContext(ctx context.Context) FunctionArrayOutput { 331 return o 332 } 333 334 func (o FunctionArrayOutput) Index(i pulumi.IntInput) FunctionOutput { 335 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Function { 336 return vs[0].([]*Function)[vs[1].(int)] 337 }).(FunctionOutput) 338 } 339 340 type FunctionMapOutput struct{ *pulumi.OutputState } 341 342 func (FunctionMapOutput) ElementType() reflect.Type { 343 return reflect.TypeOf((*map[string]*Function)(nil)).Elem() 344 } 345 346 func (o FunctionMapOutput) ToFunctionMapOutput() FunctionMapOutput { 347 return o 348 } 349 350 func (o FunctionMapOutput) ToFunctionMapOutputWithContext(ctx context.Context) FunctionMapOutput { 351 return o 352 } 353 354 func (o FunctionMapOutput) MapIndex(k pulumi.StringInput) FunctionOutput { 355 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Function { 356 return vs[0].(map[string]*Function)[vs[1].(string)] 357 }).(FunctionOutput) 358 } 359 360 func init() { 361 pulumi.RegisterInputType(reflect.TypeOf((*FunctionInput)(nil)).Elem(), &Function{}) 362 pulumi.RegisterInputType(reflect.TypeOf((*FunctionArrayInput)(nil)).Elem(), FunctionArray{}) 363 pulumi.RegisterInputType(reflect.TypeOf((*FunctionMapInput)(nil)).Elem(), FunctionMap{}) 364 pulumi.RegisterOutputType(FunctionOutput{}) 365 pulumi.RegisterOutputType(FunctionArrayOutput{}) 366 pulumi.RegisterOutputType(FunctionMapOutput{}) 367 }