-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
resource/cloudfront_distribution: Added ordered cache behaviors #4117
resource/cloudfront_distribution: Added ordered cache behaviors #4117
Conversation
if v, ok := d.GetOk("ordered_cache_behavior"); ok { | ||
distributionConfig.CacheBehaviors = expandCacheBehaviors(v.([]interface{})) | ||
} else { | ||
distributionConfig.CacheBehaviors = expandCacheBehaviorsDeprecated(d.Get("cache_behavior").(*schema.Set)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old behavior is kept under a expandCacheBehaviorsDeprecated function, which contains the exact same previous code.
cb.SmoothStreaming = aws.Bool(v.(bool)) | ||
} | ||
if v, ok := m["allowed_methods"]; ok { | ||
cb.AllowedMethods = expandAllowedMethodsDeprecated(v.([]interface{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also has the old behavior. The new behavior is a Set rather than lists for allowed_methods & cached_method
@Ninir hmm I wonder if you caught this right before the CloudFront SDK changed, but can you ensure this is rebased to handle I'm currently getting test failures for everything in TC using
|
@bflad just rebased and currently running tests (which are passing right now) |
@bflad Would it be possible to trigger tests in TC? still has the
Thanks! |
@Ninir can you push up the rebase commit? 😄 Its not showing up in Github and still throwing the same error in TC. |
1fc3865
to
1791517
Compare
@bflad Yep done. Tried a few things to tweak that setting without success. Is there anything you do on TC to fix this panic? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! 🚀 LGTM
12 tests passed (all tests)
=== RUN TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (1.55s)
=== RUN TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (1.73s)
=== RUN TestAccAWSCloudFrontDistribution_HTTP11Config
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (1535.58s)
=== RUN TestAccAWSCloudFrontDistribution_S3OriginWithTags
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (1536.80s)
=== RUN TestAccAWSCloudFrontDistribution_orderedCacheBehavior
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (1538.30s)
=== RUN TestAccAWSCloudFrontDistribution_S3Origin
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (1539.00s)
=== RUN TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (1539.26s)
=== RUN TestAccAWSCloudFrontDistribution_multiOrigin
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (1540.74s)
=== RUN TestAccAWSCloudFrontDistribution_customOrigin
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (1541.16s)
=== RUN TestAccAWSCloudFrontDistribution_noOptionalItemsConfig
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (1542.22s)
=== RUN TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (1543.61s)
=== RUN TestAccAWSCloudFrontDistribution_importBasic
--- PASS: TestAccAWSCloudFrontDistribution_importBasic (1543.98s)
This has been released in version 1.15.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
@Ninir First of all, thanks for this fix! 🎉 I did a test by importing an existing CloudFront distribution with v1.15.0, but apparently it still uses the now deprecated Also, is it safe to update a Terraform-managed distribution by replacing all |
Hey @danielfm It indeed still uses the old behaviour. I tried to come up with solutions about migrating the old behaviour to the new one without success: migrating the schema is a tough task that was nearly impossible to handle in some cases, hence the "opt-in" proposal. Since both of these 2 attributes are conflicting with the other one, you can only set one or the other, meaning if you try to set ordered ones in place of obsolete ones, there will just be a replacement & Distribution update. Hope it's clear enough! :) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Description
This allows configuring CloudFront cache behavior precedence.
This is an alternative approach to #1269 and heavily inspired by it.
While the other PR is a breaking change and thus does not allow a quick merge, this approach introduces a new attribute called
ordered_cache_behavior
, deprecatingcache_behavior
.This work is backward-compatible as it keeps the old behaviour and adds a new one, mainly benefiting from new methods. The previous methods are marked and named as
XXXDeprecated
.It also fixes the sub-options
allowed_methods
andcached_methods
which were lists whereas it should have been set.Alternative & better names for the new attribute are welcomed :)
Sidenote: panic when running tests after 2hours, main tests + ordered cache behaviors are passing but might be a good idea to run a TC test.
Related issues
#188
#1269
Test