Skip to content

Instantly share code, notes, and snippets.

@ljfranklin
Last active April 22, 2017 17:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljfranklin/0245c2d4ccfbdd37d609 to your computer and use it in GitHub Desktop.
Save ljfranklin/0245c2d4ccfbdd37d609 to your computer and use it in GitHub Desktop.
Deploying Bosh-Lite + CF on AWS with Private DNS

Links:

Setup AWS Infrastructure:

  1. Create VPC
  2. Create subnet
  3. Create IGW and bind to subnet
  4. Create bosh security group (see bosh aws link for ports)
  5. Create keypair
  6. Enable DNS hostnames for VPC
  • Select VPC > Actions > Edit DNS Hostnames
  1. Create private DNS Zone for VPC (e.g. bosh-lites-vpc.com)

Docker requirements:

  • vagrant
  • vagrant plugin install vagrant-aws
  • vagrant plugin install vagrant-awsinfo
  • jq
  • aws cli
  • bosh
  • spiff

Deploy bosh-lite with Vagrant

Note: All commands must be run from within the target VPC

  1. Set environment variables (see bosh aws link)
  2. vagrant up --provider=aws

Add private DNS record

  1. Get private IP
vagrant awsinfo | jq -r '.private_ip'
  1. Create json file to describe record:
{
  "Comment": "Delete existing DNS Entry for $DOMAIN and replace with one for new IP",
    "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "$MY_HOSTNAME.$MY_PRIVATE_DNS_ZONE",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [
          {
            "Value": "$MY_PRIVATE_IP"
          }
        ]
      }
    }
  ]
}

Deploy CF

  1. git clone https://github.com/cloudfoundry/cf-release.git
  2. Add properties.domain: $MY_HOSTNAME.$MY_PRIVATE_DNS_ZONE to bosh-lite/manifests/cf-stub-spiff.yml.
  3. bosh-lite/bin/provision_cf

Delete old bosh-lite

  1. Get Private IP: dig +short $MY_HOSTNAME.$MY_PRIVATE_DNS_ZONE
  2. Get instance-id:
aws ec2 \
  describe-instances --filters \
  "Name=subnet-id,Values=$MY_SUBNET_ID" \
  "Name=private-ip-address,Values=$MY_PRIVATE_IP" | \
  jq -r '.Reservations[0].Instances[0].InstanceId'
  1. Delete instance: aws ec2 terminate-instances --instance-ids $MY_INSTANCE_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment