Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid CloudFormation Template on initial deploy #66

Open
oleschaper opened this issue Jul 7, 2017 · 27 comments
Open

Invalid CloudFormation Template on initial deploy #66

oleschaper opened this issue Jul 7, 2017 · 27 comments

Comments

@oleschaper
Copy link

oleschaper commented Jul 7, 2017

I just tried to deploy my project with the plugin enabled but it fails with this error message:

Serverless: Packaging service...
Serverless: Preparing alias ...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading CloudFormation alias file to S3...
Serverless: Validating template...

Error --------------------------------------------------

The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayDeployment1499436937655] in the Resources block of the template

 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Stack Trace --------------------------------------------

Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayDeployment1499436937655] in the Resources block of the template
at provider.request.catch (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:25:13)
From previous event:
at AwsDeploy.validateTemplate (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:12)
From previous event:
at Object.aws:deploy:deploy:validateTemplate [as hook] (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:102:10)
at BbPromise.reduce (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:233:55)
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:233:22)
at PluginManager.spawn (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:245:17)
at AwsDeploy.BbPromise.bind.then (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:88:48)
From previous event:
at Object.deploy:deploy [as hook] (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:84:10)
at BbPromise.reduce (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:233:55)
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:233:22)
at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:252:17)
at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:104:33)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
From previous event:
at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:91:74)
at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:23:50)
at

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless

Your Environment Information -----------------------------
OS: darwin
Node Version: 8.1.2
Serverless Version: 1.14.0

@oleschaper
Copy link
Author

I don't know which template I could take a look into, I guess it is generated?
If I disable the plugin it works again.

Thank you for your help!

@HyperBrain
Copy link
Member

HyperBrain commented Jul 8, 2017

Can you give me more information about your service configuration? The alias plugin moves the APIG deployment to a separate stack (the alias stack). Can you check if there is a reference to the APIG deployment in the cloudformation-template-update-stack.json (located in S3)?

This might be missing support for a specific feature of Serverless you use (e.g. API keys are not yet supported).

Maybe you can post your serverless.yml here, so that I can try to reproduce and fix the issue.

@HyperBrain
Copy link
Member

Additionally you can use the --verbose switch, which will enable more detailed output, also for the alias plugin.

@oleschaper
Copy link
Author

Hi,

your instincts are right, I am using api keys.
I removed them but now I get another error:

Serverless: Stack update finished...
Serverless: Updating alias stack...

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

[/Resources/UserGetLambdaPermissionApiGateway/DependsOn/0] 'null' values are not allowed in templates

Stack Trace --------------------------------------------

