Resource: aws_cloudfront_function

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.

See CloudFront Functions

Example Usage

Basic Example

resource "aws_cloudfront_function" "test" {
  name    = "test"
  runtime = "cloudfront-js-2.0"
  comment = "my function"
  publish = true
  code    = file("${path.module}/function.js")
}

Argument Reference

The following arguments are required:

The following arguments are optional:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import CloudFront Functions using the name. For example:

import {
  to = aws_cloudfront_function.test
  id = "my_test_function"
}

Using terraform import, import CloudFront Functions using the name. For example:

% terraform import aws_cloudfront_function.test my_test_function