serverless-domain-manager: Error: Failed to find CloudFormation resources for

Community Note

  • Please vote on this issue by adding a šŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave ā€œ+1ā€ or ā€œme tooā€ comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Bug Report

Error Description I ran into the resource limit 200 problem with serverless. For that I used the serverless-nested-stack and it worked. I now want to use the serverless-domain-manage to have a sub domain for my services.

Command Run I ran sls create_domain and then sls deploy

Console Output `Error --------------------------------------------------

Error: Failed to find CloudFormation resources for <mydomain>`

Domain Manager Configuration Replace this with your own serverless.yml file (anonymized, of course) to help us better resolve your issue.

custom:
  customDomain:
    domainName: ${self:provider.api_endpoint}
    certificateName: ${self:provider.certificate}
    basePath: ''
    stage: ${self:provider.stage}
    createRoute53Record: true

Versions

  • Domain Manager version(s): ^3.1.0
  • Node runtime: nodejs8.10
  • Serverless Version: v1.38.0
  • Lambda Code Javascript

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 102
  • Comments: 56 (2 by maintainers)

Most upvoted comments

Got the same issue today, have three microservices, on two of them the configuration works as it should. But the third also throws ā€˜Failed to find CloudFormation resources forā€™. They were deloyed on a fresh account, where the domain manager was not used before.

  • Domain Manager: 3.1.0
  • SLS: 1.36.3

EDIT

Problem was with the user, not the pluginā€¦ Did not add a http event to my lambda function, so no API Gateway was created.

Before:

functions:
#  app:
#    handler: myHandler
#    events:
#     - http:
#          method: ANY
#          path: '{proxy+}'
#          cors: true

After:

functions:
  app:
    handler: myHandler
    events:
     - http:
          method: ANY
          path: '{proxy+}'
          cors: true

I ran into this same issue, but was able to fix it by changing the httpApi event key in my serverless.yaml to http. Is this perhaps a documentation issue or undocumented breaking change?

Before (same error mentioned here; calling the Lambda directly works, but calling through the custom domain returns ā€œforbiddenā€):

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
          path: /hello
          method: get

After (no error, successful deployment):

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: /hello
          method: get

Encase anyone else runs into this I had to specify the AWS_REGION environment variable. Previously I never had to provide this for a successful deployment. e.g. AWS_REGION=us-east-1

@allanitis I havenā€™t made the PR to the project (lots of works - just published it to my own private registry) but not sure if is getting enough attention at the moment. I see lots of PRs open without any comment. Iā€™ll submit the PR tomorrow so you can take a look to it (also Iā€™ll upload a fork on my acc)

The combination of versions has nothing to do with serverless-plugin-split-stacks problem. @captainsidd already said what is the problem in code. I have the code working on my local env, will make a PR later today

The correct explanation to this problem is that serverless-plugin-split-stacks does not create a cloudformation resource called ApiGatewayRestApi in the stack. Instead it creates APINestedStack (which is a stack). In order to apply the mappings, domain-manager needs to get StackName of APINestedStack and do another DescribeStackResource to that stackName with ApiGatewayRestApi resource and get the PhysicalResourceId of it to apply the mappings

šŸ‘ This was also broken for me. Downgrading to 2.3.5 worked.

@angel-carvajal Thanks for your fix! I am installing all plugins the regular way and your plugin afterward as follows (I am using regular API Gateway):

npm install --save-dev @types/node@12 npm install --save-dev "angel-carvajal/serverless-domain-manager#v1.0.0"

Just to possibly help someone out here, we actually encountered this error in the logs of our CI, but it turns out it was a simple configuration error in a new service on our part.

if you turn on env SLS_DEBUG=* you may also see more info like this one:

ValidationError: 1 validation error detected: Value 'auth-[object Object]' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*

In our case 'auth-[object Object]' was supposed to be 'auth-dev' and this was actually caused by stage: {self:provider.stage} needing to be stage: ${self:provider.stage} (missing $ for the var)

Error: Unable to fetch information about [domain] was actually coming from the stack failing to create because the name failed to resolve correctly.

