In this blog post, we will show how to create an AWS credentials file without using AWS configure to configure access to AWS.
Before we start with the actual configuration, let first cover why do we need a credentials file. With AWS, a credentials file is used to authenticate using an access key and a secret access key.
By default, AWS will create a credential file for us when we run the aws configure command using AWS CLI; however, you might not be able to run the aws configure wizard in some environments.
AWS uses two files to control AWS CLI commands or other automation tools like Terraform. The file that AWS uses are:
- credentials – Use to store access key and secret access key
- config – Use to store environmental information like region, etc
For AWS to read our credentials and config file, let’s create two files in the .aws directory using the following commands.
cd ~/.aws touch config touch credentials
In the config file, copy the lines below and feel free to set your default region and output format when you are done. Save the file.
[default] region=ap-southeast-2 output=json
Now let create our credentials file; you will need your access key and secret access ready for this step. Fill in the details and save the file.
[default] aws_access_key_id=youraccesskey aws_secret_access_key=yoursecretaccess
At this stage, you are ready to run AWS CLI commands. You can start with a simple command that lists all your S3 buckets.
aws s3 ls
Leave a Reply