A portable, containerized solution for running the AWS Command Line Interface through Podman, ensuring consistent CLI behavior across different environments.
This project provides a containerized version of the AWS CLI, allowing you to run AWS commands in a consistent environment without worrying about local dependencies or version conflicts. By using containers, you can ensure that your AWS CLI experience is identical across different systems.
- Consistent Environment: Same AWS CLI version and dependencies regardless of host system
- Isolated Execution: AWS CLI runs in its own container without affecting your system
- Credential Mapping: Securely use your local AWS credentials from within the container
- Tab Completion: Full command completion support, just like the native AWS CLI
- Current Directory Mounting: Automatically mounts your current directory for easy file access
- Minimal Setup: Just add an alias and you're ready to go
Add the following to your .bashrc
, .zshrc
, or equivalent shell configuration file:
# Create an alias for the containerized AWS CLI
alias aws="podman run --privileged --rm -it -v ~/.aws:/root/.aws -v $(pwd):/aws --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --env AWS_DEFAULT_REGION --env AWS_DEFAULT_OUTPUT --env AWS_PROFILE --env AWS_CA_BUNDLE --env AWS_SHARED_CREDENTIALS_FILE --env AWS_CONFIG_FILE --env AWS_ROLE_ARN --env AWS_ROLE_SESSION_NAME --env AWS_WEB_IDENTITY_TOKEN_FILE --env AWS_ROLE_ARN --env AWS_METADATA_SERVICE_TIMEOUT --env AWS_METADATA_SERVICE_NUM_ATTEMPTS --env AWS_STS_REGIONAL_ENDPOINTS --env AWS_MAX_ATTEMPTS --env AWS_RETRY_MODE --env AWS_EC2_METADATA_DISABLED --env AWS_SDK_UA_APP_ID ghcr.io/alexstorm1313/aws-cli:latest $@"
# Enable tab completion for the containerized AWS CLI
complete -C "podman run --rm -i --entrypoint /usr/local/bin/aws_completer -e COMP_LINE -e COMP_POINT ghcr.io/alexstorm1313/aws-cli:latest $@" aws
# Create an alias for the containerized AWS CLI
alias aws="docker run --privileged --rm -it -v ~/.aws:/root/.aws -v $(pwd):/aws --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --env AWS_DEFAULT_REGION --env AWS_DEFAULT_OUTPUT --env AWS_PROFILE --env AWS_CA_BUNDLE --env AWS_SHARED_CREDENTIALS_FILE --env AWS_CONFIG_FILE --env AWS_ROLE_ARN --env AWS_ROLE_SESSION_NAME --env AWS_WEB_IDENTITY_TOKEN_FILE --env AWS_ROLE_ARN --env AWS_METADATA_SERVICE_TIMEOUT --env AWS_METADATA_SERVICE_NUM_ATTEMPTS --env AWS_STS_REGIONAL_ENDPOINTS --env AWS_MAX_ATTEMPTS --env AWS_RETRY_MODE --env AWS_EC2_METADATA_DISABLED --env AWS_SDK_UA_APP_ID ghcr.io/alexstorm1313/aws-cli:latest $@"
# Enable tab completion for the containerized AWS CLI
complete -C "docker run --rm -i --entrypoint /usr/local/bin/aws_completer -e COMP_LINE -e COMP_POINT ghcr.io/alexstorm1313/aws-cli:latest $@" aws
After adding these lines, restart your shell or run source ~/.bashrc
(or equivalent) to apply the changes.
Once the alias is set up, you can use the aws
command as if it were installed locally:
# List S3 buckets
aws s3 ls
# Describe EC2 instances
aws ec2 describe-instances
# Any other AWS CLI command
aws [service] [command]
The alias runs the AWS CLI inside a container with the following configuration:
--privileged --rm -i
: Runs in privileged mode, removes the container after execution, and keeps STDIN open-v ~/.aws:/root/.aws
: Mounts your local AWS credentials directory into the container-v $(pwd):/aws
: Mounts your current working directory to /aws in the containerghcr.io/alexstorm1313/aws-cli:latest
: Uses the latest version of the container image$@
: Passes all arguments to the AWS CLI inside the container
The containerized AWS CLI respects your AWS profiles:
aws --profile production s3 ls
Since your current directory is mounted in the container, you can reference local files directly:
aws s3 cp ./localfile.txt s3://my-bucket/
If you want to build the container image yourself:
git clone https://github.com/AlexStorm1313/aws-cli.git
cd aws-cli
make build
Then update your alias to use your local image:
# Create an alias for the containerized AWS CLI
alias aws="podman run --privileged --rm -it -v ~/.aws:/root/.aws -v $(pwd):/aws --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --env AWS_DEFAULT_REGION --env AWS_DEFAULT_OUTPUT --env AWS_PROFILE --env AWS_CA_BUNDLE --env AWS_SHARED_CREDENTIALS_FILE --env AWS_CONFIG_FILE --env AWS_ROLE_ARN --env AWS_ROLE_SESSION_NAME --env AWS_WEB_IDENTITY_TOKEN_FILE --env AWS_ROLE_ARN --env AWS_METADATA_SERVICE_TIMEOUT --env AWS_METADATA_SERVICE_NUM_ATTEMPTS --env AWS_STS_REGIONAL_ENDPOINTS --env AWS_MAX_ATTEMPTS --env AWS_RETRY_MODE --env AWS_EC2_METADATA_DISABLED --env AWS_SDK_UA_APP_ID localhost/aws-cli:latest $@"
# Enable tab completion for the containerized AWS CLI
complete -C "podman run --rm -i --entrypoint /usr/local/bin/aws_completer -e COMP_LINE -e COMP_POINT localhost/aws-cli:latest $@" aws
# Create an alias for the containerized AWS CLI
alias aws="docker run --privileged --rm -it -v ~/.aws:/root/.aws -v $(pwd):/aws --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --env AWS_DEFAULT_REGION --env AWS_DEFAULT_OUTPUT --env AWS_PROFILE --env AWS_CA_BUNDLE --env AWS_SHARED_CREDENTIALS_FILE --env AWS_CONFIG_FILE --env AWS_ROLE_ARN --env AWS_ROLE_SESSION_NAME --env AWS_WEB_IDENTITY_TOKEN_FILE --env AWS_ROLE_ARN --env AWS_METADATA_SERVICE_TIMEOUT --env AWS_METADATA_SERVICE_NUM_ATTEMPTS --env AWS_STS_REGIONAL_ENDPOINTS --env AWS_MAX_ATTEMPTS --env AWS_RETRY_MODE --env AWS_EC2_METADATA_DISABLED --env AWS_SDK_UA_APP_ID localhost/aws-cli:latest $@"
# Enable tab completion for the containerized AWS CLI
complete -C "docker run --rm -i --entrypoint /usr/local/bin/aws_completer -e COMP_LINE -e COMP_POINT localhost/aws-cli:latest $@" aws
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
see the LICENSE file for details.
- AWS for the amazing AWS CLI tool
- The Podman and Docker teams for providing great container runtimes