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

s3_bucket_lifecycle_configuration: Fix import, diffs #23144

Merged
merged 8 commits into from
Feb 15, 2022

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented Feb 11, 2022

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #23129
Closes #23132

Import test starting configuration (corresponding to #23129 and #23132):

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.74.1"
    }
  }
}

resource "aws_s3_bucket" "example" {
  bucket = "barrameda-994617143"

  lifecycle_rule {
    id      = "log-expiration"
    enabled = true
    prefix  = ""

    transition {
      days          = 30
      storage_class = "STANDARD_IA"
    }

    transition {
      days          = 180
      storage_class = "GLACIER"
    }
  }
}

resource "aws_s3_bucket" "example2" {
  bucket = "valladolid-817999296"

  lifecycle_rule {
    id      = "Keep previous version 30 days, then in Glacier another 60"
    enabled = true

    noncurrent_version_transition {
      days          = 30
      storage_class = "GLACIER"
    }

    noncurrent_version_expiration {
      days = 90
    }
  }

  lifecycle_rule {
    id                                     = "Delete old incomplete multi-part uploads"
    enabled                                = true
    abort_incomplete_multipart_upload_days = 7
  }
}

4.0 configs for importing:

terraform {
  required_providers {
    aws = {
      source  = "yakdriver.com/hashicorp/aws"
      version = ">= 1.0"
    }
  }
}

resource "aws_s3_bucket" "example" {
  bucket = "barrameda-994617143"
}

resource "aws_s3_bucket_lifecycle_configuration" "example" {
  bucket = aws_s3_bucket.example.id

  rule {
    id     = "log-expiration"
    status = "Enabled"
    prefix = ""

    transition {
      days          = 30
      storage_class = "STANDARD_IA"
    }

    transition {
      days          = 180
      storage_class = "GLACIER"
    }
  }
}

resource "aws_s3_bucket" "example2" {
  bucket = "valladolid-817999296"
}

resource "aws_s3_bucket_lifecycle_configuration" "example2" {
  bucket = aws_s3_bucket.example2.id

  rule {
    id     = "Keep previous version 30 days, then in Glacier another 60"
    status = "Enabled"

    noncurrent_version_transition {
      noncurrent_days = 30
      storage_class   = "GLACIER"
    }

    noncurrent_version_expiration {
      noncurrent_days = 90
    }
  }

  rule {
    id     = "Delete old incomplete multi-part uploads"
    status = "Enabled"

    abort_incomplete_multipart_upload {
      days_after_initiation = 7
    }
  }
}

Output from import:

% terraform import aws_s3_bucket.example barrameda-994617143
aws_s3_bucket.example: Importing from ID "barrameda-994617143"...
aws_s3_bucket.example: Import prepared!
  Prepared aws_s3_bucket for import
aws_s3_bucket.example: Refreshing state... [id=barrameda-994617143]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
% terraform import aws_s3_bucket_lifecycle_configuration.example barrameda-994617143
aws_s3_bucket_lifecycle_configuration.example: Importing from ID "barrameda-994617143"...
aws_s3_bucket_lifecycle_configuration.example: Import prepared!
  Prepared aws_s3_bucket_lifecycle_configuration for import
aws_s3_bucket_lifecycle_configuration.example: Refreshing state... [id=barrameda-994617143]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
% terraform import aws_s3_bucket.example2 valladolid-817999296
aws_s3_bucket.example2: Importing from ID "valladolid-817999296"...
aws_s3_bucket.example2: Import prepared!
  Prepared aws_s3_bucket for import
aws_s3_bucket.example2: Refreshing state... [id=valladolid-817999296]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
% terraform import aws_s3_bucket_lifecycle_configuration.example2 valladolid-817999296
aws_s3_bucket_lifecycle_configuration.example2: Importing from ID "valladolid-817999296"...
aws_s3_bucket_lifecycle_configuration.example2: Import prepared!
  Prepared aws_s3_bucket_lifecycle_configuration for import
aws_s3_bucket_lifecycle_configuration.example2: Refreshing state... [id=valladolid-817999296]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
% terraform apply
aws_s3_bucket.example: Refreshing state... [id=barrameda-994617143]
aws_s3_bucket.example2: Refreshing state... [id=valladolid-817999296]
aws_s3_bucket_lifecycle_configuration.example2: Refreshing state... [id=valladolid-817999296]
aws_s3_bucket_lifecycle_configuration.example: Refreshing state... [id=barrameda-994617143]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Output from acceptance testing:

$ make testacc TESTS=TestAccXXX PKG=ec2

...

@github-actions github-actions bot added service/s3 Issues and PRs that pertain to the s3 service. size/XS Managed by automation to categorize the size of a PR. and removed service/s3 Issues and PRs that pertain to the s3 service. labels Feb 11, 2022
@ewbankkit ewbankkit added the service/s3 Issues and PRs that pertain to the s3 service. label Feb 12, 2022
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. and removed documentation Introduces or discusses updates to documentation. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 15, 2022
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 15, 2022
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Feb 15, 2022
@YakDriver YakDriver added this to the v4.1.0 milestone Feb 15, 2022
@YakDriver YakDriver merged commit 45719a7 into main Feb 15, 2022
@YakDriver YakDriver deleted the b-s3-lifecycle-churn branch February 15, 2022 15:43
github-actions bot pushed a commit that referenced this pull request Feb 15, 2022
@github-actions
Copy link

This functionality has been released in v4.1.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. service/s3 Issues and PRs that pertain to the s3 service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_s3_bucket_lifecycle_configuration and two rules with same prefix Resource churn with v4 S3 refactoring
2 participants