Skip to content

Commit

Permalink
Merge branch 'terraform-aws-modules:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 4, 2024
2 parents 7600915 + 508c40d commit 7c62d66
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 27 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [3.3.0](https://github.com/terraform-aws-modules/terraform-aws-cloudfront/compare/v3.2.2...v3.3.0) (2024-03-01)


### Features

* Added support for Staging Distribution ([#130](https://github.com/terraform-aws-modules/terraform-aws-cloudfront/issues/130)) ([601df49](https://github.com/terraform-aws-modules/terraform-aws-cloudfront/commit/601df4903d11e8bff2c907a9c8ce711ccb43a05c))

### [3.2.2](https://github.com/terraform-aws-modules/terraform-aws-cloudfront/compare/v3.2.1...v3.2.2) (2024-02-09)


Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_aliases"></a> [aliases](#input\_aliases) | Extra CNAMEs (alternate domain names), if any, for this distribution. | `list(string)` | `null` | no |
| <a name="input_comment"></a> [comment](#input\_comment) | Any comments you want to include about the distribution. | `string` | `null` | no |
| <a name="input_continuous_deployment_policy_id"></a> [continuous\_deployment\_policy\_id](#input\_continuous\_deployment\_policy\_id) | Identifier of a continuous deployment policy. This argument should only be set on a production distribution. | `string` | `null` | no |
| <a name="input_create_distribution"></a> [create\_distribution](#input\_create\_distribution) | Controls if CloudFront distribution should be created | `bool` | `true` | no |
| <a name="input_create_monitoring_subscription"></a> [create\_monitoring\_subscription](#input\_create\_monitoring\_subscription) | If enabled, the resource for monitoring subscription will created. | `bool` | `false` | no |
| <a name="input_create_origin_access_control"></a> [create\_origin\_access\_control](#input\_create\_origin\_access\_control) | Controls if CloudFront origin access control should be created | `bool` | `false` | no |
Expand All @@ -154,6 +155,7 @@ No modules.
| <a name="input_price_class"></a> [price\_class](#input\_price\_class) | The price class for this distribution. One of PriceClass\_All, PriceClass\_200, PriceClass\_100 | `string` | `null` | no |
| <a name="input_realtime_metrics_subscription_status"></a> [realtime\_metrics\_subscription\_status](#input\_realtime\_metrics\_subscription\_status) | A flag that indicates whether additional CloudWatch metrics are enabled for a given CloudFront distribution. Valid values are `Enabled` and `Disabled`. | `string` | `"Enabled"` | no |
| <a name="input_retain_on_delete"></a> [retain\_on\_delete](#input\_retain\_on\_delete) | Disables the distribution instead of deleting it when destroying the resource through Terraform. If this is set, the distribution needs to be deleted manually afterwards. | `bool` | `false` | no |
| <a name="input_staging"></a> [staging](#input\_staging) | Whether the distribution is a staging distribution. | `bool` | `false` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no |
| <a name="input_viewer_certificate"></a> [viewer\_certificate](#input\_viewer\_certificate) | The SSL configuration for this distribution | `any` | <pre>{<br> "cloudfront_default_certificate": true,<br> "minimum_protocol_version": "TLSv1"<br>}</pre> | no |
| <a name="input_wait_for_deployment"></a> [wait\_for\_deployment](#input\_wait\_for\_deployment) | If enabled, the resource will wait for the distribution status to change from InProgress to Deployed. Setting this to false will skip the process. | `bool` | `true` | no |
Expand Down
6 changes: 6 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ module "cloudfront" {

comment = "My awesome CloudFront"
enabled = true
staging = false # If you want to create a staging distribution, set this to true
http_version = "http2and3"
is_ipv6_enabled = true
price_class = "PriceClass_All"
retain_on_delete = false
wait_for_deployment = false

# If you want to create a primary distribution with a continuous deployment policy, set this to the ID of the policy.
# This argument should only be set on a production distribution.
# ref. `aws_cloudfront_continuous_deployment_policy` resource: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_continuous_deployment_policy
continuous_deployment_policy_id = null

# When you enable additional metrics for a distribution, CloudFront sends up to 8 metrics to CloudWatch in the US East (N. Virginia) Region.
# This rate is charged only once per month, per metric (up to 8 metrics per distribution).
create_monitoring_subscription = true
Expand Down
24 changes: 13 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ resource "aws_cloudfront_origin_access_control" "this" {
resource "aws_cloudfront_distribution" "this" {
count = var.create_distribution ? 1 : 0

aliases = var.aliases
comment = var.comment
default_root_object = var.default_root_object
enabled = var.enabled
http_version = var.http_version
is_ipv6_enabled = var.is_ipv6_enabled
price_class = var.price_class
retain_on_delete = var.retain_on_delete
wait_for_deployment = var.wait_for_deployment
web_acl_id = var.web_acl_id
tags = var.tags
aliases = var.aliases
comment = var.comment
continuous_deployment_policy_id = var.continuous_deployment_policy_id
default_root_object = var.default_root_object
enabled = var.enabled
http_version = var.http_version
is_ipv6_enabled = var.is_ipv6_enabled
price_class = var.price_class
retain_on_delete = var.retain_on_delete
staging = var.staging
wait_for_deployment = var.wait_for_deployment
web_acl_id = var.web_acl_id
tags = var.tags

dynamic "logging_config" {
for_each = length(keys(var.logging_config)) == 0 ? [] : [var.logging_config]
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ variable "comment" {
default = null
}

variable "continuous_deployment_policy_id" {
description = "Identifier of a continuous deployment policy. This argument should only be set on a production distribution."
type = string
default = null
}

variable "default_root_object" {
description = "The object that you want CloudFront to return (for example, index.html) when an end user requests the root URL."
type = string
Expand Down Expand Up @@ -101,6 +107,12 @@ variable "web_acl_id" {
default = null
}

variable "staging" {
description = "Whether the distribution is a staging distribution."
type = bool
default = false
}

variable "tags" {
description = "A map of tags to assign to the resource."
type = map(string)
Expand Down
34 changes: 18 additions & 16 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ module "wrapper" {

for_each = var.items

aliases = try(each.value.aliases, var.defaults.aliases, null)
comment = try(each.value.comment, var.defaults.comment, null)
create_distribution = try(each.value.create_distribution, var.defaults.create_distribution, true)
create_monitoring_subscription = try(each.value.create_monitoring_subscription, var.defaults.create_monitoring_subscription, false)
create_origin_access_control = try(each.value.create_origin_access_control, var.defaults.create_origin_access_control, false)
create_origin_access_identity = try(each.value.create_origin_access_identity, var.defaults.create_origin_access_identity, false)
custom_error_response = try(each.value.custom_error_response, var.defaults.custom_error_response, {})
default_cache_behavior = try(each.value.default_cache_behavior, var.defaults.default_cache_behavior, null)
default_root_object = try(each.value.default_root_object, var.defaults.default_root_object, null)
enabled = try(each.value.enabled, var.defaults.enabled, true)
geo_restriction = try(each.value.geo_restriction, var.defaults.geo_restriction, {})
http_version = try(each.value.http_version, var.defaults.http_version, "http2")
is_ipv6_enabled = try(each.value.is_ipv6_enabled, var.defaults.is_ipv6_enabled, null)
logging_config = try(each.value.logging_config, var.defaults.logging_config, {})
ordered_cache_behavior = try(each.value.ordered_cache_behavior, var.defaults.ordered_cache_behavior, [])
origin = try(each.value.origin, var.defaults.origin, null)
aliases = try(each.value.aliases, var.defaults.aliases, null)
comment = try(each.value.comment, var.defaults.comment, null)
continuous_deployment_policy_id = try(each.value.continuous_deployment_policy_id, var.defaults.continuous_deployment_policy_id, null)
create_distribution = try(each.value.create_distribution, var.defaults.create_distribution, true)
create_monitoring_subscription = try(each.value.create_monitoring_subscription, var.defaults.create_monitoring_subscription, false)
create_origin_access_control = try(each.value.create_origin_access_control, var.defaults.create_origin_access_control, false)
create_origin_access_identity = try(each.value.create_origin_access_identity, var.defaults.create_origin_access_identity, false)
custom_error_response = try(each.value.custom_error_response, var.defaults.custom_error_response, {})
default_cache_behavior = try(each.value.default_cache_behavior, var.defaults.default_cache_behavior, null)
default_root_object = try(each.value.default_root_object, var.defaults.default_root_object, null)
enabled = try(each.value.enabled, var.defaults.enabled, true)
geo_restriction = try(each.value.geo_restriction, var.defaults.geo_restriction, {})
http_version = try(each.value.http_version, var.defaults.http_version, "http2")
is_ipv6_enabled = try(each.value.is_ipv6_enabled, var.defaults.is_ipv6_enabled, null)
logging_config = try(each.value.logging_config, var.defaults.logging_config, {})
ordered_cache_behavior = try(each.value.ordered_cache_behavior, var.defaults.ordered_cache_behavior, [])
origin = try(each.value.origin, var.defaults.origin, null)
origin_access_control = try(each.value.origin_access_control, var.defaults.origin_access_control, {
s3 = {
description = "",
Expand All @@ -32,6 +33,7 @@ module "wrapper" {
price_class = try(each.value.price_class, var.defaults.price_class, null)
realtime_metrics_subscription_status = try(each.value.realtime_metrics_subscription_status, var.defaults.realtime_metrics_subscription_status, "Enabled")
retain_on_delete = try(each.value.retain_on_delete, var.defaults.retain_on_delete, false)
staging = try(each.value.staging, var.defaults.staging, false)
tags = try(each.value.tags, var.defaults.tags, null)
viewer_certificate = try(each.value.viewer_certificate, var.defaults.viewer_certificate, {
cloudfront_default_certificate = true
Expand Down

0 comments on commit 7c62d66

Please sign in to comment.