Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure AWS credetials #50

Open
pran-m opened this issue Dec 4, 2019 · 5 comments
Open

How to configure AWS credetials #50

pran-m opened this issue Dec 4, 2019 · 5 comments

Comments

@pran-m
Copy link

pran-m commented Dec 4, 2019

How to add ~/.aws credential folder to the lambda?. I tried directly exporting the variable in the code but it is not getting set.

handler () {
set -e
# Event Data is sent as the first parameter
EVENT_DATA=$1
echo $EVENT_DATA

export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxx
export AWS_SECRET_ACCESS_KEY=yyyyyy
export AWS_DEFAULT_REGION=us-east-1

aws configure  // This gives output as -  "AWS Access Key ID [None]:"

}

@digitalsushi
Copy link

Could this be better handled by assigning Roles to the Lambda? Then you don't need to put those secure credentials in the code.

@jpcarnes
Copy link

I have run into this same issue and am still looking for an answer.

@digitalsushi the issue with this solution is that for my use case I am receiving temporary aws credentials from a curl POST command and then need to set the environment variables for my lambda function equal to the temporary credentials.

Any insights on this would be greatly appreciated.

Thanks!

@gkrizek
Copy link
Owner

gkrizek commented Mar 19, 2020

You should use the Lambda role. It uses it automatically. If you have a reason to use different credentials you could write them to /tmp/.aws/credentials and /tmp/.aws/config. Then you need to run

export AWS_CONFIG_FILE=/tmp/.aws/config
export AWS_SHARED_CREDENTIALS_FILE=/tmp/.aws/credentials

@jpcarnes
Copy link

@gkrizek - thanks for the swift response. I do need to change he credentials, I had tried commands such as:

export AWS_ACCESS_KEY=myAccessKey

But kept getting errors saying that these types of environment variables are reserved and can't be changed in a lambda function as it's running.

I'm kind of new to bash scripts... For the exports you mentioned above would I need to create the config and credential files in the script or do those already come as files inside the lambda functions /tmp file when it executes.

thanks for the help!

@ljubaisakovic
Copy link

It seems that AWS CLI credentials are always being overwritten by IAM role lambda privileges, even if you export AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE.

So far I haven't been able to find a workaround because using the Lambda role does the work for me, but there has to be a workaround...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants