Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to configure serverless resource output to get api gateway api id

I have a serverless project that is creating an API Gateway API amongst other things. One of the functions in the project needs to generate a URL for an API endpoint.

My plan is to get the API ID using a resource output in serverless.yml then create the URL and pass it through to the lambda function as an env parameter.

My problem/question is how to get the API ID as a cloud formation output in serverless.yml?

I've tried:

resources:
  Outputs:
    RESTApiId:
      Description: The id of the API created in the API gateway
      Value:
        Ref: name-of-api

but this give the error:

The CloudFormation template is invalid: Unresolved resource dependencies [name-of-api] in the Outputs block of the template
like image 563
Peter Whitfield Avatar asked Jul 05 '17 23:07

Peter Whitfield


People also ask

Does serverless framework create API gateway?

By default, Serverless creates automatically an API Gateway for each Serverless stack or service (i.e. serverless. yml ) you deploy.

Can we call API gateway from Lambda?

The method can be applied to calling an API with a Lambda REQUEST authorizer, if you specify the required path, header, or query string parameters explicitly. Open Postman, choose the GET method, and paste the API's Invoke URL into the adjacent URL field.

Is AWS API gateway serverless?

API Gateway supports containerized and serverless workloads, as well as web applications.


1 Answers

The serverless framework has a documentation page on how they generate names for resources.

See. AWS CloudFormation Resource Reference

So the generated RestAPI resource is called ApiGatewayRestApi.

like image 71
jens walter Avatar answered Sep 18 '22 20:09

jens walter