Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
6 views
in AWS by (19.1k points)

I am writing a bash script that will automatically install and configure AWS CLI tools. I am able to install AWS CLI tools but unable to configure it.

My script is something like this:

#!/bin/bash

wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip

unzip awscli-bundle.zip

sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

./awscli-bundle/install -b ~/bin/aws

./awscli-bundle/install -h

aws configure

AWS Access Key ID [None]: ABCDEFGHIJKLMNOP   ## unable to provide this data

AWS Secret Access Key [None]: xbdwsdADDS/ssfsfa/afzfASADQASAd   ## unable to provide this data

Default region name [None]: us-west-2   ## unable to provide this data

Default output format [None]: json   ## unable to provide this data

I wish to do the configuration using this script too. I wish that I can provide these credentials via script so that it prevents manual entry. How can this be done?

1 Answer

0 votes
by (44.4k points)
edited by

Use a configuration file rather than the aws configure command. Create a file called ~/.aws/config that looks like this:

[default]

aws_access_key_id=AKIAIOSFODNN7EXAMPLE

aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

region=us-west-2

output=json

More info in the docs.

If you are keen to learn about the various AWS skills then this AWS Training page availed by Intellipaat is the right course for you. This course will help you learn to master AWS skills and ace the AWS certification exam!

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...