I ran into this same issue, but was able to fix it by changing the httpApi event key in my serverless.yaml to http. Is this perhaps a documentation issue or undocumented breaking change? Before (same error mentioned here; calling the Lambda directly works, but calling through the custom domain returns ā€œforbiddenā€):

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
          path: /hello
          method: get

After (no error, successful deployment):

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: /hello
          method: get

Found the same issue today. Thanks for the comment!

Ran into this but just had to specify the API TYPE to be able to use httpApi instead. The default is rest which is the - http V1

  customDomain:
    apiType: http

API Gateway v2 HTTP API API Gateway v1 REST API

Any news?

Hello everyone,

I have the same issue. Iā€™m trying te deploy a single lambda with a sqs event. This is where it doesnā€™t work. When I switch it to a http event. It worksā€¦

service: service-name

provider:
  name: aws
  runtime: nodejs12.x
  stage: prod
  region: eu-central-1

  iamRoleStatements:
    - Effect: 'Allow'
      Action:
        - 'lambda:InvokeFunction'
      Resource: "*"
    - Effect: 'Allow'
      Action:
        - 'sqs:ReceiveMessage'
        - 'sqs:DeleteMessage'
        - 'sqs:GetQueueAttributes'
      Resource: "arn:aws:sqs:eu-central-1:xxxxxxxxxxxxxx:sqsurl"

custom:
  customDomain:
    domainName: 'api.mywebsite.com'
    basePath: sqs
    certificateName: "api.mywebsite.com"
    createRoute53Record: true
    endpointType: 'regional'
    stage: prod

functions:
  create:
    handler: functions/create.handler
    timeout: 30 # seconds
    reservedConcurrency: 1
    events:
      - sqs:
          arn: arn:aws:sqs:eu-central-1:xxxxxxxxxxxxxx:sqsurl
          batchSize: 1
          enabled: true

plugins:
  - serverless-offline
  - serverless-domain-manager

Always the same error : Error: Error: Failed to find CloudFormation resources for api.mywebsite.com

When I SLS_DEBUG it, I have this: ValidationError: Resource ApiGatewayRestApi does not exist for stack service-name-prod

Have you got any ideas ?

If Iā€™m not misunderstanding something or you are omitting something from the quoted configurationā€¦ then:

Your SQS lambda does not create any aws gateway resources which could be connected with the domain api.mywebsite.com. I think the way itā€™s supposed to go is that you need to create a http (or websocket or something) endpoint which is connected to API gateway and this endpoint would then talk to the SQS, in order for it to have API GW resources which would get assigned a domain name.

I had a bit of a similar issue when developing one of my split-stack services. (All use the same serverless.yml, with just different functions-section). Other services create restful http apis, but one particular stack only creates scheduled lambdas for bookkeeping, i.e. These lambdas (like your SQS handler) donā€™t create anything that would be exposed via API gateway.

functions:
  scanUpcomingEvents:
    handler: eventScanner.scanUpcomingEvents
    events:
      - schedule: rate(2 hours)
      - schedule: cron(0 12 * * ? *)

When I started writing these I didnā€™t add a http endpoint, and got the exact same error, which went away after adding the http endpoint which would actually be exposed with the DNS name.

The latest master just broke my solution cuz we support now HttpApi and WebsocketsApi (I was only checking for ApiGatewayRestApi nested stack). Is someone working with any of those 2 with split stack? If you guys want me to fix that ASAP Iā€™ll need some cloudFormation info of those type of API. If not, Iā€™ll take some time so I implement those 2 and see how the cloudFormation info looks like (maybe weekend). I need to know what resource is created when having those type of APIs. On ApiGatewayRestApi it looks this. image

In summary: I need the equivalent of APINestedStack on those type of APIs and what resources that equivalent have (It should have HttpApi and WebsocketsApi)

@stefanhorning this is the comment Iā€™m talking about. Provide that info and Iā€™ll fix your scenario

I just merged the solution I had working before into my clone https://github.com/angel-carvajal/serverless-domain-manager in case someone needs it now

