You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the first SAM template, I want to create an API Gateway and a lambda function which uses this API gateway.
Here is the snippet -
First SAM template -
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
Name: Rainmaker AWS Api Gateway
StageName: !Ref StageName
Cors: "'*'"
Outputs:
RainmakerApiRestApiId:
Description: 'API Gateway ARN for my AWS API Gateway'
Value:
Ref: MyApi
Export:
Name: !Sub "${AWS::StackName}-MyApi"
MyApiRootResourceId:
Value: !GetAtt MyApi.RootResourceId
Export:
Name: MyApi-RootResourceId
I am trying to export this API gateway resource, from the first template.
I want to use this API gateway resource in another SAM template, using import statement.
Here is the snippet in the second SAM template.
Parameters:
StageName:
Type: String
Default: dev
MyBaseStackName:
Description: Name of the base stack with all infra resources
Type: String
Default: first-stack
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: MyFunctionName
CodeUri: ../../../bin/handlers/
Handler: myfunctionname
Events:
MyHTTPEvent:
Type: Api
Properties:
RestApiId:
Fn::ImportValue:
!Sub "${MyBaseStackName}-MyApi"
Path: /authorize
Method: get
Auth:
Authorizer: NONE
When I deploy the second SAM template, I am getting below error -
Error: Failed to create changeset for the stack: esp-git-user, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Internal transform failure.
Is there any good example which explains exporting API gateway resource from the first SAM template and then using it in the second SAM template.