[Solved] Referring to ApiGatewayApiKey1 in Serverless.yml no longer works

When creating an api key, I used to be able to refer to the key using ApiGatewayApiKey1 (see: https://serverless.com/framework/docs/providers/aws/guide/resources/). Now, I get this: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayApiKey1] in the Resources block of the template.

In my template I need to wait for the key to be created before creating the UsagePlan:

  Type: AWS::ApiGateway::UsagePlan
  DependsOn: ApiGatewayApiKey1
      RateLimit: 1000
      BurstLimit: 3000

I haven’'t changed my serverless.yml file. Has this feature changed? How do I refer to it now?

well, i figured it out.

  1. I was wrong. I did modify my serverless.yml file. I had commented out all the entries that created an api endpoint. I was experimenting with something else and forgot I had done that.

  2. Apparently, if you attempt to add an api key with no endpoints being created, the cloud formation template fails with the error I described in my original post. (I don’t know if this is a cloud formation issue or a serverless issue).

So, in summary, you can’t create an api key if you don’t also create endpoints. I guess that makes sense, since why do you need an api key if you don’t have endpoints. I guess all I can say, is, because I wanted to.

It would be nice if the error that was reported was a little more descriptive, since “Unresolved resource dependencies [ApiGatewayApiKey1] in the Resources block of the template” doesn’t really lead one to the conclusion that it is because you are not creating endpoints.

1 Like