Skip to content

Commit

Permalink
docs(example): Verbose comments
Browse files Browse the repository at this point in the history
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
  • Loading branch information
rjshrjndrn committed Apr 1, 2024
1 parent 71738e1 commit 8b126a7
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions examples/packer/aws-ubuntu.pkr.hcl.tpl
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
packer {
// Specify required plugins and their versions for this Packer configuration.
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
version = ">= 0.0.2" // Minimum plugin version requirement.
source = "github.com/hashicorp/amazon" // Plugin source location.
}
}
}

{{$version := .Values.version}}
{{/* Initialize variables from Helm values for reuse. */}}
{{- $version := .Values.version }}
{{- $regions := .Values.regions }}
{{- range $_, $region := .Values.regions}}
source "amazon-ebs" "{{$region}}" {
ami_name = "or-ubuntu-arm64"
instance_type = "t4g.xlarge"
region = "{{$region}}"

{{/* Iterate over each region specified in Helm values. */}}
{{- range $_, $region := $regions }}

// Define an Amazon EBS (Elastic Block Store) source configuration for each region.
source "amazon-ebs" "{{ $region }}" {
ami_name = "or-ubuntu-arm64" // AMI name pattern.
instance_type = "t4g.xlarge" // Instance type to use.
region = "{{ $region }}" // AWS region from Helm values.
source_ami_filter {
filters = {
name = "ubuntu/images/*ubuntu-jammy-22.04-arm64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
name = "ubuntu/images/*ubuntu-jammy-22.04-arm64-server-*" // Filter for Ubuntu AMI.
root-device-type = "ebs" // EBS-backed AMI.
virtualization-type = "hvm" // Hardware Virtual Machine.
}
most_recent = true
owners = ["099720109477"] # Canonical
most_recent = true // Use the most recent AMI matching the filter.
owners = ["099720109477"] // Canonical as the AMI owner.
}
ssh_username = "ubuntu"
ssh_username = "ubuntu" // Default SSH username.
tags = {
version = "{{$version}}"
createdBy = "packer"
version = "{{ $version }}" // Inject version from Helm values.
createdBy = "packer" // Tag to identify the creator.
}
}
{{- end}}

{{- end }}

build {
name = "or-ee-saas-ami"
name = "or-ee-saas-ami" // Build name for the resulting AMI.
sources = [
{{- range $_, $value := $regions}}
// Inject source references for each region defined in Helm values.
{{- range $_, $value := $regions}}
"source.amazon-ebs.{{$value}}",
{{- end}}
{{- end}}
]
}

0 comments on commit 8b126a7

Please sign in to comment.