Michael McDowell
Michael McDowell

Reputation: 413

AWS CLI Configure Profile parameters

Calling the following AWS CLI SDK command triggers the shell prompting for a series of values:

$ aws configure --profile profilename

$ AWS Access Key ID [None]: etc....

Is there any way to specify the parameters in line? E.g.

$ aws configure --profile profilename --access-key=foo --access-secret=goo --region=bar

Thanx in adv, Michael McD

Upvotes: 6

Views: 5997

Answers (1)

tremby
tremby

Reputation: 10069

Sort of. You can't do them all at once (aws configure help will show you there are no such options), but can do them one at a time.

From aws configure set help:

Given an empty config file, the following commands:

$ aws configure set aws_access_key_id default_access_key
$ aws configure set aws_secret_access_key default_secret_key
$ aws configure set default.region us-west-2
$ aws configure set default.ca_bundle /path/to/ca-bundle.pem
$ aws configure set region us-west-1 --profile testing
$ aws configure set profile.testing2.region eu-west-1
$ aws configure set preview.cloudsearch true

will produce the following config file:

[default]
region = us-west-2
ca_bundle = /path/to/ca-bundle.pem

[profile testing]
region = us-west-1

[profile testing2]
region = eu-west-1

[preview]
cloudsearch = true

and the following ~/.aws/credentials file:

[default]
aws_access_key_id = default_access_key
aws_secret_access_key = default_secret_key

Note that you could also set the credentials temporarily as environment variables when running other aws commands. If that's interesting to you, see the documentation. You can't just set them and run aws configure --profile profilename though -- this will still prompt you.

Upvotes: 6

Related Questions