I want to split my SAM application into multiple parts.
I want to create a API ( AWS::Serverless::Api ) in the root stack.
I am creating lambda functions in my child stacks, where I want to give the reference of the API from the root stack to the API Events.
Is this feasible? I didn't find any good examples for the accessing the API from the root stack into child stack?
I tried with the below template -
parenttemplateapi:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:account_id:applications/parent-template
SemanticVersion: 1.0.0
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python2.7
Events:
HelloWorld:
Type: Api
Properties:
Method: get
Path: /hello
RestApiId: !GetAtt parenttemplateapi.Outputs.ServerlessGW-restApiId
When I tried to deploy this template, I got below errors -
Error: Failed to create changeset for the stack: child-template, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Internal transform failure.
Any pointers/suggestions?
I was referring to below links -
Can the API Gateway Id ( AWS::ApiGateway::RestApi) from the root stack used here?
https://dev.to/grahamcox82/building-a-larger-serverless-application-part-3-modular-monorepos-3mon
Can this be achieved using serverless framework?