{"id":16777398,"url":"https://github.com/otakup0pe/awsswitch","last_synced_at":"2025-07-26T08:33:18.509Z","repository":{"id":141875704,"uuid":"31343778","full_name":"otakup0pe/awsswitch","owner":"otakup0pe","description":"bash helpers for juggling multiple aws accounts","archived":false,"fork":false,"pushed_at":"2024-12-27T17:13:44.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"mainline","last_synced_at":"2025-07-14T05:05:53.850Z","etag":null,"topics":["aws","aws-switch","shell"],"latest_commit_sha":null,"homepage":"http://blog.jonathanfreedman.bio/post/112089594641/juggling-clouds","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otakup0pe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-02-26T00:52:18.000Z","updated_at":"2024-12-27T17:13:48.000Z","dependencies_parsed_at":"2024-02-02T01:26:05.330Z","dependency_job_id":"72bd7e33-de13-4d62-b47d-95a30d7f5f81","html_url":"https://github.com/otakup0pe/awsswitch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/otakup0pe/awsswitch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fawsswitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fawsswitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fawsswitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fawsswitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otakup0pe","download_url":"https://codeload.github.com/otakup0pe/awsswitch/tar.gz/refs/heads/mainline","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fawsswitch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267140668,"owners_count":24041970,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aws","aws-switch","shell"],"created_at":"2024-10-13T07:24:36.523Z","updated_at":"2025-07-26T08:33:18.360Z","avatar_url":"https://github.com/otakup0pe.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/otakup0pe/awsswitch.svg?branch=master)](https://travis-ci.org/otakup0pe/awsswitch)![Maintenance](https://img.shields.io/maintenance/yes/2024.svg)\n\nAWS Switch\n==========\n\nThese scripts represent my approach for sanely working with multiple AWS accounts. When in use they will keep appropriate AWS related environment variables, and optionally, certain configuration files up to date with the appropriate AWS keys. Only one AWS account may be active at a time and this is synchronized across login sessions for a given user on the local host.\n\nThe scripts also support cross-account STS role assumption, including configurable renewal of credentials.\n\nThese scripts probably only work on Bash 4 and greater these days. They have been tested on mostly Ubuntu systems (both native and WSL) along with recent-ish macOS.\n\nI [wrote](http://blog.jonathanfreedman.bio/post/112089594641/juggling-clouds) about how I ended up with this workflow.\n\nInstallation\n------------\n\nClone this repository somewhere comfortable on your workstation. There are four environment variables which configure the scripts. Define these as you wish and then source the `init.sh` script in your `.profile`.\n\n * `AWSSWITCH_PATH` points to the location you cloned this repository\n * `AWSSWITCH_S3CFG` set to `true` if you want the script to update your `.s3cfg`\n * `AWSSWITCH_FOG` set to `true` if you want the script to update your `.fog`\n * `AWSSWITCH_CONFIG` can be set to `awscli` to read credentials from the [AWS configuration files]()\n * `AWSSWITCH_STS_RENEW` should be an integer which indicates how close to expiration to renew STS credentials.\n\n#### `.profile` Example\n```\nexport AWSSWITCH_PATH=\"${HOME}/src/awsswitch\"\nexport AWSSWITCH_KEYS=\"${HOME}/.aws.yml\"\nexport AWSSWITCH_S3CFG=\"true\"\nexport AWSSWITCH_FOG=\"false\"\nexport AWSSWITCH_STS_RENEW=900\n\n. \"${AWSSWITCH_PATH}/init.sh\"\n```\n\nThere is an additional component that is meant to be eval'd in the `PS1_COMMAND` context. This helps ensure that the AWS configuration is not only consistent across terminals but also that it may be visualized in the bash prompt. After this eval the `AWS_ACCOUNT` environment variable will be set to the name of the current AWS account. In addition, the `AWS_DEFAULT_REGION` environment variable will be updated upon switching to a _new_ aws profile.\n\n#### eval Example\n\n```\neval \"$(\"${AWSSWITCH_PATH}/awsswitch.sh\" eval)\"\n```\n\nAWS Configuration\n-----------------\n\nAWS configuration is pulled from the AWS CLI. You can read more about that [here](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files).\n\nScript Actions\n--------------\n\nThe script updates several pieces on a workstation. The minimalist form of which simply keeps various environment variables up to date. It may also optionally update other AWS related configuration files.\n\n## Environment Variables\n\nThe script will keep the following environment variables updated accordingly.\n\n* `AWS_ACCOUNT` The name of the AWS account\n* `AWS_ACCESS_KEY_ID` AWS access key ID\n* `AWS_ACCESS_KEY` AWS access key ID used by some older apps\n* `AWS_SECRET_ACCESS_KEY` AWS secret access key\n* `AWS_SECRET_KEY` AWS secret access key used by some older apps\n* `AWS_DEFAULT_REGION` the default region to use for many apps\n\n## s3cfg\n\nIF the script is updating the s3cfg a minimal configuration will be written containing only the base credentials. It will look as follows\n\n```\n[default]\naccess_key = ...\nsecret_key = ...\n```\n\n## fog\n\nIf the script is updating the fog config a minimal configuration will be written containing only the base credentials. It will look as follows\n\n```\ndefault:\n   aws_access_key_id: ...\n   aws_secret_access_key: ...\n```\n\nUsage\n-----\n\nOnce you have initialized the script in your `.profile` usage is straight forward. Simply make use of the `awsswitch` function and reference one of your defined AWS profiles. This will then cause your current terminal context to be re-initialized. For example, to switch to the `my-aws` AWS account you would invoke `awsswitch my-aws`.\n\nOther terminal contexts will _not_ be re-initialized until the next time the `PS1_COMMAND` context is evaluated. The `awsregion` function may be used to change the effective AWS region for the _current_ shell only. This override is lost upon switching AWS accounts.\n\nThis is where the inclusion of the `AWS_ACCOUNT` variable in your bash prompt is helpful as you can easily know which AWS account is currently active.\n\nLicense\n-----\n\n[MIT](https://github.com/otakup0pe/awsswitch/blob/master/LICENSE)\n\nAuthor\n-----\nThe awsswitch tool was created by [Jonathan Freedman](http://jonathanfreedman.bio/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotakup0pe%2Fawsswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotakup0pe%2Fawsswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotakup0pe%2Fawsswitch/lists"}