Deploying BOSH on AWS

Page last updated:

This topic describes how to use the bosh-bootloader command-line tool to set up an environment for Cloud Foundry on Amazon Web Services (AWS) and deploy a BOSH Director.

After performing the procedures in this topic, continue to the Customizing the Cloud Foundry Deployment Manifest for AWS topic.

For information about deploying BOSH on AWS without bosh-bootloader, see the Initializing BOSH environment on AWS topic.

Overview

After completing this topic, you will have the following:

  1. A BOSH Director instance in the Availability Zone (AZ) of your choice
  2. A set of randomly generated BOSH Director credentials
  3. A generated key pair that allows you to SSH into the BOSH Director and any instances that BOSH deploys
  4. A copy of the manifest you use to deploy the BOSH Director. A manifest is a YAML file that defines the components and properties of a BOSH deployment.
  5. A basic cloud config. A cloud config is a YAML file that defines IaaS-specific configuration for BOSH.
  6. A set of Elastic Load Balancers (ELBs). bosh-bootloader creates the ELBs, but you must still configure DNS to point your domains to the ELBs. See the Setting Up DNS for Your Environment topic for more information.

Step 1: Prepare a Domain

Perform the following steps to prepare a domain for Cloud Foundry:

  1. Select a DNS domain name for your Cloud Foundry instance. Cloud Foundry uses this domain name when deploying apps. For example, if you select the name cloud.example.com, Cloud Foundry deploys each of your apps as APP-NAME.cloud.example.com.

  2. From the AWS Route 53 dashboard, click Hosted zones.

  3. Click Create Hosted Zone.

  4. Under Domain Name, enter the domain name you selected above, for AWS to host.

  5. Under Type, choose Public Hosted Zone. This creates four name server (NS) records for your hosted zone.

  6. From your domain registrar, delegate DNS authority for your hosted zone to your four Amazon Route 53 name servers. To do this, replace your registrar’s NS records for the domain with the NS record values you created in the last step.

    Note: You can also find your NS record values by selecting your domain under the Hosted zones tab.

    Hostedzone

Step 2: Download Dependencies

Perform the following steps to download the required dependencies for bosh-bootloader:

  1. Download Terraform v0.9.1 or later. Unzip the file and move it to somewhere in your PATH:

    $ tar xvf ~/Downloads/terraform*
    $ sudo mv ~/Downloads/terraform /usr/local/bin/terraform
    

  2. Download the BOSH CLI v2. Make the binary executable and move it to somewhere in your PATH:

    $ chmod +x ~/Downloads/bosh-cli-*
    $ sudo mv ~/Downloads/bosh-cli-* /usr/local/bin/bosh
    

  3. Download the latest bosh-bootloader from GitHub. Make the binary executable and move it to somewhere in your PATH:

    $ chmod +x ~/Downloads/bbl-*
    $ sudo mv ~/Downloads/bbl-* /usr/local/bin/bbl
    

  4. Install the AWS CLI.

Step 3: Create an IAM User

Perform the following steps to create the Identity and Access Management (IAM) user that bosh-bootloader needs to interact with AWS:

  1. Copy the following policy text to your clipboard:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ec2:*",
                    "cloudformation:*",
                    "elasticloadbalancing:*",
                    "iam:*"
                ],
                "Resource": [
                    "*"
                ]
            }
        ]
    }
    
  2. Create the IAM user for bosh-bootloader with the AWS CLI:

    $ aws iam create-user --user-name "bbl-user"

  3. Apply the policy:

    $ aws iam put-user-policy --user-name "bbl-user" \
    --policy-name "bbl-policy" \
    --policy-document "$(pbpaste)"

  4. Create an access key:

    $ aws iam create-access-key --user-name "bbl-user"
    This command outputs an Access Key ID and a Secret Access Key. Record these values and store them in a secure place. You use these in the next section.

Step 4: Create the Infrastructure and the BOSH Director

Run the following command to create the required infrastructure and deploy a BOSH Director:

bbl up --aws-access-key-id YOUR-ACCESS-KEY-ID --aws-secret-access-key YOUR-SECRET-ACCESS-KEY --aws-region YOUR-AWS-REGION --iaas aws

where:

  • YOUR-ACCESS-KEY-ID and YOUR-SECRET-ACCESS-KEY are the values you recorded from the AWS CLI commands in the previous section.
  • YOUR-AWS-REGION is your AWS region, such as us-west-1.

The bbl up command takes five to eight minutes to complete. When the process finishes, it outputs a state file, bbl-state.json, in the present working directory.

Note: The bbl-state.json file contains credentials and other metadata related to your BOSH Director and infrastructure. Back up this file and store it in a safe location, and never modify it manually.

To extract information from the bbl-state.json state file, use bosh-bootloader instead of opening the file. For example, to obtain your BOSH Director address, run the following command:

$ bbl director-address
https://YOUR-DIRECTOR-ADDRESS

Run bbl to see the full list of values from the state file that you can print. You must always run bbl from the directory that contains bbl-state.json.

Step 5: Connect to the BOSH Director

Perform the following steps to connect to the BOSH Director:

  1. Save the Certificate Authority (CA) certificate to a file and set the path as an environment variable:

    $ bbl director-ca-cert > bosh.crt
    $ export BOSH_CA_CERT=bosh.crt
    

  2. Set your BOSH Director address as an environment variable:

    $ export BOSH_ENVIRONMENT=$(bbl director-address)
    

  3. Obtain your BOSH Director username and password:

    $ bbl director-username
    YOUR-DIRECTOR-USERNAME
    $ bbl director-password
    YOUR-DIRECTOR-PASSWORD
    

  4. Set your target and log in with the BOSH CLI:

    $ bosh alias-env YOUR-TARGET-NAME
    $ bosh log-in
    Username: YOUR-DIRECTOR-USERNAME
    Password: YOUR-DIRECTOR-PASSWORD
    
    Replace YOUR-TARGET-NAME with a target name to associate with the BOSH Director address, such as my-bosh. You use this target name to log in to your BOSH Director in the future.

    Replace YOUR-DIRECTOR-USERNAME and YOUR-DIRECTOR-PASSWORD with the values you obtained from bbl in the previous step.

  5. Continue to the Customizing the Cloud Foundry Deployment Manifest for AWS topic.

Destroy the BOSH Resources

You can use bbl destroy to delete the BOSH Director infrastructure in your AWS environment. Use this command if bbl up does not complete successfully and you want to reset your environment, or if you want to destroy the resources created by bosh-bootloader for any other reason.

To destroy your BOSH resources, run the following command:

$ bbl destroy

Create a pull request or raise an issue on the source for this page in GitHub