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

On module "buckets", using action type "SetStorageClass" on the "lifecycle_rules" is not working #263

Open
oralmeida opened this issue Jul 27, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@oralmeida
Copy link

oralmeida commented Jul 27, 2023

TL;DR

Using module "buckets" when I specify a type different from "delete" or "AbortIncompleteMultipartUpload" terraform plan always fail with error "Error: googleapi: Error 400: Invalid argument., invalid"

Uncommenting type = "Delete" and commenting type = "SetStorageClass" and storageClass = "NEARLINE" terraform apply works fine:

locals {
buckets = {
"stream360" = { # Name of the bucket prefix
names = ["videos"] # Name of the bucket suffix
labels = {
environment = local.environment
}
lifecycle_rules = [{
action = {
type = "Delete"
#type = "SetStorageClass"
#storageClass = "NEARLINE"
}
condition = {
age = 60
}
}]
location = upper(var.region)
versioning = {
first = true
}
storage_class = "STANDARD"
public_access_prevention = "enforced"
randomize_suffix = true
set_admin_roles = true
set_viewer_roles = true
bucket_policy_only = {
"videos" = true
}
}
}
}

module "buckets" {
for_each = local.buckets
source = "terraform-google-modules/cloud-storage/google"
prefix = each.key
project_id = local.project_id
names = each.value.names
randomize_suffix = each.value.randomize_suffix
labels = each.value.labels
lifecycle_rules = each.value.lifecycle_rules
location = each.value.location
versioning = each.value.versioning
storage_class = each.value.storage_class
public_access_prevention = each.value.public_access_prevention
set_admin_roles = each.value.set_admin_roles
set_viewer_roles = each.value.set_viewer_roles
bucket_policy_only = each.value.bucket_policy_only
depends_on = [module.projects_iam_bindings]
}

Expected behavior

Bucket is created with lifecycle based on SetStorageClass

Observed behavior

Error on terraform apply:

"Error: googleapi: Error 400: Invalid argument., invalid"

Terraform Configuration

# buckets.tf

locals {
  # Buckets definition
  buckets = {
    "stream360" = {      # Name of the bucket prefix
      names = ["videos"] # Name of the bucket suffix
      labels = {
        environment = local.environment
      }
      lifecycle_rules = [{
        action = {
          #type         = "Delete"
          type         = "SetStorageClass"
          storageClass = "NEARLINE"
        }
        condition = {
          age          = 60
        }
      }]
      location = upper(var.region)
      versioning = {
        first = true
      }
      storage_class = "STANDARD"
      public_access_prevention = "enforced"
      randomize_suffix         = true
      set_admin_roles          = true
      set_viewer_roles         = true
      bucket_policy_only       = {
        "videos" = true  
      }
    }
  }  
}

# Buckets Creation
module "buckets" {
  for_each                 = local.buckets
  source                   = "terraform-google-modules/cloud-storage/google"
  prefix                   = each.key
  project_id               = local.project_id
  names                    = each.value.names
  randomize_suffix         = each.value.randomize_suffix
  labels                   = each.value.labels
  lifecycle_rules          = each.value.lifecycle_rules 
  location                 = each.value.location
  versioning               = each.value.versioning
  storage_class            = each.value.storage_class
  public_access_prevention = each.value.public_access_prevention
  set_admin_roles          = each.value.set_admin_roles
  set_viewer_roles         = each.value.set_viewer_roles
  bucket_policy_only       = each.value.bucket_policy_only 
  depends_on               = [module.projects_iam_bindings]
}

Terraform Version

Terraform v1.3.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/external v2.3.1
+ provider registry.terraform.io/hashicorp/google v4.51.0
+ provider registry.terraform.io/hashicorp/google-beta v4.51.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1

Your version of Terraform is out of date! The latest version
is 1.5.3. You can update by downloading from https://www.terraform.io/downloads.html

Additional information

Creating lifecycle directly on Google Console works without any issue
I also noticed from the examples available that using module "cloud_storage" lifecycle rule using action type "SetStorageClass" seems to work

@oralmeida oralmeida added the bug Something isn't working label Jul 27, 2023
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Sep 26, 2023
@oralmeida
Copy link
Author

Let me know if you need further information

@github-actions github-actions bot removed the Stale label Sep 27, 2023
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Nov 26, 2023
@oralmeida
Copy link
Author

Any new on this?

@github-actions github-actions bot removed the Stale label Nov 27, 2023
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Jan 27, 2024
@oralmeida
Copy link
Author

.

@github-actions github-actions bot removed the Stale label Jan 29, 2024
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Mar 30, 2024
@oralmeida
Copy link
Author

oralmeida commented Apr 1, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

.

@github-actions github-actions bot removed the Stale label Apr 1, 2024
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label May 31, 2024
@oralmeida
Copy link
Author

.

@github-actions github-actions bot removed the Stale label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant