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

spaces lifecycle policy not working as expected #752

Open
volleynator opened this issue Nov 30, 2021 · 6 comments
Open

spaces lifecycle policy not working as expected #752

volleynator opened this issue Nov 30, 2021 · 6 comments
Labels

Comments

@volleynator
Copy link

Bug Report

Describe the bug

I try to set up lifecycle policy which should expire and delete files after one day. The rule is applied according to s3cmd, however, files are not deleted, they remain inside the space.

Affected Resource(s)

  • digitalocean_spaces_bucket

Expected Behavior

Files should be deleted after one day

Actual Behavior

Files remain inside the bucked

Steps to Reproduce

  1. terraform apply -->

Terraform Configuration Files

resource "digitalocean_spaces_bucket" "postgres-backup-s3-bucket" {
  name   = "backup-space"
  region = "fra1"

  lifecycle_rule {
    id      = "lifecycle-rule"
    enabled = true
    expiration {
      days = 1
    }
  }
}

Expected behavior

Terraform v1.0.10
on linux_amd64
+ provider registry.terraform.io/digitalocean/digitalocean v2.14.0
+ provider registry.terraform.io/gavinbunney/kubectl v1.10.0
+ provider registry.terraform.io/hashicorp/helm v1.3.2
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.4
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/kreuzwerker/docker v2.11.0
+ provider registry.terraform.io/loafoe/htpasswd v0.9.1

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

Additional context

s3cmd output of s3cmd getlifecycle

<?xml version="1.0" ?>
<LifecycleConfiguration xmlns="https://s3.amazonaws.com/doc/2006-03-01/">
	<Rule>
		<ID>lifecycle-rule</ID>
		<Prefix/>
		<Status>Enabled</Status>
		<Expiration>
			<Days>1</Days>
		</Expiration>
	</Rule>
</LifecycleConfiguration>
@baznikin
Copy link

I confirm this issue! same behavior

@andrewsomething
Copy link
Member

Can you open a DigitalOcean support ticket so the team can take a closer look? If s3cmd getlifecycle is returning the lifecycle rule as defined in Terraform, that suggests that Terraform is working as expected and the issue is on the backend.

@baznikin
Copy link

Can you open a DigitalOcean support ticket so the team can take a closer look? If s3cmd getlifecycle is returning the lifecycle rule as defined in Terraform, that suggests that Terraform is working as expected and the issue is on the backend.

I suppose you are right, I'll reach them after some additional tests. s3cmd return lifecycle policy same as for OP.

@ChiefMateStarbuck
Copy link
Contributor

Hello @baznikin, have we been able to resolve this issue for you?

@baznikin
Copy link

baznikin commented Mar 28, 2023

Hello @ChiefMateStarbuck!
Yes, after some trials and tests lifecycle_rule works for me. My issue was wrong prefix value.
My final code looks almost same as OP policy. I dunno why, maybe something was fixed from API side...

lifecycle_rule {
  id                                     = "expire-backups"
  enabled                                = true
  abort_incomplete_multipart_upload_days = 2
  expiration {
    days = 15
  }
}

@zanoni23
Copy link

zanoni23 commented Aug 1, 2023

So lifecycle policy doesn't support versioning on the bucket being set to Suspended.
If you have versioning enabled then you supposedly have to add something for noncurrent_version_expiration.

If I create a new Space bucket via the Digital Ocean portal 'aws s3api get-bucket-versioning' returns nothing.

If I create a new Space bucket with Terraform using the latest Digital Ocean provider and set versioning to disabled, it creates a bucket that when queried returns versioning status as Suspended.

If I create a new Space bucket with Terraform using the latest Digital Ocean provider and don't have anything specifying 'versioning' at all, then get-bucket-versioning returns nothing.

I would have thought that setting versioning to disabled would have not configured any versioning at all. I guess I have to modify my Terraform module to workaround this. And also test to confirm that lifecycle option works with zero versioning config set (which I assume it does given it works for other people).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants