But my question is, how do i get current api gateway rest-api id dynamically? Because my lambda function will work on the api gateway log group, which has the name format as:
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type. This section lists the available attribute and a sample return value.
RootResourceId
The root resource ID for a RestApi resource, such as a0bc123d4e.
For anyone else who finds this, note there’s some confusion here about API gateway resources.
The RestApiId is the id of the API resource itself, which is returned by a Ref of the implied ApiGatewayRestApi resource that Serverless creates under the hood.
The RootResourceId is the id of the REST resource (not to be confused with a CloudFormation resource!) at the root of the API’s path (i.e. “/”). If you are hanging methods or subresources off of root, you’ll need to provide this as the parent resource id. It is available as an attribute of the API resource.
So, for example to define a resource at the path “/mythings”, which needs both the api id and the root resource id, your CF template would look like
which worked okay up to now and out-of-the-blue I’ve started to get:
Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayRestApi] in the Resources block of the template
In the end I was able to pin point the source of the issue to upgrade of serverless-plugin-split-stacks from 1.9.3 to 1.10.0 version. Downgrading fixed the problem.
Nice, thanks for sharing the information, it really helps student like.
but beginner like me it is little hard to understand fast, can anyone suggest a good AWS classes in Pune.
This approach is if you need value in Serverless config/setup.
In other cases { “Ref” : “ApiGatewayRestApi” } will be a references, not a string and that will be a problem. With this approach you can construct string how you want and apply