ServerlessError: [/Resources/UserGetLambdaPermissionApiGateway/DependsOn/0] 'null' values are not allowed in templates
at Response.req.send (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:163:20)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:360:18)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:678:14)
at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:680:12)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:678:14)
at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:680:12)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at callNextListener (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at Request.RESET_RETRY_STATE (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/event_listeners.js:426:9)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:101:18)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:678:14)
at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:680:12)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:678:14)
at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:680:12)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:678:14)
at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:680:12)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:678:14)
at Request.transition (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/request.js:680:12)
at Request.callListeners (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at callNextListener (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at IncomingMessage.onEnd (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/event_listeners.js:256:13)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickDomainCallback (internal/process/next_tick.js:198:9)
From previous event:
at persistentRequest (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:151:14)
at doCall (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:130:9)
at BbPromise (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:141:14)
From previous event:
at persistentRequest (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:128:38)
at AwsProvider.request (/usr/local/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:144:12)
at AwsAlias.updateAlias (/Users/oleschaper/dev/sviper/projects/superspellsaga/superspellsaga_backend/node_modules/serverless-aws-alias/lib/updateAliasStack.js:82:25)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless

Your Environment Information -----------------------------
OS: darwin
Node Version: 8.1.2
Serverless Version: 1.14.0

I checked the file cloudformation-template-update-alias-stack.json for the resource UserGetLambdaPermissionApiGateway and the DependsOn looks like this (also all the others look like this):

  "DependsOn": [
    null,
    null
  ]

If needed I could send you my serverless.yml per mail.

Thank you!

@HyperBrain
Copy link
Member

That looks indeed strange. The dependency array should never ever contain null values.
Could you do come tests using my example repo (https://github.com/HyperBrain/serverless-aws-alias-example)?. A plain checkout and deploy of one of the branches should work out of the box.

You could try to configure the API within there step by step to the configuration you're actually using. There must be one step where the issue happens.

If that does not help, I'll have a look at your service definition and try to reproduce it.

@oleschaper
Copy link
Author

oleschaper commented Jul 8, 2017

Thank you @HyperBrain

I stripped down my serverless.yml but I can not figure out what is wrong.

cloudformation-resources.json.txt
cloudformation-template-update-alias-stack.json.txt
serverless.yml.txt

@HyperBrain
Copy link
Member

@oleschaper Thank you for the files 👍 . I'll have a look and try to figure out, what exactly is missing in the plugin and if there's some edge case triggered here.

@HyperBrain
Copy link
Member

It seems the error is located here:

    "UserGetLambdaPermissionApiGateway": {
      "Type": "AWS::Lambda::Permission",
      "Properties": {
        "FunctionName": {},
        "Action": "lambda:InvokeFunction",
        "Principal": "apigateway.amazonaws.com",
        "SourceArn": {
          "Fn::Join": [
            "",
            [
              "arn:aws:execute-api:",
              {
                "Ref": "AWS::Region"
              },
              ":",
              {
                "Ref": "AWS::AccountId"
              },
              ":",
              {
                "Fn::ImportValue": "MyBackend-dev-ApiGatewayRestApi"
              },
              "/*/*"
            ]
          ]
        }
      },
      "DependsOn": [
        null,
        null
      ]
    }

The permissions object is not created correctly in your case. Additionally to the null dependencies, there is also an issue with the FunctionName property which is set to an empty object here.

Honestly, I did not try the plugin with Java based code, only JavaScript/Node code. Maybe the SLS compile plugin generates something differently for Java packages. I'll try to setup a system where I can reproduce it.

In the mean-time I'll add the help-wanted tag. Maybe someone using Java can comment on the issue.

@oleschaper
Copy link
Author

Thank you @HyperBrain

@HyperBrain
Copy link
Member

Sorry that we did not have any feedback here since now 😢 . I'm not sure how many people use Java and the plugin or tried it. Just let's keep it some more time open.

@killthrush
Copy link

I'm getting the same error on a set of python 3.6 lambdas. I'm also using Gateway w/ keys. I'll try digging into this a bit more and see what I can find.

@HyperBrain
Copy link
Member

Oh. it's the APIKeys. I did not add support for them yet 🤔 . Maybe I should push that and do an update release soon.

@killthrush
Copy link

That would be awesome - I'd be happy to test it out for you!

@HyperBrain
Copy link
Member

I'll come back to you as soon as there is anything to test 😄

@HyperBrain
Copy link
Member

@killthrush Can you provide me with a simple test project that uses API keys? I want to go for an implementation within the next days and it would be better to have something at hand that reflects reality.

@killthrush
Copy link

@HyperBrain - here you go: https://github.com/killthrush/serverless-sample

I was able to reproduce the reported error using this project. Thanks!

@HyperBrain
Copy link
Member

@killthrush Thank you. I'll have some time over the weekend to take care of it and if it works well, also provide an implementation.

@HyperBrain
Copy link
Member

API Key support is handled with #25 .

@sambhusai
Copy link

I am also getting the same issue with Java Runtime for Lambda function. I am using the ApiKeys. Removing ApiKeys, it works.

@HyperBrain
Copy link
Member

Sorry for the very late reply. I was quite overloaded with my work and maintaining the webpack plugin and Serverless. The alias plugin somehow fell off the table ....

I will take care of the remaining issues now, especially API keys, DynamoDB triggers and SNS manual arns.

@killthrush
Copy link

killthrush commented Jan 24, 2018 via email

@sambhusai
Copy link

Thanks @HyperBrain.

@eshanaka
Copy link

eshanaka commented Mar 26, 2018

This is what I have noticed, hopefully, it'll be useful to fix the issue.

I have noticed API-key creation and trying to associate with an HTTP endpoint can reproduce the issue. (API Key and usage plan creation and the association was working fine before enabling the aws-alias plugin)

How I define the apiKey and usage plan

apiKeys:
   - ${opt:stage}-apiKey
 usagePlan:
    throttle:
      burstLimit: 1
      rateLimit: 1

Associate with,

 - http:
            path: /functionName
            method: get
            private: true
            integration: lambda
Error  -------------
The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayDeployment1522032673460] in the Resources block of the template

@HyperBrain
Copy link
Member

@eshanaka API Keys are still a not implemented feature (see #25 ). It would be great if someone could add support.

@eshanaka
Copy link

Thanks for the quick response @HyperBrain, I would really like to contribute, let me get familiar with the implementation little bit more and see how it goes.

@alinefm
Copy link

alinefm commented Mar 4, 2019

Any update on this?

I am having the same problem with python3.6 Lambdas and API Gateway but without API Keys.

@MartinRisk
Copy link
Member

Same problem from .Net lambda's also wihout API Keys

Any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants