Packer: Share the images to other accounts

Created on 5 Feb 2016  路  8Comments  路  Source: hashicorp/packer

Hi

I am looking for an easy way to share the new ami image to other accounts.

I can use the template to generate an AWS AMI image, but I have to manually share it to other consolidated accounts every time.

Is the feature exist in packer?

buildeamazon question

Most helpful comment

looks I am closed to the feature:

https://github.com/mitchellh/packer/issues/479

https://www.packer.io/docs/builders/amazon-ebs.html#ami_users

ami_users (array of strings) - A list of account IDs that have access to launch the resulting AMI(s). By default no additional users other than the user creating the AMI has permissions to launch it.

All 8 comments

Seems this will be a new feature for builders of aws. Not sure if this will be same request for other cloud builders.

I did some research and hope to add a new feature after image is generated. Related aws cli command is:

aws ec2 modify-image-attribute --image-id ami-2bb65342 --launch-permission "{\"Add\":[{\"UserId\":\"123456789012\"}]}"

So I need a post-processors to share the images (assume the format as below)

  "post-processors": [
    {
      "type": "sharing",
      "account": ["123456789012", "210987654321"],
    }
  ],

I am not Golang developer, but seems to use Step_register_ami.go as start:

https://github.com/mitchellh/packer/blob/master/builder/amazon/instance/step_register_ami.go

find this code, but don't know how to use it to change LaunchPermission

https://github.com/mitchellh/packer/blob/master/builder/amazon/common/step_modify_ami_attributes.go#L70

looks I am closed to the feature:

https://github.com/mitchellh/packer/issues/479

https://www.packer.io/docs/builders/amazon-ebs.html#ami_users

ami_users (array of strings) - A list of account IDs that have access to launch the resulting AMI(s). By default no additional users other than the user creating the AMI has permissions to launch it.

ticket can be closed now. I did it with ami_users.

Nice!

ami_users cannot be used with encrypt_boot

@atrakic would you be able to use something else rather than ami_users?

@atrakic @WeekendsBull Please only use _GitHub Issues_ for reporting bugs and feature requests. Do not ask for general help here. Use _IRC #packer-tool on Freenode_ or the mailing list for that.

See https://www.packer.io/community/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wduncanfraser picture wduncanfraser  路  3Comments

craigsimon picture craigsimon  路  3Comments

mushon4 picture mushon4  路  3Comments

frezbo picture frezbo  路  3Comments

Nikoos picture Nikoos  路  3Comments