Back

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

I am trying to embed access and secret key along with aws cli. e.g.

aws ec2 describe-instances --aws-access-key <access_key> --aws-secret-key <secret_key>

Also tried with -o and -w options for access and secret key respectively. It says: Unknown option aws-access-key and aws-secret-key

1 Answer

0 votes
by (18.2k points)

You can pass the credentials by configuring the AWS CLI or by setting your environment variables so your CLI just reads the key from the variable.

Configuring the AWS CLI:

aws configure

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE

AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Default region name [None]: us-west-2

Default output format [None]: json

Setting Environment variables in Linux, macOS or Unix:

export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE

export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

export AWS_DEFAULT_REGION=us-west-2

Setting Environment variables in Windows

setx AWS_ACCESS_KEY_ID AKIAIOSFODNN7EXAMPLE

setx AWS_SECRET_ACCESS_KEY wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

setx AWS_DEFAULT_REGION us-west-2

You can check out this official documentation also, https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

Related questions

0 votes
1 answer
asked Dec 19, 2020 in AWS by devin (5.6k points)

Want to get 50% Hike on your Salary?

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

0 votes
1 answer

Browse Categories

...