diff options
author | clarkzjw <[email protected]> | 2023-02-13 17:48:19 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-13 17:48:19 -0800 |
commit | b3895c6af1f1d57d5fb2fd895f9950b55246a157 (patch) | |
tree | 0478d2d2dffd921985b7cc3da276adbedd373e51 /packer/ubuntu.pkr.hcl | |
parent | dc756af1b57186122874d703821191baefa1aacd (diff) | |
download | zjw.social-packer.tar.gz |
packer: add packer ubuntu templatepacker
Diffstat (limited to 'packer/ubuntu.pkr.hcl')
-rw-r--r-- | packer/ubuntu.pkr.hcl | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/packer/ubuntu.pkr.hcl b/packer/ubuntu.pkr.hcl new file mode 100644 index 0000000..e7d4f37 --- /dev/null +++ b/packer/ubuntu.pkr.hcl | |||
@@ -0,0 +1,72 @@ | |||
1 | packer { | ||
2 | required_plugins { | ||
3 | amazon = { | ||
4 | version = ">= 1.0.1" | ||
5 | source = "github.com/hashicorp/amazon" | ||
6 | } | ||
7 | } | ||
8 | } | ||
9 | |||
10 | variable "version" { | ||
11 | type = string | ||
12 | default = "1.0.0" | ||
13 | } | ||
14 | |||
15 | data "amazon-ami" "ubuntu-focal-east" { | ||
16 | region = "us-east-2" | ||
17 | filters = { | ||
18 | name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*" | ||
19 | } | ||
20 | most_recent = true | ||
21 | owners = ["099720109477"] | ||
22 | } | ||
23 | |||
24 | source "amazon-ebs" "basic-example-east" { | ||
25 | region = "us-east-2" | ||
26 | source_ami = data.amazon-ami.ubuntu-focal-east.id | ||
27 | instance_type = "t2.small" | ||
28 | ssh_username = "ubuntu" | ||
29 | ssh_agent_auth = false | ||
30 | ami_name = "packer_AWS_{{timestamp}}_v${var.version}" | ||
31 | } | ||
32 | |||
33 | data "amazon-ami" "ubuntu-focal-west" { | ||
34 | region = "us-west-1" | ||
35 | filters = { | ||
36 | name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*" | ||
37 | } | ||
38 | most_recent = true | ||
39 | owners = ["099720109477"] | ||
40 | } | ||
41 | |||
42 | source "amazon-ebs" "basic-example-west" { | ||
43 | region = "us-west-1" | ||
44 | source_ami = data.amazon-ami.ubuntu-focal-west.id | ||
45 | instance_type = "t2.small" | ||
46 | ssh_username = "ubuntu" | ||
47 | ssh_agent_auth = false | ||
48 | ami_name = "packer_AWS_{{timestamp}}_v${var.version}" | ||
49 | } | ||
50 | |||
51 | build { | ||
52 | hcp_packer_registry { | ||
53 | bucket_name = "learn-packer-ubuntu" | ||
54 | description = <<EOT | ||
55 | Some nice description about the image being published to HCP Packer Registry. | ||
56 | EOT | ||
57 | bucket_labels = { | ||
58 | "owner" = "platform-team" | ||
59 | "os" = "Ubuntu", | ||
60 | "ubuntu-version" = "Focal 20.04", | ||
61 | } | ||
62 | |||
63 | build_labels = { | ||
64 | "build-time" = timestamp() | ||
65 | "build-source" = basename(path.cwd) | ||
66 | } | ||
67 | } | ||
68 | sources = [ | ||
69 | "source.amazon-ebs.basic-example-east", | ||
70 | "source.amazon-ebs.basic-example-west" | ||
71 | ] | ||
72 | } | ||