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

google_compute_backend_bucket with FORCE_CACHE_ALL automatically setting max_ttl to 0, causing 400 from API #10560

Assignees
Labels

Comments

@apottere
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

$ terraform -v
Terraform v1.0.11
on darwin_amd64
+ provider registry.terraform.io/hashicorp/google v4.1.0
+ provider registry.terraform.io/hashicorp/google-beta v4.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Affected Resource(s)

  • google_compute_backend_bucket

Terraform Configuration Files

resource "google_compute_backend_bucket" "bucket" {
  name        = "..."
  description = "..."
  bucket_name = "..."

  enable_cdn = true
  cdn_policy {
    cache_mode                   = "FORCE_CACHE_ALL"
    signed_url_cache_max_age_sec = 0
    default_ttl                  = 0
    client_ttl                   = 0
    serve_while_stale            = 0
  }
}

Debug Output

(partially redacted with ...)

[...]

PUT /compute/v1/projects/.../global/backendBuckets/...?alt=json HTTP/1.1
Host: compute.googleapis.com
User-Agent: Terraform/1.0.11 (+https://www.terraform.io) Terraform-Plugin-SDK/2.5.0 terraform-provider-google/4.1.0
Content-Length: 342
Content-Type: application/json
Accept-Encoding: gzip

{
 "bucketName": "...",
 "cdnPolicy": {
  "cacheMode": "FORCE_CACHE_ALL",
  "clientTtl": 0,
  "defaultTtl": 0,
  "maxTtl": 0,
  "negativeCaching": false,
  "serveWhileStale": 0,
  "signedUrlCacheMaxAgeSec": 0
 },
 "description": "...",
 "enableCdn": true,
 "name": "..."
}

[...]

HTTP/2.0 400 Bad Request
Alt-Svc: ...
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Mon, 15 Nov 2021 17:38:22 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
  "error": {
    "code": 400,
    "message": "Invalid value for field 'resource.cdnPolicy.cacheMode': 'FORCE_CACHE_ALL'. max_ttl must be specified with CACHE_ALL_STATIC cache_mode only.",
    "errors": [
      {
        "message": "Invalid value for field 'resource.cdnPolicy.cacheMode': 'FORCE_CACHE_ALL'. max_ttl must be specified with CACHE_ALL_STATIC cache_mode only.",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

Expected Behavior

Provider should omit the max_ttl field from the API request since it's not present in the terraform source.

Actual Behavior

Provider adds max_ttl=0 automatically, which causes the google API to return a 400 because max_ttl cannot be specified with FORCE_CACHE_ALL

Steps to Reproduce

  1. terraform apply

Important Factoids

I also tried manually removing the "max_ttl" field from the terraform state, but it was just re-added when applying.

@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 Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.