-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
About GCS Lifecycle Rules: Adding Unexpected Conditions #14044
About GCS Lifecycle Rules: Adding Unexpected Conditions #14044
Comments
@heiyohei which resource do you refer to? Can you share a config that can show your question? |
@edwardmedia |
@heiyohei does below config work for you? Here is the doc regarding the condition field. What problem are you facing? resource "google_storage_bucket" "auto-expire" {
name = "auto-expiring-bucket"
location = "US"
force_destroy = true
lifecycle_rule {
condition {
age = 3
}
action {
type = "Delete"
}
}
lifecycle_rule {
condition {
age = 1
}
action {
type = "AbortIncompleteMultipartUpload"
}
}
} |
I have the same issue. The below configuration creates the lifecycle rule with an additional and unwanted resource "google_storage_bucket" "bucket" {
name = "auto-expiring-bucket"
location = "US"
force_destroy = true
lifecycle_rule {
condition {
num_newer_versions = 8
}
action {
type = "Delete"
}
}
} |
@zenit89 @eraac I see what you presented. But I guess 0+ was added by the API, and the provider does not have much control over it. After apply, I don't see a permadiff. Do you see anything wrong from the terraform perspective? Also you able to create buckets with the lifecycle using other methods that can avoid 0+? |
I see where the problem is. This is a bug in the provider. The provider sends 0 for age when it is not set. Related to #12917 |
Here's some notes from when I investigated. Config I used: resource "google_storage_bucket" "test" {
name = "test-issue-14044"
location = "US"
force_destroy = true
public_access_prevention = "enforced"
lifecycle_rule {
condition {
with_state = "ARCHIVED"
}
action {
type = "Delete"
}
}
} When creating the bucket using the {
... omitted some stuff ...
"lifecycle_rule": [
{
"action": [
{
"storage_class": "",
"type": "Delete"
}
],
"condition": [
{
"age": null,
"created_before": "",
"custom_time_before": "",
"days_since_custom_time": null,
"days_since_noncurrent_time": null,
"matches_prefix": [],
"matches_storage_class": [],
"matches_suffix": [],
"noncurrent_time_before": "",
"num_newer_versions": null,
"with_state": "ARCHIVED"
}
]
}
],
} The issue appears to be at this point:
This creates a value that sets []interface {}{map[string]interface {}{"age":0, "created_before":"", "custom_time_before":"", "days_since_custom_time":0, "days_since_noncurrent_time":0, "matches_prefix":[]interface {}{}, "matches_storage_class":[]interface {}{}, "matches_suffix":[]interface {}{}, "noncurrent_time_before":"", "num_newer_versions":0, "with_state":"ARCHIVED"}} This function is invoked by the create and update functions for the resource. |
b/278745929 |
It hasn't been repaired |
I've created a draft PR that uses a failing test to confirm the problem exists, but I can't find a way to solve it. Re: an earlier comment from @SarahFrench:
It looks like the rule condition comes into the referenced function with that value already set, which you can confirm by adding the line So far my testing has confirmed that you can't unset the Age field on update or have it unset during create, and any attempt to will result in the field being set to 0. Notably This issue will have to be solved higher up in the stack than I'm immediately familiar with, as it appears that the current data handling model isn't set up with work with |
As far as I can see this issue should be fixed in the provider version 5.9.0 (see the last item in the release notes). I just set the provider version to 5.9.0, deleted one lifecycle rule and ran So this issue is not fixed and should be reopened. |
Can confirm, the issue is still unfixed in 5.9.0. Please re-open this Issue. |
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. |
The condition "after 0 days since the object was created" is set in the object's conditions, even though it is not specified. Please advise how to delete this condition.
■ Terraform Version
1.37
■ Terraform Configuration Files
Maximum number of versions per object
lifecycle_rule {
action {
type = var.gcs_param_con.type
}
condition {
num_newer_versions = each.value.num_newer_versions
with_state = var.gcs_param_con.with_state_ver
}
}
Non-Current Version Expiration Date
lifecycle_rule {
action {
type = var.gcs_param_con.type
}
condition {
days_since_noncurrent_time = each.value.days_since_noncurrent_time
}
}
Affected Resource(s)
google_storage_bucket
The text was updated successfully, but these errors were encountered: