localstack / serverless-localstack

⚡ Serverless plugin for running against LocalStack
511 stars 82 forks source link

Getting error : The security token included in the request is invalid. #169

Closed dianapps-vaibhav closed 2 years ago

dianapps-vaibhav commented 2 years ago

Stuck with an issue where running

AWS_PROFILE=default PLATFORM=punga SERVICE_BASE_PATH=auth SERVERLESS_ENV=local NODE_ENV=local sls deploy --verbose --aws-profile default --stage local --config stacks/punga-db/serverless.yml

Results in

$ AWS_PROFILE=default PLATFORM=punga SERVICE_BASE_PATH=auth SERVERLESS_ENV=local NODE_ENV=local sls deploy --verbose --aws-profile default --stage local --config stacks/punga-db/serverless.yml
[aws-config] Using development configuration.
ENV: {
  AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
  CURRENT_VERSION: '2.0.29',
  DEBUG: 'app:*',
  NODE_ENV: 'local',
  PLATFORM: 'punga',
  SERVERLESS_ENV: 'local',
  SERVICE_BASE_PATH: '/auth',
  SERVICE_NAME: 'punga-db',
  SERVICE_REGION: 'us-east-1',
  SERVICE_RUNTIME: 'nodejs12.x',
  SNS_TOPIC_ANALYTICS: 'arn:aws:sns:us-east-1:713691078682:punga-analytics-dev',
  SNS_TOPIC_CONTACTS: 'arn:aws:sns:us-east-1:713691078682:punga-contacts-dev',
  PAGINATION_ENCRYPTION_KEY: '72062df7e13d9544a149e5ec4384763ds20348fa',
  TABLE_NAME: 'punga-app-dev',
  AUTH0_JWKS_URI: 'https://punga-dev.us.auth0.com/.well-known/jwks.json',
  AUTH0_AUDIENCE: 'Oow2NYsoa2YkSZF1ngWwELJn9GlqlugF',
  AUTH0_TOKEN_ISSUER: 'https://punga-dev.us.auth0.com/',
  AUTH0_UUID_CLAIM_KEY: 'https://pungabet.com/claims/uuid',
  PUBNUB_SUBSCRIBE_KEY: 'sub-c-2d326914-017f-11ec-a04b-221653618fb7',
  PUBNUB_PUBLISH_KEY: 'pub-c-5b950593-6223-4295-bb66-f7576e5a735d',
  PUBNUB_SECRET_KEY: 'sec-c-OTY2ODVjZDctOTkwOC00MGFhLTg0ODctZjNmYmIzYTQwNmE0',
  PUBNUB_WEBHOOK_API_KEY: 'NkfPgEvdJsuNn3igAXRMJE2gqr2pyRj9mFu9PucxKV3MzpModmF3JdB7FMWXAET3',
  SEGMENT_WRITE_KEY: 'd6kDfE7nSsWqm4NbOkSrZv0iIGX8uWbI',
  CONTENTFUL_ACCESS_TOKEN: 'mQyeeqLFIYjqsayOqj30QmlgIz8TPBQcg2FTCQziT58',
  CONTENTFUL_SPACE_ID: 'edx37t3e828r',
  GIPHY_API_KEY: 'VtFOP3GgfrPo3KPWfjw0U5g8aD6VtIHi',
  WEB_DOMAIN: 'dev.pungabet.com',
  API_V2_DOMAIN: 'v2-dev.api.pungabet.com',
  UPLOADS_DOMAIN: 'punga-uploads-dev.imgix.net',
  SENTRY_DSN: 'https://3fce5b0d7f5142aabb06a8dcb4d9713a@o423480.ingest.sentry.io/5563517',
  APP_BUNDLE_ID: 'com.pungabet.dev',
  GIPHY_API_SEARCH_API_URL: 'http://api.giphy.com/v1/gifs/search',
  GIPHY_API_BASE_URL: 'http://api.giphy.com'
}
Serverless: Configuration warning:
Serverless:   at 'plugins': should be array
Serverless:   at 'functions': should be object
Serverless:  
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:  
Serverless: Packaging service...

  Serverless Error ---------------------------------------

  The security token included in the request is invalid.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              16.2.0
     Framework Version:         1.83.3 (local)
     Plugin Version:            3.8.4
     SDK Version:               2.3.2
     Components Version:        2.34.9

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is the yml file

