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

aws_dlm_lifecycle_policy support for AMI policies #16520

Closed
evandam opened this issue Dec 2, 2020 · 11 comments · Fixed by #23880
Closed

aws_dlm_lifecycle_policy support for AMI policies #16520

evandam opened this issue Dec 2, 2020 · 11 comments · Fixed by #23880
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/dlm Issues and PRs that pertain to the dlm service.
Milestone

Comments

@evandam
Copy link

evandam commented Dec 2, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Following https://aws.amazon.com/about-aws/whats-new/2020/11/ami-lifecycle-management-available-data-lifecycle-manager/, it would be great to support creating policies to manage AMI lifecycles.

I believe this would look like allowing resource_types = ["AMI"] in addition to "VOLUME".

New or Affected Resource(s)

  • aws_dlm_lifecycle_policy

Potential Terraform Configuration

resource "aws_dlm_lifecycle_policy" "my_lifecycle_policy" {
  description        = "my_lifecycle_policy"
  execution_role_arn = aws_iam_role.dlm_lifecycle_role.arn
  state              = "ENABLED"

  policy_details {
    resource_types = "AMI"

    schedule {
      name = "daily"

      create_rule {
        interval      = 24
        interval_unit = "HOURS"
      }

      retain_rule {
        count = 3
      }
    }

    target_tags = {
      "role"    = "base"
    }
  }
}

References

@evandam evandam added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 2, 2020
@ghost ghost added the service/dlm Issues and PRs that pertain to the dlm service. label Dec 2, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Dec 2, 2020
@anGie44 anGie44 removed the needs-triage Waiting for first response or review from a maintainer. label Dec 2, 2020
@bacoboy-doordash
Copy link

bacoboy-doordash commented May 5, 2021

Looks like I'm in need of this. Any kind souls out there up for a little ❤️ on this enhancement?

@jlmoody
Copy link

jlmoody commented May 5, 2021

Looks like we got it for free at some point with the AWS SDK. Simply use: resource_types = "INSTANCE"

@brian-hogan-vgh
Copy link

Using resource_types="INSTANCE" doesn't create an AMI as described in the article linked in the issue description. It just specifies that your tags are on the EC2 Instance instead of the EBS Volume, and you want to snapshot all EBS Volumes associated with those tagged EC2 Instances. Similar to selecting this in the AWS console:

image

That will still only snapshot the EBS volumes associated with the EC2 instance. It doesn't create an AMI.

What's described in the article linked in the issue description is the ability to create EBS backed AMIs through a lifecycle management policy. Here is the selection in the console:

image

@jlmoody
Copy link

jlmoody commented May 6, 2021

@brian-hogan-vgh Thanks, for the correction. Digging deeper today...

@bacoboy-doordash
Copy link

Anything come of this exploration @jlmoody ?

@fdamstra
Copy link

I'm also interested in how this exploration went and/or what the blockers are toward implementation. Using AMIs would really ease restoration of an instance with multiple volumes.

@lifeofguenter
Copy link

lifeofguenter commented Aug 3, 2021

Did some digging. This is not resource_type but instead policy_type, see: https://docs.aws.amazon.com/dlm/latest/APIReference/API_PolicyDetails.html

Specify EBS_SNAPSHOT_MANAGEMENT to create a lifecycle policy that manages the lifecycle of Amazon EBS snapshots. Specify IMAGE_MANAGEMENT to create a lifecycle policy that manages the lifecycle of EBS-backed AMIs.

However, this is a field currently not supported by the resource: https://github.com/hashicorp/terraform-provider-aws/blob/main/aws/resource_aws_dlm_lifecycle_policy.go

As such it is currently defaulting to EBS_SNAPSHOT_MANAGEMENT (and thus working as is).

So:

  • policy_type needs to be added as a field (which should by default not set anything, as is currently the case)
  • might have to test out if there are other options missing - have only briefly checked

@giobaldac
Copy link

I too need this feature in order to use EBS-backed AMI policy and policy type Instance and a backup interval that's not limited to 24 hours at most. Thanks

@larkingb
Copy link

It would be great if this could be implemented

@github-actions
Copy link

github-actions bot commented Apr 7, 2022

This functionality has been released in v4.9.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

github-actions bot commented May 8, 2022

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.
If you have found a problem that seems similar to this, 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 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/dlm Issues and PRs that pertain to the dlm service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants