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

Amazon EBS Volume builder should support setting EBS Volume Snapshot Description #470

Closed
saxonww opened this issue Mar 21, 2024 · 3 comments · Fixed by #471
Closed

Amazon EBS Volume builder should support setting EBS Volume Snapshot Description #470

saxonww opened this issue Mar 21, 2024 · 3 comments · Fixed by #471

Comments

@saxonww
Copy link
Contributor

saxonww commented Mar 21, 2024

Description

The Amazon EBS Volume builder enables Packer to create EBS Volume Snapshots. It supports setting snapshot_tags, snapshot_users, and snapshot_groups, but not snapshot description.

The builder supports sharing snapshots cross-account via snapshot_users. However, tag metadata set via snapshot_tags is not visible cross-account, leaving only the snapshot ID, owner (account ID), and KMS key ID visible on snapshots created via the Packer AWS EBS Volume builder.

This feature request is to add the capability to set snapshot description.

Use Case(s)

Any process that leverages an organization's internal versioning scheme would benefit from this feature, as the Description metadata is the simplest way to communicate version information.

A concrete example would be a CI process which packages a product release as an EBS volume snapshot. Without setting Description, consumers would have to maintain a separate mapping of snapshot ID to version and/or manually configure by unique snapshot ID when working cross-account.

Potential configuration

variable "ami_name" {}
variable "ami_owner" {}
variable "product_name" {}
variable "product_version" {}
variable "region" {}
variable "user_accounts" {}

data "amazon-ami" "base" {
    filters = {
        virtualization-type = "hvm"
        name                = var.ami_name
        root-device-type    = "ebs"
    }
    owners      = [var.ami_owner]
    most_recent = true
    region      = var.region
}
 
source "amazon-ebsvolume" "main" {
    region               = var.region
    ssh_username         = "ec2-user"
    instance_type        = "t3.nano"
    source_ami           = data.amazon-ami.base.id

    ebs_volumes {
        device_name = "/dev/xvda"
        volume_type = "gp3"
        delete_on_termination = true
        volume_size = 10
    }

    ebs_volumes {
        volume_type = "gp3"
        device_name = "/dev/xvdf"
        delete_on_termination = true
        volume_size = 3

        snapshot_description = "${var.product_name}-${var.product_version}"
        snapshot_users = var.user_accounts
        snapshot_volume = true
    }
}

build {
    # do build stuff
}

Potential References

@lbajolet-hashicorp
Copy link
Contributor

Hi @saxonww,

That is a good idea indeed, and this should be reasonably easy to implement!
We probably won't do it too soon though since we're a bit busy with other things right now, but at first glance this should essentially be adding the Description to the CreateImageInput call for create ami, would you be available to open a PR for this? We'd be glad to help if that interests you, please let us know what you think!

@saxonww
Copy link
Contributor Author

saxonww commented Mar 25, 2024

Hi @saxonww,

That is a good idea indeed, and this should be reasonably easy to implement! We probably won't do it too soon though since we're a bit busy with other things right now, but at first glance this should essentially be adding the Description to the CreateImageInput call for create ami, would you be available to open a PR for this? We'd be glad to help if that interests you, please let us know what you think!

Yeah I think so, I'm concerned about getting a good test written - I haven't looked at how to do that - but the rest of it seems easy.

@lbajolet-hashicorp
Copy link
Contributor

lbajolet-hashicorp commented Mar 25, 2024

Yeah as far as testing goes this is likely a job for acceptance tests, I suggest you try the feature in your account, and we can write one after that, which we can then run in our account each week (there's a recurring job each Sunday for those).
I can assist when comes time to write the acceptance test, no worries about that!

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

Successfully merging a pull request may close this issue.

2 participants