NOTES:

  • My master is not up to date (Iā€™m 29 commits behind), verify if the version I have in master is still suitable for you.
  • This solution only works with ApiGatewayRestApi (TODO: HttpApi and WebsocketsApi solution)
  • This solution was tested with perFunction split stack (TODO: Manual test on perType and perGroupFunction)

add the dependency on your package-lock pointing to my clone and that should be it (I added a postinstall script that npm run build so you have the dist folder of it - I created a tag v1.0.0 in case you want to pull a tag instead of master)

Latest serverless@1.67.0 and serverless-domain-manager@3.3.1 seems to be solving the problem.

serverless@1.61.1 serverless-domain-manager@2.3.5 serverless-plugin-split-stacks@1.9.3

This combination worked for us.

Getting this on sls deploy for the recent serverless versions ā†’ i.e. for version 1.61.2 and above. Error doesnā€™t appear if I downgrade the framework to 1.61.1. Plugin version: serverless-domain-manager@3.3.0

@diegomarzo , this workaround worked for me, thanks!

Went into cloudformation, deleted the stacks manually, redeployed and it worked. I think my coworker initially deployed it missing a file, then redeployed and it failed.

Note Iā€™m using https://github.com/dougmoscrop/serverless-plugin-split-stacks

@vcelisBP please update the plugin to version 5.0.0.

Hello everyone,

I have the same issue. Iā€™m trying te deploy a single lambda with a sqs event. This is where it doesnā€™t work. When I switch it to a http event. It worksā€¦

service: service-name

provider:
  name: aws
  runtime: nodejs12.x
  stage: prod
  region: eu-central-1

  iamRoleStatements:
    - Effect: 'Allow'
      Action:
        - 'lambda:InvokeFunction'
      Resource: "*"
    - Effect: 'Allow'
      Action:
        - 'sqs:ReceiveMessage'
        - 'sqs:DeleteMessage'
        - 'sqs:GetQueueAttributes'
      Resource: "arn:aws:sqs:eu-central-1:xxxxxxxxxxxxxx:sqsurl"

custom:
  customDomain:
    domainName: 'api.mywebsite.com'
    basePath: sqs
    certificateName: "api.mywebsite.com"
    createRoute53Record: true
    endpointType: 'regional'
    stage: prod

functions:
  create:
    handler: functions/create.handler
    timeout: 30 # seconds
    reservedConcurrency: 1
    events:
      - sqs:
          arn: arn:aws:sqs:eu-central-1:xxxxxxxxxxxxxx:sqsurl
          batchSize: 1
          enabled: true

plugins:
  - serverless-offline
  - serverless-domain-manager

Always the same error : Error: Error: Failed to find CloudFormation resources for api.mywebsite.com

When I SLS_DEBUG it, I have this: ValidationError: Resource ApiGatewayRestApi does not exist for stack service-name-prod

Have you got any ideas ?

Actually that was a permissions issue with my IAM user, afer allowing all apigateway actions (without IAM conditions) I now get a different error

Error: Error: Unable to setup base domain mappings for <domain>. Which is proably a different bug/issue.

Sill running into this with serverless: 1.72.0 and serverless-domain-manager: 3.3.2. However I am using the http-api product of API GW (httpApi in serverles.yml).

Using ā€œangel-carvajal/serverless-domain-manager#v1.0.0ā€, or upgrading to 4.1.1 didnā€™t seem to help for me.

(I am not using serverless-plugin-split-stack)

Can confirm this worked for me. Muchas muchas gracias!

In package.json, change to "serverless-domain-manager": "angel-carvajal/serverless-domain-manager#v1.0.0"

Am using serverless@1.71.0 and serverless-plugin-split-stacks@1.9.3

I am having the same issue after updating. Exporting AWS_REGION did not fix the problem for me.

Downgrade not work for me, iā€™m using serverless-plugin-split-stacks. Any update for this issue?

Any development on this? Having the same issue with the latest version also getting the same error with older version 3.1.x