Skip to content

Added aws_create_instance.sh script and tests - #5

Open
salvatoredipietro wants to merge 1 commit into
mainfrom
aws-create-instance
Open

Added aws_create_instance.sh script and tests#5
salvatoredipietro wants to merge 1 commit into
mainfrom
aws-create-instance

Conversation

@salvatoredipietro

Copy link
Copy Markdown
Contributor

Summary

  • Adds scripts/aws_create_instance.sh, an env-var-driven wrapper around aws ec2 run-instances for spinning up a throw-away SUT/LDG instance for repro/benchmark work. It is explicitly out of scope of the Repro Framework (infrastructure management remains the caller's responsibility) and is documented as such.
  • Adds a full test suite under tests/: 74 bats unit tests (no real AWS calls, using a fake_aws.bash stub) and a real-AWS integration test script with automatic cleanup.
  • Updates README.md to document the new scripts/ and tests/ directories and clarify the infrastructure-management scope exception.

What aws_create_instance.sh does

  • Accepts all configuration via environment variables (INSTANCE_TYPE, KEYPAIR, EXPNAME, AMI, EBS_DISKS_*, SUBNET_ID, SG_ID, PLACEMENT_GROUP_NAME, TENANCY, …). See --help for the full list.
  • Auto-discovers AMI, subnet, and security group from the target account when not provided.
  • Supports AMI aliases (AL2023_K6.12, AL2023, UBUNTU2404, etc.) in addition to raw ami-* IDs, and infers the correct SSH user and root device from the AMI metadata.
  • Optionally attaches up to 25 EBS data volumes (gp3/gp2/io1/io2/st1/sc1) and configures the root volume size, type, and IOPS.
  • Supports placement groups (creates them on first use), dedicated tenancy, public IP association, and instance tagging.
  • Clones the repro-collection repo into the instance via cloud-init on boot (CLONE_REPO=true by default).
  • Writes a resource JSON (repro-results/${EXPNAME}.resources.json) for downstream scripts to pick up instance IDs, IPs, subnet, and AZ.
  • DRYRUN=true validates and prints the run-instances call without launching anything.

Tests

Layer File Coverage
Unit (bats) tests/unit/scripts/aws_create_instance.bats 74 tests — input validation, arch inference, AMI resolution, subnet/SG discovery, block-device mappings, tenancy/tags, user-data, DRYRUN, placement groups, full launch summary
Unit helper tests/unit/helpers/fake_aws.bash aws CLI stub, fully isolated via env -i, captures exact run-instances argv
Integration tests/integration/aws_create_instance_integration.sh Real-AWS end-to-end: arm64 minimal, x86 custom root, arm64 data disks, placement group; auto-terminates all created resources on exit/interrupt

Test plan

  • bash -n scripts/aws_create_instance.sh passes
  • Integration test dry-run: DRYRUN=true INSTANCE_TYPE=t4g.micro KEYPAIR=<key> EXPNAME=test scripts/aws_create_instance.sh
  • Full integration: AWS_PROFILE=default AWS_REGION=us-west-2 tests/integration/aws_create_instance_integration.sh --yes

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant