Skip to content

Instantly share code, notes, and snippets.

@jvawdrey
Created June 24, 2016 04:55
Show Gist options
  • Save jvawdrey/02ac35e49af81789b5237fbb2f797780 to your computer and use it in GitHub Desktop.
Save jvawdrey/02ac35e49af81789b5237fbb2f797780 to your computer and use it in GitHub Desktop.
pcf dev AWS deploy steps

Deploying MicroPCF on AWS

January 5th, 2016

Instructions for deploying micropcf to AWS.

I encountered several challenges relating to AWS configurations and the available Vagrantfile while deploying micropcf to AWS. This documentation details the steps taken to successfully deploy micropcf to AWS.

micropcf - https://github.com/pivotal-cf/micropcf

Note - micropcf is now pc dev.

Configure AWS

Setup domain via Route 53

  1. Networking -> Route 53
  2. Register domain

Create AWS key

Note - Take down region and use same for AWS_REGION value

  1. Compute -> EC2
  2. Network & Security (in left side bar)
  3. Key Pairs
  4. Create Key Pair button
  5. Enter 'vagrantkey'in Key pair name field
  6. Copy pem file downloaded to project directory
  7. Change access
chmod 600 vagrantkey.pem

Setup VPC and subnet

  1. Networking -> VPC
  2. Start VPC Wizard
  3. Select (VPC with a Single Public Subnet)
  4. Set the following values
  • VPC name: vargrantVPC
  • Subnet name: vargrantSubnet
  1. Leave other values as default and click Create VPC button
  2. Click Subnets (on left bar)
  3. Click 'vagrantSubnet' and copy SubnetID value for use later

Configure security group (open up all ports for demo)

  1. Compute -> EC2
  2. Network & Security (in left side bar)
  3. Security Groups
  4. Create Security Group
  5. Set the following values
  • Security group name: vagrantSecurityGroup
  • Description: Vagrant security group (WARNING COMPLETELY OPEN)
  • VPC: < select option with 'vargrantVPC' in label >
  1. Inbound tab -> Add rule button (Outbound tab will have same by default)
  2. Set the following values
  • Type: All traffic
  • Protocol: All
  • Port Range: 0 - 65535 or ALL
  • Source: Anywhere 0.0.0.0/0
  1. Create button
  2. Copy down security group ID for use later

Allocate new Elastic IP

  1. Compute -> EC2
  2. Network & Security (in left side bar)
  3. Elastic IPs
  4. Allocate New Address button
  5. Yes, Allocate
  6. Copy Elastic IP value for use later

Setup Route 53 target

Before PC can target and log in we have to set the instance's Elastic IP as an A record in Route 53, including a wildcard for the address.

  1. Networking -> Route 53
  2. Hosted Zones
  3. Click on domain created for micropcf during setup
  4. Go to record sets
  5. Create record set
  6. Enter following lines in Value box
  • Name: Leave blank
  • Value: < Enter Elastic IP >
  1. Create button
  2. Create record set
  3. Enter following lines in Value box
  • Name: *
  • Value: < Enter Elastic IP >
  1. Create button

Setup the local environment

Download and run vagrant from https://www.vagrantup.com/downloads.html

# Install Vagrant AWS plugin
vagrant plugin install vagrant-aws

# Installing the 'vagrant-aws' plugin. This can take a few minutes...
# Installed the plugin 'vagrant-aws (0.7.0)'!

Download vagrant file from https://github.com/pivotal-cf/micropcf/releases/download/v0.3.0/Vagrantfile-v0.3.0.base

# change name of base file to Vagrantfile
mv Vagrantfile-v0.3.0.base Vagrantfile

# add AWS credentials to environment
export AWS_ACCESS_KEY_ID=''
export AWS_SECRET_ACCESS_KEY=''
export AWS_SSH_PRIVATE_KEY_NAME=''
export AWS_SSH_PRIVATE_KEY_PATH=''
export AWS_REGION=us-west-2
export MICROPCF_DOMAIN=pcfds.com # this value is domain setup via Route 53
export AWS_SECURITY_GROUP_ID=sg-c5cddfa1 # security group ID captured during AWS setup
export AWS_SUBNET_ID=subnet-14c4824d # subnet ID captured during AWS setup
export AWS_ELASTIC_IP=52.33.140.103 # elastic IP captured during AWS setup

Edit vargrantfile

Open Vagrantfile and edit the following lines

  • Add the following lines after 'config.vm.provider "aws" do |aws, override|'.

# set AWS security group
args = ENV["AWS_SECURITY_GROUP_ID"]
aws.security_groups = [args]

  • Add the following lines after 'aws.ami'.

# assign a subnet and VPC
aws.subnet_id = ENV["AWS_SUBNET_ID"]

# associate elastic ip with instance
aws.elastic_ip = (ENV["AWS_ELASTIC_IP"])

Launch PCF micro instance

# Launch vagrant file (same directory as Vagrantfile)
vagrant up --provider aws

# Note - Pauses for several minutes at "default: Waiting for services to start..."

# ==> default: Waiting for services to start...
# ==> default: MicroPCF is now running.
# ==> default: To begin using MicroPCF, please run:
# ==> default: 	cf api api.pcfds.com --skip-ssl-validation
# ==> default: 	cf login
# ==> default: Email: admin
# ==> default: Password: admin

# Note - Username and password supplied!

# Target and login using this format with the '-a':
cf login -a api.$MICROPCF_DOMAIN --skip-ssl-validation

# Enter email and password

# API endpoint:   https://api.pcfds.com (API version: 2.44.0)   
# User:           admin   
# Org:            micropcf-org   
# Space:          micropcf-space

# Setup MICRO environment

# Create org MICRO
cf create-org MICRO

# Create space production in org MICRO
cf create-space production -o MICRO

# Create space development in org MICRO
cf create-space development -o MICRO

# Create space test in org MICRO
cf create-space test -o MICRO

# Assign target (space = production, org = MICRO)
cf target -s production -o MICRO

Contact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment