-
Notifications
You must be signed in to change notification settings - Fork 0
/
firstrun.pkr.hcl
48 lines (44 loc) · 1.35 KB
/
firstrun.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
variable "ami_name" {
type = string
# This example demostrates that you can load variables from the environment.
# In real usage, the AWS sdk used by the Amazon builder can automatically
# load credentials from the environment, so you wouldn't need to do this
# step. See the Packer AWS docs for more details.
default = "${env("CUSTOM_AMI_NAME")}"
}
variable "region" {
type = string
default = "us-east-1"
}
# source blocks are generated from your builders; a source can be referenced in
# build blocks. A build block runs provisioners and post-processors on a
# source.
source "amazon-ebs" "firstrun" {
ami_name = "packer-linux-aws-demo"
instance_type = "t2.micro"
region = "${var.region}"
source_ami_filter {
filters = {
name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
ssh_username = "ubuntu"
}
# a build block invokes sources and runs provisioning steps on them.
build {
sources = ["source.amazon-ebs.firstrun"]
provisioner "file" {
destination = "/home/ubuntu/"
source = "./welcome.txt"
}
provisioner "shell" {
inline = ["ls -al /home/ubuntu", "cat /home/ubuntu/welcome.txt"]
}
provisioner "shell" {
script = "./example.sh"
}
}