I am trying to deploy a shared api gateway for multiple services, and I have deployed the api gateway, I have checked on aws cloudformation, it does exist, however when I try to deploy other services who are going to use the api gateway, it always shows Can not find API Gateway resource from path xxx
.
I tried to find the reason and disconnect the network, then run sls deploy --force
, it also shows the same error.
The serverless framework version is 1.57.0
the shared api gateway is defined as:
service: sso-server-api-gateway
frameworkVersion: ">=1.2.0 <2.0.0"
provider:
name: aws
runtime: python3.7
profile: self
region: ap-southeast-1
stage: dev
deploymentBucket: serverless-bucket-s3
resources:
Resources:
# root
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: sso-server-api
EndpointConfiguration:
Types:
- REGIONAL
# /sso
ApiGatewaySSO:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId:
Ref: ApiGatewayRestApi
ParentId:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
PathPart: "sso"
# /sso/register
ApiGatewaySSORegister:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId:
Ref: ApiGatewayRestApi
ParentId:
Ref: ApiGatewaySSO
PathPart: "register"
Outputs:
ApiGatewayRestApiId:
Value:
Ref: ApiGatewayRestApi
Export:
Name: ApiGatewayRestApiId
ApiGatewayRootResourceId:
Value:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
Export:
Name: ApiGatewayRootResourceId
ApiGatewaySSOId:
Value:
Ref: ApiGatewaySSO
Export:
Name: ApiGatewaySSOId
ApiGatewaySSORegisterId:
Value:
Ref: ApiGatewaySSORegister
Export:
Name: ApiGatewaySSORegisterId
and the other service is defined as:
service: sso-server-entry
frameworkVersion: ">=1.2.0 <2.0.0"
provider:
name: aws
runtime: python3.7
profile: self
region: ap-southeast-1
stage: dev
deploymentBucket: serverless-bucket-s3
apiGateway:
restApiId:
Fn::ImportValue: ApiGatewayRestApiId
restApiRootResourceId:
Fn::ImportValue: ApiGatewayRootResourceId
restApiResources:
/sso:
Fn::ImportValue: ApiGatewaySSOId
/sso/register:
Fn::ImportValue: ApiGatewaySSORegisterId
functions:
hello:
handler: handler.entry
name: entry
events:
- http:
method: post
path: /sso/register
cors: false