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

crash when bucket logging block is empty #13038

Assignees

Comments

@ghost
Copy link

ghost commented Nov 14, 2022

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.3.4
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.43.0
+ provider registry.terraform.io/hashicorp/google-beta v4.43.0
+ provider registry.terraform.io/hashicorp/null v3.2.0
+ provider registry.terraform.io/hashicorp/random v3.4.3
+ provider registry.terraform.io/hashicorp/time v0.9.1

Affected Resource(s)

  • google_storage_bucket

Terraform Configuration Files

variable "log-bucket" {
  type    = string
  default = ""
}
# set up a bucket for access logging, with some readonly grants
resource "google_storage_bucket" "_" {
  name                        = var.name
  location                    = "US"
  uniform_bucket_level_access = true
  public_access_prevention    = "enforced"

  logging {
    log_bucket = var.log-bucket
  }
  }

Debug Output

upon request

Panic Output

It's short enough IMO:

panic: interface conversion: interface {} is nil, not map[string]interface {}                                                                                                         
                                                                                                                                                                                      
goroutine 106 [running]:                                                                                                                                                              
github.com/hashicorp/terraform-provider-google/google.expandBucketLogging(...)                                                                                                        
        github.com/hashicorp/terraform-provider-google/google/resource_storage_bucket.go:970                                                                                          
github.com/hashicorp/terraform-provider-google/google.resourceStorageBucketUpdate(0x14000c55e00?, {0x102c4ec00?, 0x14000aa9000})                                                      
        github.com/hashicorp/terraform-provider-google/google/resource_storage_bucket.go:623 +0x1794                                                                                  
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x102c8f6a8?, {0x102c8f6a8?, 0x14000c6d320?}, 0xd?, {0x102c4ec00?, 0x14000aa9000?})                     
<snip>                                                                                                                     
                                                                                                                                                                                      
Error: The terraform-provider-google_v4.43.0_x5 plugin crashed!

Expected Behavior

A GCS bucket should be successfully provisioned, with no "log bucket" configured.

Actual Behavior

See above panic.

Steps to Reproduce

  1. terraform apply

Important Factoids

@ghost ghost added the bug label Nov 14, 2022
@github-actions github-actions bot added the crash label Nov 14, 2022
@ghost
Copy link
Author

ghost commented Nov 14, 2022

The workaround is to ensure that there is never an empty logging block:

  dynamic "logging" {
    for_each = var.log-bucket == "" ? [] : [var.log-bucket]
    content {
      log_bucket = var.log-bucket
    }
  }

This is a pretty involved workaround however, and it took me more than a couple minutest to realize this was the cause of the panic.

@edwardmedia edwardmedia self-assigned this Nov 15, 2022
c2thorn pushed a commit to GoogleCloudPlatform/magic-modules that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes hashicorp/terraform-provider-google#13038
modular-magician added a commit to modular-magician/terraform-provider-google-beta that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes hashicorp/terraform-provider-google#13038

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes hashicorp#13038

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to hashicorp/terraform-provider-google-beta that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes hashicorp/terraform-provider-google#13038

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes #13038

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to modular-magician/terraform-validator that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes hashicorp/terraform-provider-google#13038

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to GoogleCloudPlatform/terraform-validator that referenced this issue Nov 16, 2022
Co-authored-by: Edward Sun <sunedward@google.com>
Fixes hashicorp/terraform-provider-google#13038

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
googlerjk pushed a commit to googlerjk/magic-modules that referenced this issue Nov 22, 2022
googlerjk pushed a commit to googlerjk/magic-modules that referenced this issue Nov 25, 2022
kimihrr pushed a commit to kimihrr/kimiah-magic-modules that referenced this issue Dec 6, 2022
hao-nan-li pushed a commit to hao-nan-li/magic-modules that referenced this issue Dec 6, 2022
@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, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.