- Set the environment variables (
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY) accordingly. Note that the account must have the proper permissions to interact with IAM, EC2 and S3. Keep these variables inside a .env file in order to source it when needed if you are going to develop on top of this codebase. - Terraform state file is stored centrally in an S3 bucket, this is configured in
backend.tf. Note that this bucket must already exist beforehand. If you don't want a remote state file, delete thebackend.tffile from here. - Run
terraform initto download the dependencies and initialize Terraform. - Run
terraform applyto see the Terraform provisioning plan and enter "yes" to apply (or run with--auto-approveright away). Theterraform plancommand can also be used to view the provisioning plan. - For now, run
terraform output -raw private_key > ec2_spot_private_key && chmod 400 ec2_spot_private_keyto output the SSH private key. - For now, obtain the instances' public IPs from the EC2 dashboard. Note that the working SSH port is 65535.
- SSH into
alpine@IP_ADDRESS -p 65535when needed.
NOTE: Certain AWS regions require you to opt-in, you should opt-in and wait some time before applying the Terraform resources. You can edit locals.tf to set the regions and other preferences.