Capture "ServiceEndpoint" output as a parameter


#1

Related to, but not explicitly related to other discussions about using the Parameter store, as there’s no circular dependency, so I thought I’d ask:

Currently serverless dynamically creates an API Gateway for functions to reside behind and the resulting CloudFormation template actually returns the endpoint url back as “ServiceEndpoint”. What I’d like to do is store this in the SystemManager Parameter store so I can reference it with other deployments. In a “pure” cloudformation sense it’s exceedingly simple to create such a resource:

Resources:
  ServiceUrlParam:
    Type: "AWS::SSM::Parameter"
    Properties: 
      Name: /SeviceUrl
      Type: String
      Value: !Ref <someresource>

Now in the serverless.yml … isn’t necessarily defined, so while I can add said resource, I have no idea how to populate the endpoint. It’s clearly referenced by the time the cloudformation template is formed (hence the output), but is there an easy way to reference it here?


#2

Note to all that I was able to solve this, due to the fact that serverless uses a consistent name for it’s resources in cloud formation every time. So for those currious, the earlier mentioned example would look like this in the serverless.tml:

resources:
  Resources:
    ServiceUrlParam:
      Type: "AWS::SSM::Parameter"
      Properties: 
        Name: /SeviceUrl
        Type: String
        Value:
          Ref: ApiGatewayRestApi

And bam: now my new service generates a key/value I can reference in other projects easily.