# Consistently Failing Localstack Serverless Spin Up

**URL:** <https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [January 11, 2021, 10:49pm UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684 "2021-01-11T22:49:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://forum.serverless.com/u/Cristian)\
**Post date:** [January 11, 2021, 10:49pm UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684/1 "2021-01-11T22:49:18Z")

</div>

I am making use of localstack, cloudformation, and serverless-localstack to create a local environment for my team and every time I get to using serverless-localstack as a way to creating and attaching my lambda function to my other localstack resource I keep getting failures in the actual bucket creation for my serverless.yml

I have created and exposed all my outputs via cloudformation for this lambda to hook, I have verified the variables all exist and I believe I have properly configured my serverless.yml except that I consistently fail in utilizing serverless to establish the s3 bucket and correctly attach the event map from my SQS to it.

Below is the terminal output related to me running `serverless deploy --stage local`

```auto
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Deprecation warning: Detected ".env" files. Note that Framework now supports loading variables from those files when "useDotenv: true" is set (and that will be the default from next major release)
            More Info: https://www.serverless.com/framework/docs/deprecations/#LOAD_VARIABLES_FROM_ENV_FILES
Serverless: To ensure safe major version upgrades ensure "frameworkVersion" setting in service configuration (recommended setup: "frameworkVersion: ^2.15.0")

Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Using serverless-localstack
Serverless: Warning: Unable to find plugin named: TypeScriptPlugin
Serverless: Load command deploy
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Compiling with Typescript...
Serverless: Typescript compiled.
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Invoke aws:package:finalize
AWS Pseudo Parameters
Skipping automatic replacement of regions with account region!
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::0 Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::0 Replaced AWS::AccountId with ${AWS::AccountId}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::1 Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::1 Replaced AWS::AccountId with ${AWS::AccountId}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::3::Resource Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::3::Resource Replaced AWS::AccountId with ${AWS::AccountId}
Serverless: Invoke aws:common:moveArtifactsToPackage
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:deploy:deploy
Serverless: [AWS cloudformation 400 0.021s 0 retries] describeStacks({ StackName: 'message-queue-function-local' })
Serverless: Creating Stack...
Serverless: [AWS cloudformation 400 0.092s 0 retries] createStack({
  StackName: 'message-queue-function-local',
  OnFailure: 'DELETE',
  Capabilities: ['CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', [length]: 2 ],
  Parameters: [[length]: 0 ],
  TemplateBody: '{"AWSTemplateFormatVersion":"2010-09-09","Description":"The AWS CloudFormation template for this Serverless application","Resources":{"ServerlessDeploymentBucket":{"Type":"AWS::S3::Bucket","Properties":{"BucketEncryption":{"ServerSideEncryptionConfiguration":[{"ServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}}]}}},"ServerlessDeploymentBucketPolicy":{"Type":"AWS::S3::BucketPolicy","Properties":{"Bucket":{"Ref":"ServerlessDeploymentBucket"},"PolicyDocument":{"Statement":[{"Action":"s3:*","Effect":"Deny","Principal":"*","Resource":[{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":s3:::",{"Ref":"ServerlessDeploymentBucket"},"/*"]]},{"Fn::Join":["",["arn:",{"Ref":"AWS::Partition"},":s3:::",{"Ref":"ServerlessDeploymentBucket"}]]}],"Condition":{"Bool":{"aws:SecureTransport":false}}}]}}}},"Outputs":{"ServerlessDeploymentBucketName":{"Value":{"Ref":"ServerlessDeploymentBucket"}}}}',
  Tags: [{ Key: 'STAGE', Value: 'local' }, [length]: 1 ]
})
 
  Serverless Error ---------------------------------------
 
  ServerlessError: Unable to create stack "message-queue-function-local": An error occurred (InvalidBucketName) when calling the CreateBucket operation: The specified bucket is not valid.
      at /home/cristian/Desktop/Dev/lambda/modularOnboarding/Generics/Message-Queue-Function/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:1314:27
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
 
  Get Support --------------------------------------------
     Docs: docs.serverless.com
     Bugs: github.com/serverless/serverless/issues
     Issues: forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System: linux
     Node Version: 12.18.1
     Framework Version: 2.14.0 (standalone)
     Plugin Version: 4.1.2
     SDK Version: 2.3.2
     Components Version: 3.4.2

```

Below is the serverless.yml config(obfuscated account details like security group ids):

```auto
service: message-queue-function

plugins:
  - serverless-pseudo-parameters
  - serverless-localstack
  - serverless-plugin-typescript
custom:
  localstack:
    stages:
      # list of stages for which the plugin should be enabled
      - local
    host: http://localhost # optional - LocalStack host to connect to
    edgePort: 4566 # optional - LocalStack edge port to connect to
    autostart: true # optional - Start LocalStack in Docker on Serverless deploy
    lambda:
      # Enable this flag to improve performance
      mountCode: False
    docker:
      # Enable this flag to run "docker ..." commands as sudo
      sudo: False
  setStage: ${opt:stage, self:provider.stage}
  setSecurityGroup:
    prod: 'sg'
    dev: 'sg'
    local: 'sg'
  setSubnet:
    prod: 'subnet'
    dev: 'subnet'
    local: 'subnet'
  setEnvironment:
    ENV:
      local: 'local'
      dev: 'test'
      prod: 'prod'
    SERVER:
      local: 'LOCALHOST'
      dev: 'TEST'
      prod: 'PRODUCTION'
    UTILS:
      local: '../../../utils'
      dev: './utils'
      prod: './utils'

provider:
  name: aws
  stage: local # Default stage if one wasn't passed via command line
  environment:
    # use the ENV value set in the 'custom' section above
    ENV: ${self:custom.setEnvironment.ENV.${self:custom.setStage}}
    SERVER: ${self:custom.setEnvironment.SERVER.${self:custom.setStage}}
    UTILS_PATH: ${self:custom.setEnvironment.UTILS.${self:custom.setStage}}
  runtime: nodejs12.x
  versionFunctions: false
  region: us-east-2
  vpc:
    securityGroupIds:
      - ${self:custom.setSecurityGroup.${self:custom.setStage}}
    subnetIds:
      - ${self:custom.setSubnet.${self:custom.setStage}}

  iamRoleStatements:
    - Effect: 'Allow'
      Action: 'ssm:GetParameters'
      Resource:
        - 'arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter/SLACK_*'
        - 'arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter/DB_*'
    - Effect: 'Allow'
      Action: 'kms:Decrypt'
      Resource: 
        - 'arn:aws:kms:#{AWS::Region}:#{AWS::AccountId}:key/ace909b7-e527-491c-a92a-5e9c679ac9be'
    - Effect: 'Allow'
      Action: 's3:*'
      Resource:
        - '*'
functions:
  message-queue-function:
    handler: message.sendMessage
    events:
    	# Provide the ARN of your previously established queue
      - sqs:
          arn:
            Fn::ImportValue: MessageQueueArn

```

And the pertinent docker-compose.yml config for my localstack looks like below:

```auto
localstack:
    image: localstack/localstack
    networks:
      static-network:
        ipv4_address: 172.18.0.6
    container_name: localstack_dev
    ports:
      - "4566-4597:4566-4597"
      - "8080:8080"
    environment:
      - SERVICES=sns,sqs,s3,cloudformation,cloudwatch,logs,iam,lambda
      - PORT_WEB_UI=8080
      - DEBUG=1
      - DEFAULT_REGION=us-east-2
      - LAMBDA_REMOTE_DOCKER=false
      - HOST_TMP_FOLDER=${TMPDIR}
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

```

Please can someone assist in resolving this, it has to be something I am not seeing. If I re-run the deploy after the above initial error I recieve a different error:

```auto
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Deprecation warning: Detected ".env" files. Note that Framework now supports loading variables from those files when "useDotenv: true" is set (and that will be the default from next major release)
            More Info: https://www.serverless.com/framework/docs/deprecations/#LOAD_VARIABLES_FROM_ENV_FILES
Serverless: To ensure safe major version upgrades ensure "frameworkVersion" setting in service configuration (recommended setup: "frameworkVersion: ^2.15.0")

Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Using serverless-localstack
Serverless: Warning: Unable to find plugin named: TypeScriptPlugin
Serverless: Load command deploy
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Compiling with Typescript...
Serverless: Typescript compiled.
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Invoke aws:package:finalize
AWS Pseudo Parameters
Skipping automatic replacement of regions with account region!
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::0 Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::0 Replaced AWS::AccountId with ${AWS::AccountId}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::1 Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::2::Resource::1 Replaced AWS::AccountId with ${AWS::AccountId}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::3::Resource Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::3::Resource Replaced AWS::AccountId with ${AWS::AccountId}
Serverless: Invoke aws:common:moveArtifactsToPackage
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:deploy:deploy
Serverless: [AWS cloudformation 200 0.047s 0 retries] describeStacks({ StackName: 'message-queue-function-local' })
Serverless: [AWS cloudformation 200 0.012s 0 retries] describeStackResource({
  StackName: 'message-queue-function-local',
  LogicalResourceId: 'ServerlessDeploymentBucket'
})
Serverless: [AWS s3 undefined 0.004s 0 retries] listObjectsV2({ Bucket: '', Prefix: 'serverless/message-queue-function/local' })
 
  Serverless Error ---------------------------------------
 
  ServerlessError: Expected uri parameter to have length >= 1, but found "" for params.Bucket
      at /home/cristian/Desktop/Dev/lambda/modularOnboarding/Generics/Message-Queue-Function/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:1314:27
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
 
  Get Support --------------------------------------------
     Docs: docs.serverless.com
     Bugs: github.com/serverless/serverless/issues
     Issues: forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System: linux
     Node Version: 12.18.1
     Framework Version: 2.14.0 (standalone)
     Plugin Version: 4.1.2
     SDK Version: 2.3.2
     Components Version: 3.4.2

```

---

<div class="post-metadata">

**Author:** ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://forum.serverless.com/u/Cristian)\
**Post date:** [January 13, 2021, 5:06am UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684/2 "2021-01-13T05:06:28Z")

</div>

Update I started with a really simple sls config and modified localstack config and finally got it resolved.

---

<div class="post-metadata">

**Author:** ![sssd-dev](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/sssd-dev/32/5530_2.png) [@sssd-dev](https://forum.serverless.com/u/sssd-dev)\
**Post date:** [April 9, 2021, 2:29pm UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684/3 "2021-04-09T14:29:02Z")

</div>

What was the issue? I am asking as I am getting the same error.

---

<div class="post-metadata">

**Author:** ![carlosfer02](https://avatars.discourse-cdn.com/v4/letter/c/b77776/32.png) [@carlosfer02](https://forum.serverless.com/u/carlosfer02)\
**Post date:** [April 23, 2021, 9:59pm UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684/4 "2021-04-23T21:59:24Z")

</div>

I am having the same problem. What do you mean by “and modified localstack config”? i cant get to solve this problem and i need to deploy my functions

---

<div class="post-metadata">

**Author:** ![mjacobsson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mjacobsson/32/5780_2.png) [@mjacobsson](https://forum.serverless.com/u/mjacobsson)\
**Post date:** [May 28, 2021, 3:51pm UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684/5 "2021-05-28T15:51:35Z")

</div>

Same problem for me ☹ Anyone found the solution?

---

<div class="post-metadata">

**Author:** ![FernandoCostaB](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/fernandocostab/32/5868_2.png) [@FernandoCostaB](https://forum.serverless.com/u/FernandoCostaB)\
**Post date:** [June 17, 2021, 4:57pm UTC](https://forum.serverless.com/t/consistently-failing-localstack-serverless-spin-up/13684/6 "2021-06-17T16:57:20Z")

</div>

I’m had the same problem. I changed the name of service in serverless.yml. The name was “teste-serverless-local”. I changed it to “teste” and works for me. I think if you change the name to a short name maybe will work
