Welcome to this guide on how to install and configure the AWS command line interface. The command line interface is a powerful tool for programmatically managing and configuring AWS services and automating processes for those resources using scripts.
Download and run the installer
Download the installer here
Follow the Installation Wizard to complete the installation.
Verify Installation
Open up a command prompt and run aws --version
You should see the version number in response.
Configure Access
Firstly, we need to create a user with permissions for the AWS resources we want to access programmatically. In AWS permissions are explicitly set for users with the IAM (Identity Access Management) console.
-> Log into AWS console. Find the IAM dashboard by typing IAM into the search bar.
-> On the left hand panel, click users, and then click create user.
-> Give the user a name, and click next. Do not tick the console access button, we only want this user to have programmatic access.
-> For permissions, attach an existing policy, search for and add AmazonS3FullAccess.
-> Review and create user.
Create Access Key
-> From the users dashboard select the user we just created. Then click on create access key.
-> Select other and click next.
-> Tags are optional so leave as is and click create access key.
-> You should be on the retrieve access key page. Stay on this page for the next step. Please note the security warnings regarding access keys.
CLI configuration
Inside your command prompt run aws configure
As the command requests, copy and paste in your access key and secret access key. Type in your region, which is available in the top right corner of the AWS console.
It should look something like this
Click done on the retrieve access key page.
Test configuration
To ensure your permissions are working correctly, create an s3 bucket from the CLI with the following command. AWS S3 bucket names must be unique.
aws s3 mb s3://nat-blog-test-1
List the contents of the bucket, it is empty so nothing is listed.
aws s3 ls s3://nat-blog-test-1
Create a file to upload to the s3 bucket.
echo hello aws > testfile.txt
Use the cp (copy) command to upload it to the bucket.
aws s3 cp <path to file> s3://bucket-name
You can either list the contents of the bucket again or go to S3 on the AWS console and confirm the bucket has been created and the file has been uploaded. If the file is there, then the configuration has been successful.
Thanks for reading :)
Top comments (0)