-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
- Loading branch information
1 parent
71738e1
commit 8b126a7
Showing
1 changed file
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} | ||
] | ||
} | ||
|