-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Enhancement] r/aws_cloudfront_distribution: Added SaaS Manager configuration support for distributions #44034
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
base: main
Are you sure you want to change the base?
Conversation
finished implementation
updated tests
✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible. |
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
@ewbankkit @justinretzolk Hi I'm current working on another new resource that is part of Cloudfront's SaaS manager, but acceptance testing it requires the changes in this PR. My team suggested I write tests for the new resource using pre-deployed resources on my own AWS account so I can meet the deadline to publish the PR for that, but I understand its bad practice. Will this get merged soon? Or I was thinking I could write the tests normally and make it clear in my PR that this PR should be merged first. |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
N/A
Description
IMPORTANT: This PR is part of a set of PRs for AWS Cloudfront SaaS Manager support. Please merge this PR before #44181, #44183, #44184, and #44185 as those features rely on these changes.
This PR introduces support for AWS Cloudfront's latest SaaS Manager feature and allows users to now deploy Multi-Tenant Distributions using the new
connection_mode
andtenant_config
arguments.connection_mode
is used to determine whether the deployed Distribution is direct or multi-tenant, by setting its value todirect
ortenant-only
respectively. If unspecified,direct
is usedtenant_config
is a multi-tenant only argument that allows tenants of a distribution to inherit specific configurationsSchema Additions:
Configuration Validation
Multi-tenant Distributions do not support many regular Distribution configurations. These are
is_ipv6_enable
,price_class
,aliases
,staging
,continuous_deployment_policy_id
, and cache behaviour related configurations for TTL,forwarded_values
,smooth_streaming
, andtrusted_signers
. In order to deploy a Multi-tenant Distribution, the AWS API expects these arguments to be completely absent from the plan (eg.aliases: nil
oraliases: []
will return a configuration error,aliases:
must not exist in the plan at all when it is passed to AWS). The current distribution implementation will populate the plan with these arguments even if the user did not specify them in their Terraform resource definition, meaning Multi-tenant Distribution deployment will fail regardless of whether the user configured their resource illegally.To fix this, I've modified the
expandDistributionConfig
,expandCacheBehaviours
, andexpandDefaultCacheBehaviour
to check what type of distribution is being created before generating the plan. If the user defines illegal arguments while creating a Multi-tenant Distribution, an error will be returned and creation will fail. If the user has not defined them, they won't be added to the plan even if Terraform assigns them default values. Refer to 4e025fb for full validation changes.A small issue however, is that for arguments that are defined with default values in the distribution schema (eg.
is_ipv6_enabled
) or defined as Optional and not Computed (eg.smooth_streaming
), there is no way to distinguish if the user did not set these arguments at all for the distribution so Terraform provided default values for them, or if the user themself set the arguments with default values (eg. user setsis_ipv6_enabled = false
vs user leavesis_ipv6_enabled
blank and Terraform sets it to false). As a result, the user will not receive an error when setting default values for an illegal argument with such properties. This does not impact actual distribution resource deployment but only user visibility. Fixing this issue would require changes on the AWS API side to accept blank illegal arguments, or changes to how or when Terraform sets default values.Testing
To ensure the afore mentioned configuration checking changes did not cause any regressions or issues for regular Distribution deployments, I ran the existing acceptance tests to ensure they still passed and behaved as expected. I've also added 2 acceptance tests
TestAccCloudFrontDistribution_multiTenantWithConfig
andTestAccCloudFrontDistribution_minimalMultiTenant
for multi-tenant deployments, and 9TestAccCloudFrontDistribution_multiTenantValidation
tests for illegal configuration validation.Relations
Updates
aws_cloudfront_distribution
as requested by #42409References
General SaaS information
SaaS unsupported features
Output from Acceptance Testing