Resource: awsCloudfrontFunction
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.
\~> 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.
Example Usage
Basic Example
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.cloudfrontFunction.CloudfrontFunction(this, "test", {
code: '${file("${path.module}/function.js")}',
comment: "my function",
name: "test",
publish: true,
runtime: "cloudfront-js-1.0",
});
Argument Reference
The following arguments are required:
name
- (Required) Unique name for your CloudFront Function.code
- (Required) Source code of the functionruntime
- (Required) Identifier of the function's runtime. Currently onlycloudfrontJs10
is valid.
The following arguments are optional:
comment
- (Optional) Comment.publish
- (Optional) Whether to publish creation/change as Live CloudFront Function Version. Defaults totrue
.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
arn
- Amazon Resource Name (ARN) identifying your CloudFront Function.etag
- ETag hash of the function. This is the value for thedevelopment
stage of the function.liveStageEtag
- ETag hash of anylive
stage of the function.status
- Status of the function. Can beunpublished
,unassociated
orassociated
.
Import
CloudFront Functions can be imported using the name
, e.g.,