Cross Stack reference to api gateway?

I’ve created an api gateway:

  Resources: 
    ApiGateway:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: ${self:service}_${self:provider.stage}
      Description: ${self:custom.defaults.description}
  Outputs:
    ApiGatewayRestApi:
    Description: 'Api Gateway Rest Api'
    Value:
      Ref: ApiGateway
    Export:
       Name: 'ApiGateway:${self:provider.stage}:RestApiID'

And then try to import it in a microservice i.e:

provider: 
  apiGateway:
     restApiId: 
         Ref: ${cf:stackname-${self:provider.stage}.ApiGatewayRestApi}

I got the error:

 The CloudFormation template is invalid: Template format error: 
 Unresolved resource dependencies [actual_api_gateway_rest_id] 
 in the Resources block of the template

Any ideas what I’m doing wrong?

1 Like