-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault.pkr.hcl
112 lines (102 loc) · 2.74 KB
/
vault.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
variable "ami_regions" {
type = list(string)
default = [
"ap-south-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"eu-central-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-north-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
]
}
variable "ami_groups" {
type = list(string)
default = [
"all"
]
}
variable "builder_region" {
type = string
default = "eu-west-3"
}
variable "builder_subnet_id" {
type = string
default = "subnet-935273fa"
}
variable "builder_vpc_id" {
type = string
default = "vpc-fd794394"
}
variable "vault_version" {
type = string
default = "1.12.1"
}
variable "vault_version_checksum" {
type = string
default = "839fa81eacd250e0b0298e518751a792cd5d7194650af78cf5da74d7b7b1e5fb"
}
data "amazon-ami" "al2022" {
filters = {
name = "al2022-ami-2022*-x86_64"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["amazon"]
region = "${var.builder_region}"
}
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
source "amazon-ebs" "ec2-amazonlinux2022" {
ami_description = "vault-${var.vault_version}-al2002-ami-hvm-x86_64-${local.timestamp}"
ami_name = "vault-${var.vault_version}-al2022-ami-hvm-x86_64-${local.timestamp}"
ami_regions = var.ami_regions
ami_groups = var.ami_groups
communicator = "ssh"
instance_type = "t3.small"
region = "${var.builder_region}"
run_tags = {
Name = "Vault ${var.vault_version} Builder"
build_date = "${local.timestamp}"
packer = true
packer_version = "${packer.version}"
}
run_volume_tags = {
Name = "Vault ${var.vault_version} Builder"
build_date = "${local.timestamp}"
packer = true
packer_version = "${packer.version}"
}
source_ami = "${data.amazon-ami.al2022.id}"
spot_price = "auto"
ssh_username = "ec2-user"
subnet_id = "${var.builder_subnet_id}"
tags = {
Name = "vault-${var.vault_version}-al2022-ami-hvm-x86_64-${local.timestamp}"
build_date = "${local.timestamp}"
os = "Amazon Linux 2022"
packer = true
packer_version = "${packer.version}"
vault_version = "${var.vault_version}"
}
vpc_id = "${var.builder_vpc_id}"
ssh_interface = "public_dns"
}
build {
sources = ["source.amazon-ebs.ec2-amazonlinux2022"]
provisioner "ansible" {
extra_arguments = ["--extra-vars", "vault_version=${var.vault_version} vault_version_checksum=${var.vault_version_checksum}"]
playbook_file = "./ansible/site.yml"
use_proxy = false
}
}