I am trying to embed access and secret key along with aws cli. e.g.
aws ec2 describe-instances --aws-access-key --aws-secret-key
You can also use aws configure:
$ aws configure
AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxx
You can set credentials with:
aws configure set aws_access_key_id <yourAccessKey>
aws configure set aws_secret_access_key <yourSecretKey>
Verify your credentials with:
aws sts get-caller-identity
For more information on set command:
aws configure set help
General pattern is:
aws <command> help
aws <command> <subcommand> help
Note: Before overriding your credentials, you may want to keep a copy of it:
aws configure get aws_access_key_id
aws configure get aws_secret_access_key
Summarizing the aws doc, there several ways to pass credentials to the command line. Please note that there are no command line options to pass in the the key and secret key directly. The "provider chain" is used instead.
In my bash scripts, I often use environment variables. To add a tiny bit of security, I source a file containing the variables rather than putting them in the script. With named profiles, it's even easier.
The provider chain is:
Use the access key and id is not recommended as it will be stored in config file. Better approach is to create an IAM role and give required access which you need.
You should store your credentials to ~/.aws/config file (or .aws/credentials)
More info how to setup it http://docs.aws.amazon.com/cli/latest/reference/configure/index.html
Also as alternative way you can create IAM role and certain policy and set it to you ec2 instance where you will use aws cli, then you won't need any credentials setup there