diff --git a/examples/packer/aws-ubuntu.pkr.hcl.tpl b/examples/packer/aws-ubuntu.pkr.hcl.tpl index d3b9598..d77fa4a 100644 --- a/examples/packer/aws-ubuntu.pkr.hcl.tpl +++ b/examples/packer/aws-ubuntu.pkr.hcl.tpl @@ -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}} ] } -