Merge pull request #8550 from tpounds/add-ami-owner-to-template

Add source AMI owner ID/name to build template
pull/8572/head
Megan Marsh 6 years ago committed by GitHub
commit 7411a8a6ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,8 @@ type BuildInfoTemplate struct {
BuildRegion string BuildRegion string
SourceAMI string SourceAMI string
SourceAMIName string SourceAMIName string
SourceAMIOwner string
SourceAMIOwnerName string
SourceAMITags map[string]string SourceAMITags map[string]string
} }
@ -31,6 +33,8 @@ func extractBuildInfo(region string, state multistep.StateBag) *BuildInfoTemplat
BuildRegion: region, BuildRegion: region,
SourceAMI: aws.StringValue(sourceAMI.ImageId), SourceAMI: aws.StringValue(sourceAMI.ImageId),
SourceAMIName: aws.StringValue(sourceAMI.Name), SourceAMIName: aws.StringValue(sourceAMI.Name),
SourceAMIOwner: aws.StringValue(sourceAMI.OwnerId),
SourceAMIOwnerName: aws.StringValue(sourceAMI.ImageOwnerAlias),
SourceAMITags: sourceAMITags, SourceAMITags: sourceAMITags,
} }
} }

@ -13,6 +13,8 @@ func testImage() *ec2.Image {
return &ec2.Image{ return &ec2.Image{
ImageId: aws.String("ami-abcd1234"), ImageId: aws.String("ami-abcd1234"),
Name: aws.String("ami_test_name"), Name: aws.String("ami_test_name"),
OwnerId: aws.String("ami_test_owner_id"),
ImageOwnerAlias: aws.String("ami_test_owner_alias"),
Tags: []*ec2.Tag{ Tags: []*ec2.Tag{
{ {
Key: aws.String("key-1"), Key: aws.String("key-1"),
@ -52,6 +54,8 @@ func TestInterpolateBuildInfo_extractBuildInfo_withSourceImage(t *testing.T) {
BuildRegion: "foo", BuildRegion: "foo",
SourceAMI: "ami-abcd1234", SourceAMI: "ami-abcd1234",
SourceAMIName: "ami_test_name", SourceAMIName: "ami_test_name",
SourceAMIOwner: "ami_test_owner_id",
SourceAMIOwnerName: "ami_test_owner_alias",
SourceAMITags: map[string]string{ SourceAMITags: map[string]string{
"key-1": "value-1", "key-1": "value-1",
"key-2": "value-2", "key-2": "value-2",

@ -287,4 +287,6 @@ variables are available:
- `SourceAMIName` - The source AMI Name (for example - `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI. build the AMI.
- `SourceAMIOwner` - The source AMI owner ID.
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object. - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.

@ -194,6 +194,8 @@ variables are available:
- `SourceAMIName` - The source AMI Name (for example - `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI. build the AMI.
- `SourceAMIOwner` - The source AMI owner ID.
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object. - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
## Tag Example ## Tag Example

@ -157,6 +157,8 @@ variables are available:
- `SourceAMIName` - The source AMI Name (for example - `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI. build the AMI.
- `SourceAMIOwner` - The source AMI owner ID.
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object. - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
-> **Note:** Packer uses pre-built AMIs as the source for building images. -> **Note:** Packer uses pre-built AMIs as the source for building images.

@ -176,6 +176,8 @@ variables are available:
- `SourceAMIName` - The source AMI Name (for example - `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI. build the AMI.
- `SourceAMIOwner` - The source AMI owner ID.
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object. - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
-> **Note:** Packer uses pre-built AMIs as the source for building images. -> **Note:** Packer uses pre-built AMIs as the source for building images.

@ -159,6 +159,8 @@ variables are available:
- `SourceAMIName` - The source AMI Name (for example - `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI. build the AMI.
- `SourceAMIOwner` - The source AMI owner ID.
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object. - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
## Custom Bundle Commands ## Custom Bundle Commands

Loading…
Cancel
Save