{"id":17424334,"url":"https://github.com/neboat/awsscripts","last_synced_at":"2025-03-28T00:19:11.391Z","repository":{"id":212963992,"uuid":"732707862","full_name":"neboat/awsscripts","owner":"neboat","description":"Template scripts for launching and setting up AWS instances","archived":false,"fork":false,"pushed_at":"2023-12-17T15:51:03.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T02:16:10.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neboat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-17T15:25:09.000Z","updated_at":"2023-12-17T15:49:51.000Z","dependencies_parsed_at":"2023-12-17T16:51:59.674Z","dependency_job_id":null,"html_url":"https://github.com/neboat/awsscripts","commit_stats":null,"previous_names":["neboat/awsscripts"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neboat%2Fawsscripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neboat%2Fawsscripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neboat%2Fawsscripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neboat%2Fawsscripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neboat","download_url":"https://codeload.github.com/neboat/awsscripts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245944198,"owners_count":20697971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-17T05:41:48.992Z","updated_at":"2025-03-28T00:19:11.365Z","avatar_url":"https://github.com/neboat.png","language":"Shell","readme":"# Template repository for AWS scripts\n\nThis repository contains scripts to help you launch and configure AWS instances.  This repository includes three core template scripts that you can configure for your needs:\n\n- `start`: Launch a new AWS instance from a specified launch template.  This script lets you launch instances from the command line and ensures that those instances are configured consistently.  For example, the script will attach a specified persistent EBS volume to your new instance.\n- `setup`: Setup a new AWS instance.  This script will perform routine setup steps on a newly launched AWS instance, including the following:\n  - Create a new user with your username.\n  - Install a standard set of packages.\n  - Copy standard configuration files.\n  - Mount an attached EBS volume.\n- `keys`: Start an SSH agent and add a list of keys to it.  When you use SSH-agent forwarding to connect to a machine, these keys will be available to use.\n\nThese scripts are designed to work on Linux or macOS.\n\nOnce these scripts are configured, you can use them as follows to launch and setup a new AWS instance:\n\n```console\n./start  # At the end, prints the hostname of the newly launched instance\n./setup \u003cinstance_hostname\u003e\n```\n\nTo make your SSH keys available from your instance, ensure you have run the `./keys` script, and then use SSH-agent forwarding when you connect to your instance with SSH.\n\u003e [!NOTE]\n\u003e You can enable SSH-agent forwarding either using the `-A` command-line flag with `ssh` or by setting `ForwardAgent yes` in the appropriate entry in your SSH config.\n\nThe following sections describe how to configure and use these scripts for your use case.  These instructions assume you already have an AWS account.\n\n## `start`: Launching a new instance\n\n### Prerequisites\n\nTo use the `start` script, you will first need to do the following steps:\n\n- Install and setup AWS CLI version 2 on your local machine: \u003chttps://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html\u003e.\n- Create a launch template for launching new instances: \u003chttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-launch-template.html\u003e.\n- *Recommended, but optional:* Create a persistent, empty EBS volume to store data across spot instances: \u003chttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-creating-volume.html\u003e.\n\n### Configuring the `start` script\n\nThe `start` script uses a ***launch configuration** to specify how to launch instances.  By default, `start` uses the launch configuration `example-fleet-config.json`, which launches a single spot instance from a specified launch template that is terminated when interrupted.\n\nYou can configure the `start` script with this default configuration file as follows:\n\n- ***Mandatory:*** In `example-fleet-config.json`, replace `\u003cYour Launch Template ID\u003e` with the ID of your launch template.\n- In `example-fleet-config.json` at `LaunchTemplateConfigs[0].Overrides[0].InstanceType`, replace `c5.4xlarge` with your preferred instance type.\n- ***To automatically attach a separate EBS volume:***\n  - In `example-fleet-config.json`, make sure that `LaunchTemplateConfigs[0].Overrides[0].SubnetId` matches the subnet ID of the Availability Zone that contains your EBS volume.\n  - In the `start` script itself, set the value of `PERSISTENT_VOLUME_ID` to match the ID of your EBS volume.\n\n\u003e [!NOTE]\n\u003e If you wish for the `start` script to choose between multiple possible instance types, create multiple entries within `LaunchTemplateConfigs[0].Overrides`, one for each instance type the script may use.  For more documentation and examples of launch configurations, see \u003chttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-fleet-examples.html\u003e.\n\n### Running the script\n\nOnce configured, simply run the `start` script to launch your AWS instance:\n\n```console\n./start\n```\n\nThe script will report its progress in launching the instance as it goes.  Once the instance is launched, the script will print the hostname of the newly launched instance.\n\n\u003e [!NOTE]\n\u003e You can create different configuration `json` files to launch instances and specify which configuration file `start` should use via the `--config` command-line flag.\n\nFor more information on using the `start` script, run:\n\n```console\n./start -h\n```\n\n## `setup`: Setup a new AWS instance\n\n### Configuring the `setup` script\n\nConfigure the `setup` script as follows:\n\n- ***Mandatory:*** Set the `AWS_KEY_PAIR` variable to match the filename on your system of the private key for your AWS key pair, such as `my_aws_key.pem`.  The `setup` script assumes that this file is located inside `~/.ssh/`.\n- ***Mandatory:*** Set the `AWS_USER_PRIVATE_KEY` variable to match the filename of the private key for logging to your AWS instance in as your preferred username, e.g., `id_ed25519`.  The `setup` script assumes that this file and the corresponding public key — such as `id_ed25519.pub` — are both located inside `~/.ssh/`.\n- Set the `AWS_USER` variable to be the username you wish to use on your AWS instance.  If left unmodified, the `setup` script will set this variable to `${USER}`, that is, your username on your local machine.\n- Populate the `PACKAGES` variable with a space-separated list of packages you wish to install by default on any new AWS instance.\n- ***To automatically mount a separate EBS volume:*** Set the `PERSISTENT_VOLUME_MOUNT` variable to the path where your separate EBS volume should be mounted.\n- Populate `home_config` with any files --- such as `.gitconfig`, `.vim/`, or `.emacs` --- that you wish to automatically copy into `AWS_USER`'s home directory on the instance.\n  - To automatically append any content onto an existing hidden file — such as `.bashrc` — within `AWS_USER`'s home directory, place the text to append inside a not-hidden ***addon*** file within `home_config` with the corresponding name — such as `bashrc-addon`.\n\n\u003e [!WARNING]\n\u003e Because of potential security risks, I recommend that you ***do not*** create a `.ssh/` directory inside `home_config` that contains SSH keys you wish to use from the instance.  To make SSH keys available when you're using the instance, use SSH-agent forwarding and the `keys` script.\n\n#### Additional configuration\n\nThe `setup` script assumes the AWS instance is running a recent Ubuntu AMI.  For other AMI's, you may need to modify the variables `AWS_ROOT_USER`, `PACKAGE_MANAGER_UPDATE_CMD`, and `PACKAGE_MANAGER_INSTALL_CMD`; the `adduser` and `usermod` commands for setting up a new user on the instance; and the commands for quiescing the instance.\n\n### Running the `setup` script\n\nOnce configured, simply run the `setup` script with your AWS instance hostname to setup a newly launched AWS instance:\n\n```console\n./setup \u003cinstance_hostname\u003e\n```\n\nwhere, `\u003cinstance_hostname\u003e` is the hostname printed when the `start` script terminates.\n\nBy default, `setup` will perform all setup steps, creating the user `$USER` on the instance.  You can specify command-line flags to change the username that `setup` will create or restrict `setup` to perform specific setup steps only.  For more information on using the `setup` script, run:\n\n```console\n./setup -h\n```\n\n## `keys`: Add SSH keys to an SSH agent\n\n### Configuring the `keys` script\n\nPopulate the `KEYS` variable in the `keys` script with a space-separated list of SSH-key names that you would like to make available on any instance you SSH to.\n\n### Running `keys`\n\nOnce configured, simply run the `keys` script to start your SSH agent and add your keys to it:\n\n```console\n./keys\n```\n\nOnce you have run `./keys` once, your SSH agent will be setup for any instances you SSH into until you next logout of your local machine.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneboat%2Fawsscripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneboat%2Fawsscripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneboat%2Fawsscripts/lists"}