From 6d29ec956b0371c4f0936e2b1a582589016b89a3 Mon Sep 17 00:00:00 2001 From: nitrocode Date: Fri, 22 May 2020 07:17:38 -0400 Subject: [PATCH] Added SourceAMICreationDate --- .../amazon/common/interpolate_build_info.go | 26 ++++++++++--------- .../common/interpolate_build_info_test.go | 12 +++++---- website/pages/docs/builders/amazon/chroot.mdx | 1 + website/pages/docs/builders/amazon/ebs.mdx | 1 + .../docs/builders/amazon/ebssurrogate.mdx | 1 + .../pages/docs/builders/amazon/ebsvolume.mdx | 1 + .../pages/docs/builders/amazon/instance.mdx | 1 + 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/builder/amazon/common/interpolate_build_info.go b/builder/amazon/common/interpolate_build_info.go index 3a2ab4611..df11808cd 100644 --- a/builder/amazon/common/interpolate_build_info.go +++ b/builder/amazon/common/interpolate_build_info.go @@ -8,12 +8,13 @@ import ( ) type BuildInfoTemplate struct { - BuildRegion string - SourceAMI string - SourceAMIName string - SourceAMIOwner string - SourceAMIOwnerName string - SourceAMITags map[string]string + BuildRegion string + SourceAMI string + SourceAMICreationDate string + SourceAMIName string + SourceAMIOwner string + SourceAMIOwnerName string + SourceAMITags map[string]string } func extractBuildInfo(region string, state multistep.StateBag, generatedData *builder.GeneratedData) *BuildInfoTemplate { @@ -31,12 +32,13 @@ func extractBuildInfo(region string, state multistep.StateBag, generatedData *bu } buildInfoTemplate := &BuildInfoTemplate{ - BuildRegion: region, - SourceAMI: aws.StringValue(sourceAMI.ImageId), - SourceAMIName: aws.StringValue(sourceAMI.Name), - SourceAMIOwner: aws.StringValue(sourceAMI.OwnerId), - SourceAMIOwnerName: aws.StringValue(sourceAMI.ImageOwnerAlias), - SourceAMITags: sourceAMITags, + BuildRegion: region, + SourceAMI: aws.StringValue(sourceAMI.ImageId), + SourceAMICreationDate: aws.StringValue(sourceAMI.CreationDate), + SourceAMIName: aws.StringValue(sourceAMI.Name), + SourceAMIOwner: aws.StringValue(sourceAMI.OwnerId), + SourceAMIOwnerName: aws.StringValue(sourceAMI.ImageOwnerAlias), + SourceAMITags: sourceAMITags, } generatedData.Put("SourceAMIName", buildInfoTemplate.SourceAMIName) return buildInfoTemplate diff --git a/builder/amazon/common/interpolate_build_info_test.go b/builder/amazon/common/interpolate_build_info_test.go index e85e167d6..a29f82dac 100644 --- a/builder/amazon/common/interpolate_build_info_test.go +++ b/builder/amazon/common/interpolate_build_info_test.go @@ -13,6 +13,7 @@ import ( func testImage() *ec2.Image { return &ec2.Image{ ImageId: aws.String("ami-abcd1234"), + CreationDate: aws.String("ami_test_creation_date"), Name: aws.String("ami_test_name"), OwnerId: aws.String("ami_test_owner_id"), ImageOwnerAlias: aws.String("ami_test_owner_alias"), @@ -59,11 +60,12 @@ func TestInterpolateBuildInfo_extractBuildInfo_withSourceImage(t *testing.T) { buildInfo := extractBuildInfo("foo", state, &generatedData) expected := BuildInfoTemplate{ - BuildRegion: "foo", - SourceAMI: "ami-abcd1234", - SourceAMIName: "ami_test_name", - SourceAMIOwner: "ami_test_owner_id", - SourceAMIOwnerName: "ami_test_owner_alias", + BuildRegion: "foo", + SourceAMI: "ami-abcd1234", + SourceAMICreationDate: "ami_test_creation_date", + SourceAMIName: "ami_test_name", + SourceAMIOwner: "ami_test_owner_id", + SourceAMIOwnerName: "ami_test_owner_alias", SourceAMITags: map[string]string{ "key-1": "value-1", "key-2": "value-2", diff --git a/website/pages/docs/builders/amazon/chroot.mdx b/website/pages/docs/builders/amazon/chroot.mdx index 1e4d00dbe..1aaaf22dd 100644 --- a/website/pages/docs/builders/amazon/chroot.mdx +++ b/website/pages/docs/builders/amazon/chroot.mdx @@ -289,6 +289,7 @@ variables are available: building the AMI. - `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build the AMI. +- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`). - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI. diff --git a/website/pages/docs/builders/amazon/ebs.mdx b/website/pages/docs/builders/amazon/ebs.mdx index 559eb0924..8763faa87 100644 --- a/website/pages/docs/builders/amazon/ebs.mdx +++ b/website/pages/docs/builders/amazon/ebs.mdx @@ -193,6 +193,7 @@ variables are available: building the AMI. - `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build the AMI. +- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`). - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI. diff --git a/website/pages/docs/builders/amazon/ebssurrogate.mdx b/website/pages/docs/builders/amazon/ebssurrogate.mdx index 0cb80b307..54b59cfee 100644 --- a/website/pages/docs/builders/amazon/ebssurrogate.mdx +++ b/website/pages/docs/builders/amazon/ebssurrogate.mdx @@ -155,6 +155,7 @@ variables are available: building the AMI. - `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build the AMI. +- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`). - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI. diff --git a/website/pages/docs/builders/amazon/ebsvolume.mdx b/website/pages/docs/builders/amazon/ebsvolume.mdx index 4bbd490e8..26470661e 100644 --- a/website/pages/docs/builders/amazon/ebsvolume.mdx +++ b/website/pages/docs/builders/amazon/ebsvolume.mdx @@ -176,6 +176,7 @@ variables are available: building the AMI. - `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build the AMI. +- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`). - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI. diff --git a/website/pages/docs/builders/amazon/instance.mdx b/website/pages/docs/builders/amazon/instance.mdx index 5c632971c..8345a6e0a 100644 --- a/website/pages/docs/builders/amazon/instance.mdx +++ b/website/pages/docs/builders/amazon/instance.mdx @@ -161,6 +161,7 @@ variables are available: building the AMI. - `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build the AMI. +- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`). - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI.