Skip to content

Commit 7f87f51

Browse files
authored
Implemented architecture choice 'arm' or amd 'x86_64' for EC2 cloud (#14289)
New `arch` config.cfg parameter is used along with the image name parameter to find the most recent OS image to be used in hosted ec2 instance. This allows the user to choose arm based instance types which was causing algo failure during cloud formation.
1 parent 571daf4 commit 7f87f51

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

config.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ cloud_providers:
182182
size: t2.micro
183183
image:
184184
name: "ubuntu-focal-20.04"
185+
arch: x86_64
185186
owner: "099720109477"
186187
# Change instance_market_type from "on-demand" to "spot" to take advantage of
187188
# simplified spot launch options

docs/cloud-amazon-ec2.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The cheapest EC2 plan you can choose is the "Free Plan" a.k.a. the "AWS Free Tie
1212

1313
As of the time of this writing (July 2018), the Free Tier limits include "750 hours of Amazon EC2 Linux t2.micro instance usage" per month, 15 GB of bandwidth (outbound) per month, and 30 GB of cloud storage. Algo will not even use 1% of the storage limit, but you may have to monitor your bandwidth usage or keep an eye out for the email from Amazon when you are about to exceed the Free Tier limits.
1414

15+
Addtional configurations are documented in the [EC2 section of the deploy from ansible guide](https://github.com/trailofbits/algo/blob/master/docs/deploy-from-ansible.md#amazon-ec2)
16+
1517
### Create an AWS permissions policy
1618

1719
In the AWS console, find the policies menu: click Services > IAM > Policies. Click Create Policy.

docs/deploy-from-ansible.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,16 @@ Possible options can be gathered via cli `aws ec2 describe-regions`
110110

111111
Additional variables:
112112

113-
- [encrypted](https://aws.amazon.com/blogs/aws/new-encrypted-ebs-boot-volumes/) - Encrypted EBS boot volume. Boolean (Default: false)
113+
- [encrypted](https://aws.amazon.com/blogs/aws/new-encrypted-ebs-boot-volumes/) - Encrypted EBS boot volume. Boolean (Default: true)
114114
- [size](https://aws.amazon.com/ec2/instance-types/) - EC2 instance type. String (Default: t2.micro)
115+
- [image](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-images.html) - AMI `describe-images` search parameters to find the OS for the hosted image. Each OS and architecture has a unique AMI-ID. The OS owner, for example [Ubuntu](https://cloud-images.ubuntu.com/locator/ec2/), updates these images often. If parameters below result in multiple results, the most recent AMI-ID is chosen
116+
```
117+
# Example of equivalent cli comand
118+
aws ec2 describe-images --owners "099720109477" --filters "Name=architecture,Values=arm64" "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-focal-20.04*"
119+
```
120+
- [owners] - The operating system owner id. Default is [Canonical](https://help.ubuntu.com/community/EC2StartersGuide#Official_Ubuntu_Cloud_Guest_Amazon_Machine_Images_.28AMIs.29) (Default: 099720109477)
121+
- [arch] - The architecture (Default: x86_64, Optional: arm64)
122+
- [name] - The wildcard string to filter available ami names. Algo appends this name with the string "-\*64-server-\*", and prepends with "ubuntu/images/hvm-ssd/" (Default: ubuntu-focal-20.04)
115123
- [instance_market_type](https://aws.amazon.com/ec2/pricing/) - Two pricing models are supported: on-demand and spot. String (Default: on-demand)
116124
* If using spot instance types, one additional IAM permission along with the below minimum is required for deployment:
117125
```

roles/cloud-ec2/tasks/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
owners: "{{ cloud_providers.ec2.image.owner }}"
1313
region: "{{ algo_region }}"
1414
filters:
15-
name: "ubuntu/images/hvm-ssd/{{ cloud_providers.ec2.image.name }}-amd64-server-*"
15+
architecture: "{{ cloud_providers.ec2.image.arch }}"
16+
name: "ubuntu/images/hvm-ssd/{{ cloud_providers.ec2.image.name }}-*64-server-*"
1617
register: ami_search
1718

1819
- name: Set the ami id as a fact

0 commit comments

Comments
 (0)