Serverless framework deployment error: You're not authorized to access this resource

Viewed 2806

When I deploy my serverless framework project using AWS as provider I get:

You're not authorized to access this resource. - Please contact support and provide this identifier to reference this issue BLAHBLAH

I am logged into Serverless framework with serverless login

My serverless.yaml:

org: vladimirorg
app: vladimirapp
service: backend-rest

provider:
  name: aws
  runtime: nodejs12.x
  apiGateway: {
    shouldStartNameWithService: true
  }

  environment:
    DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
    DYNAMODB_LOCAL_PORT: 9000
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:provider.environment.DYNAMODB_TABLE}"

functions:
  create:
    handler: src/handlers/create.create
    events:
      - http:
          path: todos
          method: post
          cors: true
          request:
            schema:
              application/json: ${file(src/schemas/create.json)}
...
4 Answers

I have found the root cause - if you wish to deploy serverless framework application you must use the exact same organization (org) and application name (app) as one you registered with serverless framework.

To find out your current app/org name, change them or create new app/org login to Serverless Framework’s dashboard account on https://app.serverless.com/ using same credentials you use for deploying and make sure you are using the exact org and app in your serverless.yaml file:

org: orgname  <---
app: appname  <--- 
service: backend-rest
...

So you can't just use any arbitrary org/app name, you must use exact org/app registered with Serverless framework.

I had to remove org: <org> in order for it to ask me again next time sls is run.

Try using serverless logout or deleting the ~\.serverlessrc file then run serverless login again and try your command

you need to specify AWS profile in your serverless.yml, and set your AWS account credential in ~/.aws/credentials like below:

[your_preferred_profile_name]
aws_access_key_id=AKIAZEIJOWEFJOIWEF
aws_secret_access_key=siAOEIF4+TdifOHeofoe+iJR8yFokT7uBmV4DEZ

And speciffy this profile in your serverless.yml file like this:

provider:
  name: aws
  runtime: nodejs12.x
  stage: dev
  region: us-east-1
  profile: your_preferred_profile_name

The error you are getting is saying sls framework couldn't access to your AWS resources. It means you didn't setup this AWS account credential in your local environment and serverless framework.

Related