Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/infra/cloud-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,28 @@ else
exit 1
fi

latest_centos_9_ami() {
# Look up the latest CentOS 9 AMI ID for $EC2_REGION.
# See https://www.centos.org/download/aws-images/
# The CentOS CPE team publishes these with their account ID:
local CENTOS_CPE_AWS_ID=125523088429
aws ec2 describe-images \
--owners $CENTOS_CPE_AWS_ID \
--filters "Name=name,Values=CentOS Stream 9 x86_64*" \
--region "$EC2_REGION" \
--query "sort_by(Images[], &CreationDate)[-1].[ImageId]" \
--output text
}


ec2__launch() {
if [ -z ${EC2_SUBNET_VARS+x} ]; then
EC2_SUBNET_VARS=("EC2_SUBNET_ID")
fi

local instance_type
instance_type="${INSTANCE_TYPE:-$EC2_INSTANCE_TYPE}"
[ -n "$EC2_AMI_ID" ] || EC2_AMI_ID=$(latest_centos_9_ami)

for subnet_var in "${EC2_SUBNET_VARS[@]}"; do
subnet="${!subnet_var}"
Expand Down
3 changes: 2 additions & 1 deletion scripts/infra/instructlab-cloud-config-example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ EC2_SUBNET_ID="subnet-12345678901234567"
EC2_SUBNET_VARS=("EC2_SUBNET_ID_1" "EC2_SUBNET_ID_2")
EC2_SUBNET_ID_1=subnet-12345678901234567
EC2_SUBNET_ID_2=subnet-12345678901234568
EC2_AMI_ID="ami-12345678901234567"
# By default, cloud-instance.sh will use the latest CentOS Stream 9 image.
# Set EC2_AMI_ID="ami-12345678901234567" to choose another image.
EC2_REGION="us-east-2"
EC2_INSTANCE_NAME=`whoami`
EC2_KEY_NAME="${EC2_INSTANCE_NAME}"
Expand Down