Skip to content

Commit

Permalink
Add aarch64 testing terraform config
Browse files Browse the repository at this point in the history
When testing the linux aarch64 code on a real platform (AWS graviton),
it is a bit of a hassle walking through all the steps to instantiate,
configure, and then run the test suite. So I created a terraform
configuration that does it all for me (a la infrastructure as code).

Right now, the config is a too tailored to me (assumes the default
network policy allows inbound ssh and the ssh key is named "me"). But,
I'm a terraform noob, so I welcome implementation suggestions.
  • Loading branch information
nickbabcock committed Oct 28, 2023
1 parent cf11588 commit fac4a8d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
**/target
**/*.rs.bk
Cargo.lock

### Terraform ###
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*
25 changes: 25 additions & 0 deletions assets/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions assets/aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -euxo pipefail

terraform plan
terraform apply -auto-approve
public_ip=$(terraform output --raw public_ip)
sleep 30
ssh ec2-user@$public_ip "
sudo yum update -y &&
sudo yum groupinstall -y 'Development Tools' &&
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal -y &&
source "\$HOME/.cargo/env" &&
git clone https://github.com/nickbabcock/highway-rs.git &&
cd highway-rs &&
cargo test"

if [[ $? = 0 ]]; then
read -p "Test successful, preserve instance? (y/N): " -n 1 -r -t 300
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
terraform destroy -auto-approve
fi
else
echo "Test failed"
fi
22 changes: 22 additions & 0 deletions assets/aarch64.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}

provider "aws" {
region = "us-east-1"
}

resource "aws_instance" "highway_aarch64" {
ami = "ami-055859c8e0f361065"
instance_type = "t4g.small"
key_name = "me"
}

output "public_ip" {
value = aws_instance.highway_aarch64.public_ip
}

0 comments on commit fac4a8d

Please sign in to comment.