Skip to content

Commit

Permalink
adding a new 'ec2-instance-type' parameter
Browse files Browse the repository at this point in the history
to be more flexible, adding a new paramter: 'ec2-instance-type'
that can be transfter to the script and will be used during AMI build.
  • Loading branch information
Annamikhlin committed Oct 22, 2023
1 parent 58610e8 commit 9c12695
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packer/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ APT_KEY='d0a112e067426ab2'

print_usage() {
echo "$0 --localdeb --repo [URL] --target [distribution]"
echo " [--localdeb] Deploy locally built debs Default: false"
echo " [--localdeb] Deploy locally built debs Default: false"
echo " --repo Repository for both install and update, specify .repo/.list file URL"
echo " --repo-for-install Repository for install, specify .repo/.list file URL"
echo " --repo-for-update Repository for update, specify .repo/.list file URL"
Expand All @@ -37,6 +37,7 @@ print_usage() {
echo " [--log-file] Path for log. Default build/ami.log on current dir. Default: build/packer.log"
echo " --target Target cloud (aws/gce/azure), mandatory when using this script directly, and not by soft links"
echo " --arch Set the image build architecture. Valid options: x86_64 | aarch64 . if use didn't pass this parameter it will use local node architecture"
echo " --ec2-instance-type Set EC2 instance type to use while building the AMI. If empty will use defaults per architecture"
exit 1
}
LOCALDEB=0
Expand Down Expand Up @@ -96,7 +97,7 @@ while [ $# -gt 0 ]; do
;;
"--ami-regions"):
AMI_REGIONS=$2
echo "--ami-regions prameter: AMI_REGIONS |$AMI_REGIONS|"
echo "--ami-regions parameter: AMI_REGIONS |$AMI_REGIONS|"
shift 2
;;
"--ami-users"):
Expand Down Expand Up @@ -152,6 +153,10 @@ while [ $# -gt 0 ]; do
ARCH="$2"
shift 2
;;
"--ec2-instance-type")
INSTANCE_TYPE="$2"
shift 2
;;
*)
echo "ERROR: Illegal option: $1"
print_usage
Expand Down Expand Up @@ -270,11 +275,15 @@ if [ "$TARGET" = "aws" ]; then
case "$arch" in
"x86_64")
SOURCE_AMI_FILTER="ubuntu-minimal/images/hvm-ssd/ubuntu-jammy-22.04-amd64*"
INSTANCE_TYPE="c4.xlarge"
if [ -z "$INSTANCE_TYPE" ]; then
INSTANCE_TYPE="c4.xlarge"
fi
;;
"aarch64")
SOURCE_AMI_FILTER="ubuntu-minimal/images/hvm-ssd/ubuntu-jammy-22.04-arm64*"
INSTANCE_TYPE="im4gn.2xlarge"
if [ -z "$INSTANCE_TYPE" ]; then
INSTANCE_TYPE="im4gn.2xlarge"
fi
;;
*)
echo "Unsupported architecture: $arch"
Expand Down

0 comments on commit 9c12695

Please sign in to comment.