8
votes

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

5

5 Answers

4
votes

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

sls deploy --aws-profile common

1
votes

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.

0
votes

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

0
votes

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).

0
votes

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