I'm trying to spin up a s3 bucket via the AWS CLI and I'm getting the error "upload failed: .\mylocalfile.txt to s3://testBucket/mylocalfile.txt Unable to locate credentials".
I've ran aws configure and aws configure set on a default profile and i've done aws configure on a specific profile as well. In either case when I run AWS configure list I get the following
Name Value Type Location
---- ----- ---- --------
profile TestProfile manual --profile
access_key <not set> None None
secret_key <not set> None None
region us-east-1 config-file ~/.aws/config
the secret key is set in the same config file as the region but they are being located for some reason.
When I run AWS configure list --profile TestProfile I expect the credentials set in AWS configure to appear properly.
Related
After typing aws configure list command in my project path, I get:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************skey env
secret_key ****************tkey env
region <not set> None None
My ~/.aws/credentials and ~/.aws/config looks like below:
~/.aws/credentials
[default]
aws_access_key_id=xxx
aws_secret_access_key=xxx
~/.aws/config
[default]
region=us-east-1
output=json
I tried to set aws configure in the path of this project, but the only change is region:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************skey env
secret_key ****************tkey env
region us-east-01 config-file ~/.aws/config
Conclusion: even though ~/.aws/credentials and ~/.aws/config are correct and I tried to set them in the project path, it still doesn't read the credentials correctly.
The only change was in the region because it was set to none; the rest is still read from env
How to unset these credentials and make them read from the above mentioned files (default user)?
I did it manually using unset:
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
After that, both the access key and the secret key read from the file:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************AYX shared-credentials-file
secret_key ****************vwT shared-credentials-file
region us-east-01 config-file ~/.aws/config
I've tried to set the default profile using the command below and now it reads it as default but type is env - not the shared-credentials-file or ~/.aws/config or ~/.aws/credential file.
export AWS_DEFAULT_PROFILE=default
It seems to work, but I don't think it's a valid solution...
The AWS CLI credentials and configuration settings take precedence in the following order:
command line options (--region, --output, and --profile)
environment variables
CLI credentials file
CLI config file
container credentials
EC2 instance profiles credentials
So, to force the AWSCLI to read the default configuration from the credentials/config files in ~/.aws/, don't supply --profile on the command line and don't have the AWS_PROFILE or AWS_ACCESS_KEY_ID environment variables set.
Read more at Configuration settings and precedence.
Also, I see no mention of AWS_DEFAULT_PROFILE at AWS CLI supported environment variables. I believe that it was deprecated some time ago in favor of AWS_PROFILE.
I can run the AWS CLI aws configure command and it lists my credentials. I even have a named profile I use.
However, my system does not have Users\{profile}\.aws\credentials file. Where could my credentials be stored?
The following command returns this but ~/.aws/config is empty for all the accounts I have on this machine. I have hidden files shown.
$aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************BBBB shared-credentials-file
secret_key ****************BBBB shared-credentials-file
region us-east-1 config-file ~/.aws/config
As others pointed out the location of your AWS credentials should be in %USERPROFILE%\.aws
Follow these steps and let's see what you get
Open terminal
Run: cd %UserProfile%\.aws
Run: type credentials
Another option is that you have added AWS_SHARED_CREDENTIALS_FILE environment variable. This changes the default location of the shared credentials file (https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#the-shared-credentials-file). Try these steps:
Open terminal
Run: echo %AWS_SHARED_CREDENTIALS_FILE%
Run: type %AWS_SHARED_CREDENTIALS_FILE%
I have solved this creating a profile:
aws configure --profile {profile-name}
set any values
The /.aws/ folder have been created and now you can edit their files.
I cannot seem to get my AWS provider to use my AWS credentials in the Docker Containers
I have ran all of these so far
serverless config credentials --provider provider --key key --secret secret
&
aws configure
☝️ ran through the prompts and plugged in my info
&
export AWS_ACCESS_KEY_ID=blah
export AWS_SECRET_ACCESS_KEY=blah
export AWS_DEFAULT_REGION=east-whatever
But still, get stopped by AWS
ServerlessError: AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here:.
I have also generated and regenerated my IAM creds multipule time, also whne I run aws configure list it returns
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************67GT shared-credentials-file
secret_key ****************6glt shared-credentials-file
region us-east-2 config-file ~/.aws/config
I am not sure what else to do, I am on Ubuntu 20.04 using Bash
I will take approach of setting everything using aws-cli ( hence aws cli installation is imp)
install aws cli
run aws configure -> enter your creds, this info will be stored in profile called default in ~/.aws/credentials file. docs.
verify your configuration by checking ~/.aws/config ~/.aws.credentials file
for serverless frame work deployment use this serverless deploy.
if mutiple profiles needs to be used use sls deploy --aws-profile profile-name
I have multiple profiles set up in my .aws\credentials file.
From the Windows 10 command line I have tried two approaches as per https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
aws cp s3://bucketname etc... --profile profile1
setx AWS_PROFILE profile1
aws cp etc...
Both cases give me "unable to locate credentials" on each file that is being uploaded to S3.
I use these profiles in Python with no issue.
This is the output of the "aws configure list" command:
C:\Users\nwalt>aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key <not set> None None
secret_key <not set> None None
region us-east-1 config-file ~/.aws/config
but if I type "aws configure list --profile profile",
then I see the profile name, and keys filled in.
Turns out, I was not reading carefully. After adding the --profile profile1, the error changed to "access denied", which is something totally different.
I'm leaving the question though, because it might help someone see how to work with multiple profiles.
I have the default region set in ~/.aws/config file:
[default]
region=us-west-2
However, when I try describe-instances command for some specific profile it is failing with the following message:
$ aws ec2 describe-instances --profile my_profile
You must specify a region. You can also configure your region by running "aws configure".
Shouldn't it used the default profile configured in ~/.aws/config file? What am I missing here?
Output of aws configure list:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ******************** shared-credentials-file
secret_key ******************** shared-credentials-file
region us-west-2 config-file ~/.aws/config
Output of aws configure list --profile my_profile
Name Value Type Location
---- ----- ---- --------
profile my_profile manual --profile
access_key ******************** shared-credentials-file
secret_key ******************** shared-credentials-file
region <not set> None None
p.s. new to AWS. pardon me if this is a very basic question.
You are using named profiles, by default default profile is used. Just like you configure default, you can/need to configure your profile.
aws configure --profile my_profile
It will prompt you to fill access key, secret access key, AWS Region, and output format as it is stated here
You can create additional configurations that you can refer to with a name by specifying the --profile option and assigning a name. The following example creates a profile named produser. You can specify credentials from a completely different account and Region than the other profiles.