-
Notifications
You must be signed in to change notification settings - Fork 8
/
nginx.pkr.hcl
75 lines (67 loc) · 1.75 KB
/
nginx.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
variable "ami_name" {
default = "NGINX"
description = "Name of AMI to be created"
type = string
}
variable "instance_type" {
default = "t3.medium"
description = "The instance type for the AMI build"
type = string
}
variable "nginx_plus_certificate" {
description = "The path to your NGINX Plus certificate"
type = string
}
variable "nginx_plus_key" {
description = "The path to your NGINX Plus key"
type = string
}
variable "owner" {
default = ""
description = "Owner of resources being created (included as a tag)"
type = string
}
variable "region" {
default = "us-west-1"
description = "Your target AWS region"
type = string
}
variable "source_ami" {
default = "ami-0a741b782c2c8632d"
description = "Source AMI ID to base this build on"
type = string
}
source "amazon-ebs" "nginx" {
# AMI configuration
ami_name = var.ami_name
ami_description = "${var.ami_name} AMI"
force_deregister = true
force_delete_snapshot = true
ssh_username = "ubuntu"
tags = {
Name = "${var.ami_name} AMI"
Owner = var.owner != "" ? var.owner : "Packer"
}
# Access configuration
region = var.region
# Run configuration
instance_type = var.instance_type
source_ami = var.source_ami
}
build {
description = "Install NGINX"
sources = [
"source.amazon-ebs.nginx"
]
provisioner "ansible" {
extra_arguments = [
"--extra-vars",
"nginx_plus_certificate=${var.nginx_plus_certificate} nginx_plus_key=${var.nginx_plus_key}",
]
galaxy_file = "${path.root}/requirements.yml"
playbook_file = "${path.root}/nginx.yml"
# Global parameters
max_retries = 2
pause_before = "10s"
}
}