Home > Back-end >  Serverless lambda deploy stuck in UPDATE_ROLLBACK_COMPLETE
Serverless lambda deploy stuck in UPDATE_ROLLBACK_COMPLETE

Time:12-19

I'm trying to deploy this serverless application but it gets stuck in UPDATE_ROLLBACK_COMPLETE status. I've done some search but all answers says to check for failed nested stacks, which is not my case. Here's the print screen from my couldformation resources, as you can see both resources were successfully created: enter image description here

Here's my serverless.yml

app: mentoria-tech-server
service:
  name: mentoria-tech-server
  useDotenv: true
package:
  exclude:
    - node_modules/**
custom:
  jest:
    collectCoverage: true
  pg_user: ${env:MENTORIA_TECH_PG_USER}
  pg_host: ${env:MENTORIA_TECH_PG_HOST}
  pg_password: ${env:MENTORIA_TECH_PG_PASSWORD}
  pg_database: ${env:MENTORIA_TECH_PG_DATABASE}
  pg_port: ${env:MENTORIA_TECH_PG_PORT}
  pg_database_url: ${env:MENTORIA_TECH_DATABASE_URL}
provider:
  name: aws
  stage: ${opt:stage, 'development'}
  runtime: nodejs12.x
  memorySize: 512
  timeout: 10
  environment:
    MENTORIA_TECH_PG_USER: ${self:custom.pg_user}
    MENTORIA_TECH_PG_HOST: ${self:custom.pg_host}
    MENTORIA_TECH_PG_DATABASE: ${self:custom.pg_database}
    MENTORIA_TECH_PG_PASSWORD: ${self:custom.pg_password}
    MENTORIA_TECH_PG_PORT: ${self:custom.pg_port}
    MENTORIA_TECH_DATABASE_URL: ${self:custom.pg_database_url}
functions:
  - ${file(./functions/boards.yml)}
  - ${file(./functions/journey.yml)}
  - ${file(./functions/user.yml)}
  - ${file(./functions/subscription.yml)}
plugins:
  - serverless-plugin-typescript
  - serverless-offline

Does anyone have any ideia of why this is happening? Thank you in advance :)

Update: this is the output of serverless deploy

 An error occurred: ApiGatewayResourceApiV1BoardEmailVar - Resource handler returned message: "A sibling ({id}) of this resource already has a variable path part -- only one is allowed (Service: ApiGateway, Status Code: 400, Request ID: 56f13ceb-ddb6-4f28-821e-f39d516563f3, Extended Request ID: null)" (RequestToken: 27e9b5a5-ca84-4a43-dcde-d6fab549c1d4, HandlerErrorCode: InvalidRequest).

CodePudding user response:

Without seeing your function configuration, or understanding what you're trying to do - this is hard to debug.

However I can see this error commonly occurs if you're moving an API Gateway Path Variable, IE:

functions:
  hello:
    handler: handler.hello
     events:
         - http:
             path: /foo/{id}/bar

to

functions:
  hello:
    handler: handler.hello
     events:
         - http:
             path: /foo/bar/{id}

Unfortunately this is a limitation in CloudFormation, as it creates the new resource before removing the old one, which causes this issue source, and thus this is still an unsolved issue.

You'll need to create a new function and temporarily route requests to that function, then remove the old route, then add the new route, and finally route requests to the old function.

CodePudding user response:

Aaron's tip really helped! Turns out that I had these two functions:

getUser:
  handler: src/controllers/user.getOne
  events:
    - http:
        path: v1/user/{id}
        method: GET
updateUser:
  handler: src/controllers/user.update
  events:
    - http:
        path: v1/user/{email}
        method: PUT

In one of them I was using the id as parameter and in the other I was using the email. They should be both id or both email. You can only use different parameters for different paths! So it should look like this:

getUser:
  handler: src/controllers/user.getOne
  events:
    - http:
        path: v1/user/{email}
        method: GET
updateUser:
  handler: src/controllers/user.update
  events:
    - http:
        path: v1/user/{email}
        method: PUT

Thank you so much Aaron, it's working now!

  • Related