wata727 / packer-plugin-amazon-ami-management

Packer post-processor plugin for Amazon AMI management
Mozilla Public License 2.0
102 stars 26 forks source link

Improvement when call to ec2 DescribeLaunchTemplateVersions use ResolveAlias parameter to get the AMI ID. #430

Closed jorovipe97 closed 3 weeks ago

jorovipe97 commented 1 month ago

Hi, I'm using this plugin to delete old AMIs. However I found the following case:

When I create a LaunchTemplate that uses AWS Systems Manager parameters instead of AMI IDs in launch templates. The Cleaner::setLaunchTemplateUsed() does not detect the actual AMI ID as used.

Because we do not pass the ResolveAlias parameter to the DescribeLaunchTemplateVersions API call.

My proposal is to pass the paremter as follows:

versions, err := c.ec2conn.DescribeLaunchTemplateVersions(&ec2.DescribeLaunchTemplateVersionsInput{
        LaunchTemplateId: lt.LaunchTemplateId,
        ResolveAlias: true // TODO: Get this from packer template configuration.
})

If you like the proposal. I would like to contribute to the repo by creating a Pull Request with this change. I just need a link to the contributions guidelines or any advise you can give me.

Thanks in advance. And thanks for making this plugin, which is super useful.

A little background about me in case you find it useful

I am a full-stack engineer with 6 years of experience, I'm 3x AWS Certified (DevOps Profesional, Developer Associate, Solution Architect Associate). Here is my linkedin page with a more detailed CV.

wata727 commented 1 month ago

This proposal makes sense. PRs are welcome.

jorovipe97 commented 1 month ago

Nice, I will prepare a PR and let you know when is ready.

jorovipe97 commented 1 month ago

Hi @wata727 Just to let you know that I opened this PR with the discussed proposal. https://github.com/wata727/packer-plugin-amazon-ami-management/pull/431.

I needed to update the initial approach due to a limitation on the DescribeLaunchTemplateVersions API. I left details in the PR description.