This is a service broker written in Go Language for Cloud Foundry. This service broker supports creating VMs on AWS or SoftLayer. Since VMs take some to spin up creating them is done asynchronously.
This broker also supports creating service keys. This is a new feature added to the Service Broker v2.6 APIs. In this broker we implement service keys by creating SSH keys and adding them to the VM.
Finally, this broker also supports arbitrary service parameters. For AWS this is done by allowing the user to pass the
ami-id to use when spinning up the VM. And for SoftLayer you can specify the Virtual Guest Device Block Device Template Group ID.
NOTE that for AWS, in this implementation, service bind operation will generate a keypair and inject the public key into that EC2 instance and return the corresponding credentials including private key, user name and public IP address information which can be used to ssh login that EC2 instance. The service unbind operation will revoke that public key from the EC2 instance.
This sample project has been presented in CF Summit 2015:
Videos for each of the main features of the brokers are in these Youtube videos:
The following blog post on IBM's OpenTech web site covers the broker in much details:
Get Latest Executable: go_service_broker
$ go get github.com/cloudfoundry-samples/go_service_broker
This will build and place the
go_service_broker executable built for your operating system in your
Building From Source
Clone this repo and build it. Using the following commands on a Linux or Mac OS X system:
$ mkdir -p go_service_broker/src/github.com/cloudfoundry-samples $ export GOPATH=$(pwd)/go_service_broker:$GOPATH $ cd go_service_broker/src/github.com/cloudfoundry-samples $ git clone https://github.com/cloudfoundry-samples/go_service_broker.git $ cd go_service_broker $ godep restore $ ./bin/build
NOTE: you may need to install godep on your system, if you have not already. You can with this one line command:
$ go get github.com/tools/godep
NOTE2: if you get any dependency errors, then use
go get path/to/dependency to get it, e.g.,
go get github.com/onsi/ginkgo and
go get github.com/onsi/gomega
The executable output should now be located in:
out/go_service_broker. Place it wherever you want, e.g.,
/usr/local/bin on Linux or Mac OS X.
$ go get github.com/tools/godep
Download and install packages with dependencies by using godep.
$ cd - $ godep get ./...
Save the dependencies by godep.
$ godep save ./...
Build your executable
Configuring for AWS
Before running the service broker, you need to configure your AWS accpunt's credentials. If you do not have AWS account, then you can get one for free here.
As a best practice, we recommend creating an IAM user that has access keys rather than relying on root access keys. You can login into your AWS account to create a new user 'service_broker' with the option to generate an access key for this user.
Once you get a Access Key ID and Secret Access Key, copy and save it into
~/.aws/credentials file, which might look like:
[default] aws_access_key_id = YOUR-AWS-ACCESS-KEY-ID aws_secret_access_key = YOUR-AWS-SECRET-ACCESS-KEY
Configuring for SoftLayer
For SoftLayer the configuration requires you to supply your SL user name and API key. If you do not have an SL account, please get one for free here. The API key can be requested once you login to your account.
You need to setup two environment variables with your SL credentials as follows.
$ export SL_USERNAMEfirstname.lastname@example.org $ export SL_API_KEY=YOUR-SOFTLAYER-API-KEY
These two environment variables must exist where you run your broker. Locally, in a VM or server process, or whithin CloudFoundry. See below on details on how to run broker in CF or locally.
The broker can be ran in one of two modes: locally or as an app in a CF environment.
Run the executable to start the service broker which will listening on port
8001 by default.
$ out/go_service_broker --cloud AWS
This will run the broker in
AWS mode. You can also specify
SoftLayer mode with:
$ out/go_service_broker --cloud SoftLayer
If no argument is passed to the
--cloud flag then AWS mode is assumed/
When running the broker in a CF environment (including BOSH lite). You simply need to:
$ git clone https://github.com/cloudfoundry-samples/go_service_broker.git $ cd go_service_broker $ cf push
You, of course, need to have the CF CLI installed into your system. Also, you can edit the
Procfile if you want to specify a different mode (AWS or SoftLayer) as well as any additional optional parameters to the CF Golang buildpacks.
This is under Apache 2.0 OSS license.
There is no documentation for this package.
Package ssh implements an SSH client and server.
|Package ssh implements an SSH client and server.|
Package agent implements a client to an ssh-agent daemon.
|Package agent implements a client to an ssh-agent daemon.|
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
|Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.|
This package contains integration tests for the code.google.com/p/go.crypto/ssh package.
|This package contains integration tests for the code.google.com/p/go.crypto/ssh package.|
Package aws provides core functionality for making requests to AWS services.
|Package aws provides core functionality for making requests to AWS services.|
Package awserr represents API error interface accessors for the SDK.
|Package awserr represents API error interface accessors for the SDK.|
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
|Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.|
Package stscreds are credential Providers to retrieve STS AWS credentials.
|Package stscreds are credential Providers to retrieve STS AWS credentials.|
Package ec2 provides a client for Amazon Elastic Compute Cloud.
|Package ec2 provides a client for Amazon Elastic Compute Cloud.|
Package ec2iface provides an interface for the Amazon Elastic Compute Cloud.
|Package ec2iface provides an interface for the Amazon Elastic Compute Cloud.|
Package context stores values shared during a request lifetime.
|Package context stores values shared during a request lifetime.|
Package gorilla/mux implements a request router and dispatcher.
|Package gorilla/mux implements a request router and dispatcher.|
Package ini provides functions for parsing INI configuration files.
|Package ini provides functions for parsing INI configuration files.|