awslabs / aws-servicebroker

AWS Service Broker
Apache License 2.0
468 stars 131 forks source link

Support osb costs convention #223

Closed tealeg closed 3 years ago

tealeg commented 3 years ago

Overview

Add support for service plan costs defined in the OSB convention by including in the CloudFormation template a "Costs" (note the "s") key alongside the existing "Cost" key in the ServicePlan definition, and by modifying the Db.ServiceDefinitionToOsb method to take account of this new key.

I've deliberately left he old "Cost" key because, I assume this was designed to avoid having to update the template every time the costs change upstream. In this case, we'd like to present costs to our internal customers via Stratos, and we'll need to use the OSB convention instead.

Related Issues

Fixes #222

Testing

I slightly refactored the Db.ServiceDefinitionToOsb method, pulling out a new, private, Db.servicePlanToOSBPlan which I was able to directly test via a unit test. I also added a test to a new types_test.go file, which demonstrates that the Costs structure can be populated from YAML. Additionally, we're deploying this version into our own CF environment.

Testing Instructions

In a cloud formation template you can add, a Costs definition like:

    ServicePlans:
      production:
        DisplayName: Production
        Description: Configuration designed for production deployments
        LongDescription: Creates an Amazon RDS Microsoft SQL Server Enterprise, Standard, Web and Express optimised for
          production use
        Cost: https://aws.amazon.com/rds/sqlserver/pricing/
        Costs:
          - Amount:
                EUR: 20.01
                USD: 22.50
             Unit: Monthly
          - Amount:
               EUR: 200.99
               USD: 220
            Unit: Yearly

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

tealeg commented 3 years ago

A pleasure @jaymccon