Skip to content
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

aws_cloudfront_distribution takes 10 mins for updating tags instead of 10 seconds #12138

Closed
schammah opened this issue Feb 23, 2020 · 8 comments · Fixed by #32865
Closed

aws_cloudfront_distribution takes 10 mins for updating tags instead of 10 seconds #12138

schammah opened this issue Feb 23, 2020 · 8 comments · Fixed by #32865
Assignees
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/cloudfront Issues and PRs that pertain to the cloudfront service.
Milestone

Comments

@schammah
Copy link

schammah commented Feb 23, 2020

Terraform Version

Affected Resource(s)

  • aws_cloudfront_distribution

Terraform Configuration Files

 Any cloudfront distribution creation, for which you update the TAGS

Debug Output

2020-02-23T10:42:21.752+0200 [DEBUG] plugin.terraform-provider-aws_v2.49.0_x4: ---[ REQUEST POST-SIGN ]-----------------------------
2020-02-23T10:42:21.752+0200 [DEBUG] plugin.terraform-provider-aws_v2.49.0_x4: PUT /2019-03-26/distribution/E34W9FSLFIIZ7E/config HTTP/1.1

files generated before apply

 # module.fe-stack.module.cf_distribution.module.cloudfront_dist.aws_cloudfront_distribution.cloudfront_distribution[0] will be updated in-place
  ~ resource "aws_cloudfront_distribution" "cloudfront_distribution" {
        active_trusted_signers         = {
            "enabled" = "false"
            "items.#" = "0"
        }
        aliases                        = [
            "acc-qa.autodesk.com",
        ]
        arn                            = "arn:aws:cloudfront::487986017923:distribution/E34W9FSLFIIZ7E"
        caller_reference               = "terraform-20200220094934939000000001"
        comment                        = "ACCWBPLT-C-UW2 CDN"
        domain_name                    = "d2up58t5iqm1zu.cloudfront.net"
        enabled                        = true
        etag                           = "E192WWI3HWHNWL"
        hosted_zone_id                 = "Z2FDTNDATAQYW2"
        http_version                   = "http2"
        id                             = "E34W9FSLFIIZ7E"
        in_progress_validation_batches = 0
        is_ipv6_enabled                = true
        last_modified_time             = "2020-02-23 08:22:39.079 +0000 UTC"
        price_class                    = "PriceClass_100"
        retain_on_delete               = false
        status                         = "Deployed"
      ~ tags                           = {
          - "Name"                = "ACCWBPLT-C-UW2 CDN"
          - "adsk:environment"    = "dev"
2020/02/23 10:40:00 [DEBUG] command: asking for input: "Do you want to perform these actions?"
          - "adsk:moniker"        = "ACCWBPLT-C-UW2"
          - "last_automation_run" = "2020-02-23T08:22:06Z"
          - "last_run_arn_id"     = "arn:aws:sts::487986017923:assumed-role/Application-Ops/vault-ldap-chammas-Application-Ops-1582446016-5474"
        } -> (known after apply)

Expected Behavior

Expected the provider to use the TagResource
If a change in tags occurs, therefor the run would take 10 secs and not 10 minutes
Same as if you modify a tag from the console

Actual Behavior

AWS Provider is using the 4: PUT /2019-03-26/distribution/E34W9FSLFIIZ7E/config HTTP/1.1
the PUT config API for the whole distribution which is taking 10 minutes to complete

  1. Create any cloudfront distribution
  2. Update the tags=**** parameter inside the resource
    3 runterraform apply , wait 10 minutes

Important Factoids

This might be occurring for other updates than tags only, it's worth investigating and modify the behavior of the provider on cloudfront distribution to be more efficient

@ghost ghost added the service/cloudfront Issues and PRs that pertain to the cloudfront service. label Feb 23, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Feb 23, 2020
@ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 21, 2020
@ewbankkit
Copy link
Contributor

This is a great use case for the proposed schema.ResourceData.HasChangeExcept method: hashicorp/terraform-plugin-sdk#457.

@ptierno
Copy link

ptierno commented Aug 11, 2022

👍 upvoting this. quite an annoying issue.

@jameshalsall
Copy link

I've recently seen this when modifying a distribution's origin too, except it's taking way longer than 10 mins and currently been running for 30 mins!

module.serverless.module.cloudfront.aws_cloudfront_distribution.api_distribution: Still modifying... [id=E3IIWP497XXANV, 30m0s elapsed]

@mfontanaar
Copy link

Upvoting. Takes 8 minutes to replace a tag on cloudfront_distribution. It's completely annoying.

@ewbankkit
Copy link
Contributor

func resourceDistributionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).CloudFrontConn(ctx)
params := &cloudfront.UpdateDistributionInput{
Id: aws.String(d.Id()),
DistributionConfig: expandDistributionConfig(d),
IfMatch: aws.String(d.Get("etag").(string)),
}
// Handle eventual consistency issues
err := retry.RetryContext(ctx, 1*time.Minute, func() *retry.RetryError {
_, err := conn.UpdateDistributionWithContext(ctx, params)
// ACM and IAM certificate eventual consistency
// InvalidViewerCertificate: The specified SSL certificate doesn't exist, isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain.
if tfawserr.ErrCodeEquals(err, cloudfront.ErrCodeInvalidViewerCertificate) {
return retry.RetryableError(err)
}
if err != nil {
return retry.NonRetryableError(err)
}
return nil
})

should add if d.HasChangesExcept("tags", "tags_all") guard.

@ewbankkit ewbankkit self-assigned this Aug 4, 2023
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 4, 2023
@github-actions github-actions bot added this to the v5.12.0 milestone Aug 4, 2023
@github-actions github-actions bot removed the bug Addresses a defect in current functionality. label Aug 10, 2023
@github-actions
Copy link

This functionality has been released in v5.12.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2023
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/cloudfront Issues and PRs that pertain to the cloudfront service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants