---
subcategory: "CloudFront"
layout: "aws"
page_title: "AWS: aws_cloudfront_public_key"
description: |-
  Provides a CloudFront Public Key which you add to CloudFront to use with features like field-level encryption.
---

# Resource: aws_cloudfront_public_key

## Example Usage

The following example below creates a CloudFront public key.

```hcl
resource "aws_cloudfront_public_key" "example" {
  comment     = "test public key"
  encoded_key = file("public_key.pem")
  name        = "test_key"
}
```

## Argument Reference

The following arguments are supported:

* `comment` - (Optional) An optional comment about the public key.
* `encoded_key` - (Required) The encoded public key that you want to add to CloudFront to use with features like field-level encryption.
* `name` - (Optional) The name for the public key. By default generated by Terraform.
* `name_prefix` - (Optional) The name for the public key. Conflicts with `name`.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `caller_reference` - Internal value used by CloudFront to allow future updates to the public key configuration.
* `etag` - The current version of the public key. For example: `E2QWRUHAPOMQZL`.
* `id` - The identifier for the public key. For example: `K3D5EWEUDCCXON`.
