hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

[New Resource]: `aws_imagebuilder_lifecycle_policy` #34854

Open seanturner026 opened 6 months ago

seanturner026 commented 6 months ago

Description

Image Builder recently added a lifecycle manager that would be super handy in preventing the accumulation of AMIs (and EBS Snapshots?) which cost $$.

https://aws.amazon.com/about-aws/whats-new/2023/11/ec2-image-builder-lifecycle-management-deletion/

Requested Resource(s) and/or Data Source(s)

aws_imagebuild_lifecycle_policy

Potential Terraform Configuration

resource "aws_imagebuilder_lifecycle_policy" "this" {
  name          = string
  enabled       = bool
  description   = string
  resource_type = string // AMI_IMAGE | CONTAINER_IMAGE
  iam_role      = string // name or arn in awscli docs

  // Mutually exclusive?
  resource_selection {
    recipes {
      name             = string
      semantic_version = string
    }

    tags {
      key   = string
      value = string
    }
  }

  // See JSON Syntax in awscli docs
  policy_details {
  }

  lifecycle_rules {
    delete_rule    = bool
    deprecate_rule = bool
    disable_rule   = bool
  }

  tags = map(string)
}

References

https://aws.amazon.com/about-aws/whats-new/2023/11/ec2-image-builder-lifecycle-management-deletion/

Would you like to implement a fix?

No

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

bschaatsbergen commented 6 months ago

Hey @seanturner026 thanks for taking the time to raise this issue! πŸ‘πŸΌ Correct me if I'm wrong, but you're pointing to the EC2 Image Builder Lifecycle Policy right?

In that case, I think we should rename the resource: aws_imagebuilder_lifecycle_policy πŸ‘πŸΌ

API reference:

seanturner026 commented 6 months ago

Sounds good! Will update the original post to reflect that. I was looking in the AWS Console when I originally started creating this issue which refers to the resource as a lifecycle I believe.

bschaatsbergen commented 6 months ago

I'll happily pick this up too πŸš€

sophiecosgrove commented 5 months ago

Hey, are there any updates on this?

bschaatsbergen commented 5 months ago

Hey @sophiecosgrove, I'm still working on this - it's just in my "todo" of provider tickets I'm currently working on. I aim to have this done next week.

bschaatsbergen commented 4 months ago

Just a quick update: We're actively working on the issue in the background. However, it's taking a bit longer than expected because we need to update the entire image builder service in this provider to use the AWS SDK v2. Thanks for your patience.

Update as of March 1st: We're almost finished moving the imagebuilder service to V2. @DanielRieske has been helping me with this because there's a lot of work to be done.

Update as of March 11: We've implementation work and migration to the aws-sdk-v2, it became a really large PR and we need to loop in the core team for this change.

Update as of April 5: @DanielRieske is finalizing the last acceptance tests.

cc @ewbankkit

sethbacon commented 3 months ago

Any updates? Trying to wait patiently on this one :) ...

nestorcolt commented 2 months ago

a new AWS provider has been introduced "awscc" which hosts this feature with: https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/imagebuilder_lifecycle_policy

awscc_imagebuilder_lifecycle_policy (Resource) Resource schema for AWS::ImageBuilder::LifecyclePolicy

DanielRieske commented 2 months ago

Hi everyone, small update on this.

We are still actively working on getting this merged however we are running in a problem with certain arguments not being serialized. For this we have created an issue upstream https://github.com/aws/aws-sdk/issues/736 to fix for which we are waiting. As soon as this is picked up we will continue on the PR,

mobious999 commented 2 weeks ago

any updates?