service: punga-db

frameworkVersion: ">=1.45.0 <2.0.0"

plugins:

custom:
  localstack:
    debug: true
    stages: 
      - local
    host : http://localhost
    edgePort : 4566
    autostart: true
    endpointFile: localstack_endpoints.json
    lambda:
      mountCode : false
  stage: ${opt:stage}
  account_id: 000000000000
  region: us-east-1
  platform: punga
  lambda_arn_prefix: "arn:aws:lambda:${self:custom.region}:${self:custom.account_id}:function:${self:service}-${self:custom.stage}"
  prune:
    automatic: true
    number: 5
  tableName: ${file(src/config.js):env.TABLE_NAME}

provider:
  profile : default
  name: aws
  runtime: nodejs12.x
  stage: "${self:custom.stage}"
  region: "${self:custom.region}"
  environment:
    SERVERLESS_ENV: "${self:custom.stage}"

functions:

resources:
  Resources:
    AppDynamoDbTable:
      Type: "AWS::DynamoDB::Table"
      Properties:
        TableName: ${self:custom.tableName}
        AttributeDefinitions:
          - AttributeName: "PK"
            AttributeType: "S"
          - AttributeName: "SK"
            AttributeType: "S"
          - AttributeName: "GSI1PK"
            AttributeType: "S"
          - AttributeName: "GSI1SK"
            AttributeType: "S"
          - AttributeName: "GSI2PK"
            AttributeType: "S"
          - AttributeName: "GSI2SK"
            AttributeType: "S"
          - AttributeName: "GSI3PK"
            AttributeType: "S"
          - AttributeName: "GSI3SK"
            AttributeType: "S"
          - AttributeName: "GSI4PK"
            AttributeType: "S"
          - AttributeName: "GSI4SK"
            AttributeType: "S"
          - AttributeName: "GSI5PK"
            AttributeType: "S"
          - AttributeName: "GSI5SK"
            AttributeType: "S"
          - AttributeName: "GSI6PK"
            AttributeType: "S"
          - AttributeName: "GSI6SK"
            AttributeType: "S"
        KeySchema:
          - AttributeName: "PK"
            KeyType: "HASH"
          - AttributeName: "SK"
            KeyType: "RANGE"
        BillingMode: "PAY_PER_REQUEST"
        GlobalSecondaryIndexes:
          - IndexName: "GSI1"
            KeySchema:
              - AttributeName: "GSI1PK"
                KeyType: "HASH"
              - AttributeName: "GSI1SK"
                KeyType: "RANGE"
            Projection:
              ProjectionType: ALL
          - IndexName: "GSI2"
            KeySchema:
              - AttributeName: "GSI2PK"
                KeyType: "HASH"
              - AttributeName: "GSI2SK"
                KeyType: "RANGE"
            Projection:
              ProjectionType: ALL
          - IndexName: "GSI3"
            KeySchema:
              - AttributeName: "GSI3PK"
                KeyType: "HASH"
              - AttributeName: "GSI3SK"
                KeyType: "RANGE"
            Projection:
              ProjectionType: ALL
          - IndexName: "GSI4"
            KeySchema:
              - AttributeName: "GSI4PK"
                KeyType: "HASH"
              - AttributeName: "GSI4SK"
                KeyType: "RANGE"
            Projection:
              ProjectionType: ALL
          - IndexName: "GSI5"
            KeySchema:
              - AttributeName: "GSI5PK"
                KeyType: "HASH"
              - AttributeName: "GSI5SK"
                KeyType: "RANGE"
            Projection:
              ProjectionType: ALL
          - IndexName: "GSI6"
            KeySchema:
              - AttributeName: "GSI6PK"
                KeyType: "HASH"
              - AttributeName: "GSI6SK"
                KeyType: "RANGE"
            Projection:
              ProjectionType: ALL
        StreamSpecification:
          StreamViewType: NEW_AND_OLD_IMAGES
        PointInTimeRecoverySpecification:
          PointInTimeRecoveryEnabled: True
whummer commented 2 years ago

Thanks for reporting @dianapps-vaibhav .

Please note that you'll need to activate the plugin in your config via:

plugins:
  - serverless-localstack

Also, we recommend upgrading the framework version to a more recent version (i.e., not restricting as <2.0.0)

frameworkVersion: ">=1.45.0"

Hope that helps - please let us know if the problem persists.. Thanks!