serverless-localstack icon indicating copy to clipboard operation
serverless-localstack copied to clipboard

`serverless deploy` returns error "Unable to update stack ...", but appears to deploy successfully

Open ajthomp2 opened this issue 4 years ago • 0 comments

Hello,

I was setting up a dummy project to start transitioning existing lambda functions to using serverless for deployment and localstack for local testing, and I came across a bug that I've been unable to fix.

When running serverless deploy, I get the output:

  Serverless Error ---------------------------------------
 
  Unable to update stack "test-serverless-local": Resource deployment loop completed, pending resource changes: [{'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HttpApiStage', 'PhysicalResourceId': None, 'ResourceType': 'AWS::ApiGatewayV2::Stage', 'Replacement': 'False', 'ChangeSetId': None}}, {'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HelloLambdaPermissionHttpApi', 'PhysicalResourceId': None, 'ResourceType': 'AWS::Lambda::Permission', 'Replacement': 'False', 'ChangeSetId': None}}, {'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HttpApiIntegrationHello', 'PhysicalResourceId': None, 'ResourceType': 'AWS::ApiGatewayV2::Integration', 'Replacement': 'False', 'ChangeSetId': None}}, {'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HttpApiRouteGetPing', 'PhysicalResourceId': None, 'ResourceType': 'AWS::ApiGatewayV2::Route', 'Replacement': 'False', 'ChangeSetId': None}}]

However, when testing to see if the function was deployed properly, serverless invoke --function hello responds successfully:

{
    "body": "{\"message\":\"Hello, the current time is Mon Feb 22 23:06:10 UTC 2021\"}",
    "headers": {
        "Content-Type": "application/json",
        "X-Powered-By": "AWS Lambda & Serverless"
    },
    "isBase64Encoded": false,
    "statusCode": 200
}

as does aws lambda invoke --endpoint-url http://localhost:4566 --function-name test-serverless-local-hello response.json:

{
  "body": "{\"message\":\"Hello, the current time is Mon Feb 22 23:08:07 UTC 2021\"}",
  "headers": {
    "Content-Type": "application/json",
    "X-Powered-By": "AWS Lambda & Serverless"
  },
  "isBase64Encoded": false,
  "statusCode": 200
}

which seems to indicate that the function was actually deployed successfully.

I am using this java project: https://github.com/serverless/examples/tree/master/aws-java-simple-http-endpoint.

serverless.yml

service: test-serverless

frameworkVersion: '2'

plugins:
    - serverless-localstack

custom:
    defaultStage: local
    localstack:
        stages:
            - local
        autostart: true
        lambda:
            mountCode: false
        docker:
            sudo: false
        debug: true

provider:
    name: aws
    runtime: java11
    lambdaHashingVersion: 20201221
    stage: local
    region: us-east-1
    apiName: hello-gateway
    memorySize: 1024
    deploymentPrefix: serverless
    versionFunctions: true

package:
    individually: true

functions:
    hello:
        package:
            artifact: test-serverless/build/distributions/test-serverless.zip
        handler: com.serverless.Handler
        events:
            - httpApi:
                  path: /ping
                  method: get

full output when running serverless deploy:

Serverless: config.options_stage: undefined
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: local
Serverless: config.stage: local
Serverless: Using serverless-localstack
Serverless: Reconfiguring service apigateway to use http://localhost:4566
Serverless: Reconfiguring service cloudformation to use http://localhost:4566
Serverless: Reconfiguring service cloudwatch to use http://localhost:4566
Serverless: Reconfiguring service lambda to use http://localhost:4566
Serverless: Reconfiguring service dynamodb to use http://localhost:4566
Serverless: Reconfiguring service kinesis to use http://localhost:4566
Serverless: Reconfiguring service route53 to use http://localhost:4566
Serverless: Reconfiguring service firehose to use http://localhost:4566
Serverless: Reconfiguring service stepfunctions to use http://localhost:4566
Serverless: Reconfiguring service es to use http://localhost:4566
Serverless: Reconfiguring service s3 to use http://localhost:4566
Serverless: Reconfiguring service ses to use http://localhost:4566
Serverless: Reconfiguring service sns to use http://localhost:4566
Serverless: Reconfiguring service sqs to use http://localhost:4566
Serverless: Reconfiguring service sts to use http://localhost:4566
Serverless: Reconfiguring service iam to use http://localhost:4566
Serverless: Reconfiguring service ssm to use http://localhost:4566
Serverless: Reconfiguring service rds to use http://localhost:4566
Serverless: Reconfiguring service ec2 to use http://localhost:4566
Serverless: Reconfiguring service elasticache to use http://localhost:4566
Serverless: Reconfiguring service kms to use http://localhost:4566
Serverless: Reconfiguring service secretsmanager to use http://localhost:4566
Serverless: Reconfiguring service logs to use http://localhost:4566
Serverless: Reconfiguring service cloudwatchlogs to use http://localhost:4566
Serverless: Reconfiguring service iot to use http://localhost:4566
Serverless: Reconfiguring service cognito-idp to use http://localhost:4566
Serverless: Reconfiguring service cognito-identity to use http://localhost:4566
Serverless: Reconfiguring service ecs to use http://localhost:4566
Serverless: Reconfiguring service eks to use http://localhost:4566
Serverless: Reconfiguring service xray to use http://localhost:4566
Serverless: Reconfiguring service appsync to use http://localhost:4566
Serverless: Reconfiguring service cloudfront to use http://localhost:4566
Serverless: Reconfiguring service athena to use http://localhost:4566
Serverless: Warning: Unable to find plugin named: TypeScriptPlugin
Serverless: config.options_stage: undefined
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: local
Serverless: config.stage: local
Serverless: config.options_stage: undefined
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: local
Serverless: config.stage: local
Serverless: Starting LocalStack in Docker. This can take a while.
Serverless: Checking state of LocalStack container e7760e98e737
Serverless: Checking state of LocalStack container e7760e98e737
Serverless: Checking state of LocalStack container e7760e98e737
Serverless: Checking state of LocalStack container e7760e98e737
Serverless: Checking state of LocalStack container e7760e98e737
Serverless: Packaging service...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
..
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service test-serverless.zip file to S3 (21.45 MB)...
Serverless: Validating template...
Serverless: Skipping template validation: Unsupported in Localstack
Serverless: Updating Stack...
 
  Serverless Error ---------------------------------------
 
  Unable to update stack "test-serverless-local": Resource deployment loop completed, pending resource changes: [{'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HttpApiStage', 'PhysicalResourceId': None, 'ResourceType': 'AWS::ApiGatewayV2::Stage', 'Replacement': 'False', 'ChangeSetId': None}}, {'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HelloLambdaPermissionHttpApi', 'PhysicalResourceId': None, 'ResourceType': 'AWS::Lambda::Permission', 'Replacement': 'False', 'ChangeSetId': None}}, {'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HttpApiIntegrationHello', 'PhysicalResourceId': None, 'ResourceType': 'AWS::ApiGatewayV2::Integration', 'Replacement': 'False', 'ChangeSetId': None}}, {'Type': 'Resource', 'ResourceChange': {'Action': 'Add', 'LogicalResourceId': 'HttpApiRouteGetPing', 'PhysicalResourceId': None, 'ResourceType': 'AWS::ApiGatewayV2::Route', 'Replacement': 'False', 'ChangeSetId': None}}]
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.4.0
     Framework Version:         2.25.2 (standalone)
     Plugin Version:            4.4.3
     SDK Version:               2.3.2
     Components Version:        3.7.0

ajthomp2 avatar Feb 22 '21 23:02 ajthomp2