Skip to content

Commit

Permalink
Add info for running multiple profiles closes #2 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
richarvey committed Mar 4, 2023
1 parent b2a8f17 commit e00f84a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Run the container and map a local directory (for files you may want to use) and
docker run -it -v `pwd`:/cfg -v ~/.aws:/home/awsuser/.aws richarvey/awscli:latest ${COMMAND}
```

#### Switching profile

Instead of including ```--profile SomeProfile``` in each command you can also use the ```-e AWS_PROFILE=SomeProfile``` in the docker command. This can be particularly useful when setting up your bash profile and allows us to use different alias' for different accounts. To run fromt he command line do the following:

```
docker run -it -e AWS_PROFILE=SomeProfile -v `pwd`:/cfg -v ~/.aws:/home/awsuser/.aws richarvey/awscli:latest ${COMMAND}
```

## Adding to .bash_profile for :latest

You can set an alias and then use awscli as normal from your shell if desired, this makes it super easy to access.
Expand All @@ -62,6 +70,25 @@ aws() {

Now when you call ```aws``` from the command line (don't forget to source your bash_profile) you'll have direct access to the aws command as if it were installed on your system.

For advanced use and multiple profiles try something like the following:

```
vi ~/.bash_profile
```

```
# default account
aws() {
docker run -it -v `pwd`:/cfg -v ~/.aws:/home/awsuser/.aws --rm richarvey/awscli:latest "$@";
}
# Named profile account from .aws/config file
aws_profile_name() {
docker run -it -e AWS_PROFILE=SomeProfile -v `pwd`:/cfg -v ~/.aws:/home/awsuser/.aws --rm richarvey/awscli:latest "$@";
}
```

## Building yourself

The build process is now super simple and you can build using the normal docker tools:
Expand Down

0 comments on commit e00f84a

Please sign in to comment.