-
-
Notifications
You must be signed in to change notification settings - Fork 121
feat: Improve CDN origin control #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
milldr
merged 18 commits into
cloudposse:main
from
jwadolowski:feat/add-better-origin-control
Apr 4, 2025
Merged
feat: Improve CDN origin control #140
milldr
merged 18 commits into
cloudposse:main
from
jwadolowski:feat/add-better-origin-control
Apr 4, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The module is meant to be used with custom origins, but it may happen that your origin of choice is an S3 bucket that's not managed by yourself. `cloudposse/cloudfront-s3-cdn/aws` may seem to be a viable alternative (it supports pre-existing buckets), but there's an implicit assumption there - both the origin bucket and the CloudFront distribution that points to it should be deployed to the same AWS account. In order to secure CDN-to-S3 communication one may want to specify either OAI or OAC. Prior to this change, it was not possible to use OAI when S3 bucket domain name was used.
When user specifies an S3 domain name as the origin and attaches OAC to it, Terraform fails with the following error: Illegal configuration: The origin type and OAC origin type differ.
At the moment origin shield can be configured only for the default origin. This commit enables the feature for all the remaining ones.
`map()` function is no longer available
When cache policy ID is specified, all TTL arguments should be zeroed, as the policy-scoped TTLs take precedence. If non-zero `min_ttl`, `default_ttl` or `max_ttl` is set to non-0 value and at the same time cache policy is specified it leads to phantom changes in the plan: default_ttl = 0 -> 60
This reverts commit 30ff7b9. This should be moved to a separate PR to narrow down the scope just to origin-related changes
…_origin_config` variable
@johncblandii @jamengual can someone start the tests please? Thanks. |
/terratest |
Looks like tests passed. |
/terratest |
milldr
approved these changes
Apr 4, 2025
These changes were released in v1.3.0. |
jwadolowski
added a commit
to jwadolowski/terraform-aws-cloudfront-s3-cdn
that referenced
this pull request
May 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what
why
Currently, the module aims for a backend/cloud/platform-agnostic default origin. All of its details (port, protocol, domain, etc) are placed inside
custom_origin_config
block. Unfortunately,custom_origin_config
presence implies lack of OAC/OAI support.Here's my use case:
cloudposse/cloudfront-cdn/aws
in AWS accountA
B
(outside of my control)B
account would like to protect the bucket from unauthorized access by leveraging either Origin Access Identity or Origin Access ControlTechnically, the module allows me to assign an S3 bucket URL to
origin_domain_name
, but I can associate neither OAC (even thoughorigin_access_control_id
exists) nor OAI (no such option at the moment, however OAI gets created by the module) with it.The following code fails upon
apply
:That's because OAC works only when the
origin
block doesn't reference thecustom_origin_config
sub-block inside.All in all, currently S3 origin silently implies public access to the bucket, which would be an eyebrow-raising requirement.
At first glance,
cloudposse/cloudfront-s3-cdn/aws
may seem to be a viable alternative (it supports pre-existing S3 buckets), but it's not going to work - behind the scenes it assumes that both the CloudFront distribution and the bucket belong to the same AWS account (which is totally fine, that's just a different use case).Aside from the above, this PR includes the following improvements:
map()
referencesreferences