To set up two profiles in AWS CLI, you use the ~/.aws/config and ~/.aws/credentials files to configure separate profiles.
Here's a step-by-step guide:
To introduce new data or new config without restarting or recreating containers, we have to copy files from the host to a Docker container. It smoothes out workflows while working with development, debugging, data sharing between host system and the containerized application.
1. Open AWS Configuration Files
The configuration file is located at ~/.aws/config.
The credentials file is located at ~/.aws/credentials.
2. Add Profiles in the Configuration File (~/.aws/config)
Add entries for each profile with different names. For example:
[default]
region = us-east-1
output = json
[profile dev]
region = us-west-2
output = json
[profile prod]
region = ap-south-1
output = json
3. Add Credentials in the Credentials File (~/.aws/credentials)
Each profile needs corresponding credentials:
[default]
aws_access_key_id = YOUR_DEFAULT_ACCESS_KEY
aws_secret_access_key = YOUR_DEFAULT_SECRET_KEY
[dev]
aws_access_key_id = YOUR_DEV_ACCESS_KEY
aws_secret_access_key = YOUR_DEV_SECRET_KEY
[prod]
aws_access_key_id = YOUR_PROD_ACCESS_KEY
aws_secret_access_key = YOUR_PROD_SECRET_KEY
4. Use the Profiles
When using the AWS CLI, specify the profile with the --profile flag. For example:
Use the dev profile
aws s3 ls --profile dev
Use the prod profile
aws s3 ls --profile prod
5. (Optional) Set Environment Variables
To make a profile the default temporarily, set the AWS_PROFILE environment variable:
export AWS_PROFILE=dev
Now, any AWS CLI commands will use the dev profile without needing the --profile flag. Let me know if you encounter any issues!
By using the above steps we can easily set the multiple profiles in AWS CLI.
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise.
0