forked from hashicorp-education/learn-hcp-packer-get-started
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubuntu-focal.pkr.hcl
86 lines (78 loc) · 2.1 KB
/
ubuntu-focal.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
packer {
required_plugins {
amazon = {
version = ">= 1.0.1"
source = "github.com/hashicorp/amazon"
}
googlecompute = {
version = ">= 1.1.4"
source = "github.com/hashicorp/googlecompute"
}
}
}
variable "version" {
type = string
default = "1.0.1"
}
data "amazon-ami" "ubuntu-focal-east" {
region = "us-east-2"
filters = {
name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
}
most_recent = true
owners = ["099720109477"]
}
source "amazon-ebs" "basic-example-east" {
region = "us-east-2"
source_ami = data.amazon-ami.ubuntu-focal-east.id
instance_type = "t2.small"
ssh_username = "ubuntu"
ssh_agent_auth = false
ami_name = "packer_AWS_{{timestamp}}_v${var.version}"
}
data "amazon-ami" "ubuntu-focal-west" {
region = "us-west-1"
filters = {
name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
}
most_recent = true
owners = ["099720109477"]
}
source "amazon-ebs" "basic-example-west" {
region = "us-west-1"
source_ami = data.amazon-ami.ubuntu-focal-west.id
instance_type = "t2.small"
ssh_username = "ubuntu"
ssh_agent_auth = false
ami_name = "packer_AWS_{{timestamp}}_v${var.version}"
}
source "googlecompute" "basic-example-gcp" {
project_id = "hc-9e268a3159ea47ad9ae0b4744a7"
zone = "us-central1-f"
source_image_family = "ubuntu-2004-lts"
image_description = "built with packer"
ssh_username = "ubuntu"
image_name = "packer-gcp-{{timestamp}}-v${replace(var.version, ".", "-")}"
}
build {
hcp_packer_registry {
bucket_name = "multicloud-ubuntu-base"
description = <<EOT
MEOW WORLD.
EOT
bucket_labels = {
"owner" = "platform-team"
"os" = "Ubuntu",
"ubuntu-version" = "Focal 20.04",
}
build_labels = {
"build-time" = timestamp()
"build-source" = basename(path.cwd)
}
}
sources = [
"source.amazon-ebs.basic-example-east",
"source.amazon-ebs.basic-example-west",
"source.googlecompute.basic-example-gcp"
]
}