Serverless Error: The security token included in the request is invalid
Asked Answered
R

9

17

when i type serverless deploy appear this error: ServerlessError: The security token included in the request is invalid.

Ruffian answered 16/11, 2018 at 20:29 Comment(0)
P
17

I had to specify sls deploy --aws-profile in my serverless deploy commands like this:

sls deploy --aws-profile common

Pylle answered 21/10, 2019 at 21:36 Comment(0)
D
3

Can you provide more information?

Make sure that you've got the correct credentials in ~/.aws/config and ~/.aws/credentials. You can set these up by running aws configure. More info here: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-quick-configuration

Also make sure that the IAM user in question has as an attached security policy that allows access to everything you need, such as CloudFormation.

Danika answered 16/11, 2018 at 20:46 Comment(1)
there was all fine, seems there are a problem with windows, i downloaded another console: "ubuntu bash for windows" and install again nodejs, npm and serverless in that console, then i created a project and typed "serverless deploy" and it workRuffian
S
3

Create a new user in AWS (don't use the root key).

In the SSH keys for AWS CodeCommit, generate a new Access Key.

Copy the values and run this:

serverless config credentials --overwrite --provider aws --key bar --secret foo

sls deploy

enter image description here

Sayer answered 1/2, 2021 at 1:28 Comment(0)
J
1

In my case, I added region to the provider. I suppose it's not read from the credentials file.

provider:
  name: aws
  runtime: nodejs12.x
  region: cn-northwest-1
Jaunita answered 9/9, 2021 at 7:42 Comment(0)
S
0

In my case it was missing the localstack entry in the serverless file. I had everything that should be inside it, but it was all inside custom (instead of custom.localstack).

Santiagosantillan answered 30/7, 2021 at 22:2 Comment(0)
M
0

In my case, multiple credentials are stored in the ~/.aws/credentials file.

And serverless is picking the default credentials.

So, I kept the new credentials under [default] and removed the previous credentials. And that worked for me.

enter image description here

Mite answered 29/11, 2021 at 3:3 Comment(2)
Hope these credentials are fake, As for the good practice we should not share aws secretes to any oneInterscholastic
They stole my credentials once by my mistake... They used it to mine crypto and I got billed 75K USD a day... Luckely for me AWS saved me with it <3Kath
R
0

to run the function from AWS you need to configure AWS with access_key_id and secret_access_key but to might get this error if you want to run the function locally so for that use this command

sls invoke local -f functionName

it will run the function locally not on aws

Reproduction answered 20/8, 2022 at 18:24 Comment(0)
C
0

If none of these answers work, it's maybe because you need to add a provider in your serverless account and add your AWS keys.

enter image description here

Clevey answered 7/11, 2022 at 4:4 Comment(0)
D
0

If your credentials on ~/.aws/credentials file are fine. Delete line on your .yml config file

region: us-east-1

and try again

Delusive answered 11/2 at 11:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.