Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Modify script and workflow for AMI to include ARM64 (#738)
Browse files Browse the repository at this point in the history
* add right instance type for ami and change creds for prod-sync-ami workflow

Signed-off-by: sreekarjami <[email protected]>
  • Loading branch information
sreekarjami committed Apr 7, 2021
1 parent ea1f154 commit aabb00f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/prod-sync-ami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jobs:
- name: Required Packages
run: ./release-tools/scripts/required_packages.sh
- name: Set AMI from private to public in all regions
env:
AWS_DEFAULT_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.ODFE_AMI_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ODFE_AMI_AWS_SECRET_ACCESS_KEY }}
run: |
#!/bin/bash
# The actions aws credential above would lock region
# This is to allow aws to switch region in order to
# make AMI public on all available regions
aws configure set aws_access_key_id ${{ secrets.AWS_EC2_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_EC2_SECRET_ACCESS_KEY }}
aws configure set region us-east-1
export AWS_PAGER=""

REGIONS_LIST=`aws ec2 describe-regions --query 'Regions[].RegionName[]' --output text`
Expand All @@ -40,10 +41,12 @@ jobs:

echo "Making AMI Public in region (${region_name}): Open Distro for Elasticsearch-${{ env.od_version }}-x86_64"
AMI_IMAGE_ID_x64=`aws ec2 describe-images --filters "Name=name,Values=Open Distro for Elasticsearch-${{ env.od_version }}-x86_64*" --query 'Images[*].{ID:ImageId}' --output text`
echo "AMI ID : " $AMI_IMAGE_ID_x64
aws ec2 modify-image-attribute --image-id "${AMI_IMAGE_ID_x64}" --launch-permission "Add=[{Group=all}]"

echo "Making AMI Public in region (${region_name}): Open Distro for Elasticsearch-${{ env.od_version }}-arm64"
AMI_IMAGE_ID_arm64=`aws ec2 describe-images --filters "Name=name,Values=Open Distro for Elasticsearch-${{ env.od_version }}-arm64*" --query 'Images[*].{ID:ImageId}' --output text`
echo "AMI ID : " $AMI_IMAGE_ID_arm64
aws ec2 modify-image-attribute --image-id "${AMI_IMAGE_ID_arm64}" --launch-permission "Add=[{Group=all}]"
done

Expand Down
6 changes: 5 additions & 1 deletion elasticsearch/AMI/lib/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ def __init__(
self.key_pair_name = "ODFEAMIInstanceKey"
self.key_path = self._create_key_pair()
logging.info("Creating instance")
if "x86_64" in AMI_name:
ec2Type="t3a.2xlarge"
if "arm64" in AMI_name:
ec2Type="t4g.2xlarge"
self.instance = ec2_resource.create_instances(
ImageId=base_image_id,
MinCount=1,
MaxCount=1,
InstanceType="t3a.2xlarge",
InstanceType=ec2Type,
KeyName=self.key_pair_name,
SecurityGroupIds=[security_group_id],
AdditionalInfo="ODFE AMI",
Expand Down

0 comments on commit aabb00f

Please sign in to comment.