set sha
This commit is contained in:
parent
82637715cf
commit
e51651c34a
|
@ -19,6 +19,23 @@ provider "registry.terraform.io/hashicorp/aws" {
|
|||
]
|
||||
}
|
||||
|
||||
provider "registry.terraform.io/hashicorp/external" {
|
||||
version = "2.0.0"
|
||||
hashes = [
|
||||
"h1:6S7hqjmUnoAZ5D/0F1VlJZKSJsUIBh7Ro0tLjGpKO0g=",
|
||||
"zh:07949780dd6a1d43e7b46950f6e6976581d9724102cb5388d3411a1b6f476bde",
|
||||
"zh:0a4f4636ff93f0644affa8474465dd8c9252946437ad025b28fc9f6603534a24",
|
||||
"zh:0dd7e05a974c649950d1a21d7015d3753324ae52ebdd1744b144bc409ca4b3e8",
|
||||
"zh:2b881032b9aa9d227ac712f614056d050bcdcc67df0dc79e2b2cb76a197059ad",
|
||||
"zh:38feb4787b4570335459ca75a55389df1a7570bdca8cdf5df4c2876afe3c14b4",
|
||||
"zh:40f7e0aaef3b1f4c2ca2bb1189e3fe9af8c296da129423986d1d99ccc8cfb86c",
|
||||
"zh:56b361f64f0f0df5c4f958ae2f0e6f8ba192f35b720b9d3ae1be068fabcf73d9",
|
||||
"zh:5fadb5880cd31c2105f635ded92b9b16f918c1dd989627a4ce62c04939223909",
|
||||
"zh:61fa0be9c14c8c4109cfb7be8d54a80c56d35dbae49d3231cddb59831e7e5a4d",
|
||||
"zh:853774bf97fbc4a784d5af5a4ca0090848430781ae6cfc586adeb48f7c44af79",
|
||||
]
|
||||
}
|
||||
|
||||
provider "registry.terraform.io/hashicorp/local" {
|
||||
version = "2.0.0"
|
||||
hashes = [
|
||||
|
|
|
@ -58,6 +58,15 @@ resource "aws_instance" "client_windows_2016_amd64" {
|
|||
}
|
||||
}
|
||||
|
||||
data "external" "packer_sha" {
|
||||
program = ["/bin/sh", "-c", <<EOT
|
||||
sha=$(git log -n 1 --pretty=format:%H packer)
|
||||
echo "{\"sha\":\"$${sha}\"}"
|
||||
EOT
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
data "aws_ami" "ubuntu_bionic_amd64" {
|
||||
most_recent = true
|
||||
owners = ["self"]
|
||||
|
@ -71,6 +80,11 @@ data "aws_ami" "ubuntu_bionic_amd64" {
|
|||
name = "tag:OS"
|
||||
values = ["Ubuntu"]
|
||||
}
|
||||
|
||||
filter {
|
||||
name = "tag:BuilderSha"
|
||||
values = [data.external.packer_sha.result["sha"]]
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_ami" "windows_2016_amd64" {
|
||||
|
@ -86,4 +100,9 @@ data "aws_ami" "windows_2016_amd64" {
|
|||
name = "tag:OS"
|
||||
values = ["Windows2016"]
|
||||
}
|
||||
|
||||
filter {
|
||||
name = "tag:BuilderSha"
|
||||
values = [data.external.packer_sha.result["sha"]]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
variable "build_sha" {
|
||||
type = string
|
||||
description = "the revision of the packer scripts building this image"
|
||||
}
|
||||
|
||||
locals {
|
||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||
distro = "ubuntu-bionic-18.04-amd64-server-*"
|
||||
|
@ -24,8 +29,9 @@ source "amazon-ebs" "latest_ubuntu_bionic" {
|
|||
}
|
||||
|
||||
tags = {
|
||||
OS = "Ubuntu"
|
||||
Version = "Bionic"
|
||||
OS = "Ubuntu"
|
||||
Version = "Bionic"
|
||||
BuilderSha = var.build_sha
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
variable "build_sha" {
|
||||
type = string
|
||||
description = "the revision of the packer scripts building this image"
|
||||
}
|
||||
|
||||
locals {
|
||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||
version = "v2"
|
||||
|
@ -23,7 +28,8 @@ source "amazon-ebs" "latest_windows_2016" {
|
|||
}
|
||||
|
||||
tags = {
|
||||
OS = "Windows2016"
|
||||
OS = "Windows2016"
|
||||
BuilderSha = var.build_sha
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue