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.
Setup domain via Route 53
- Networking -> Route 53
- Register domain
Create AWS key
Note - Take down region and use same for AWS_REGION value
- Compute -> EC2
- Network & Security (in left side bar)
- Key Pairs
- Create Key Pair button
- Enter 'vagrantkey'in Key pair name field
- Copy pem file downloaded to project directory
- Change access
chmod 600 vagrantkey.pem
Setup VPC and subnet
- Networking -> VPC
- Start VPC Wizard
- Select (VPC with a Single Public Subnet)
- Set the following values
- VPC name: vargrantVPC
- Subnet name: vargrantSubnet
- Leave other values as default and click Create VPC button
- Click Subnets (on left bar)
- Click 'vagrantSubnet' and copy SubnetID value for use later
Configure security group (open up all ports for demo)
- Compute -> EC2
- Network & Security (in left side bar)
- Security Groups
- Create Security Group
- Set the following values
- Security group name: vagrantSecurityGroup
- Description: Vagrant security group (WARNING COMPLETELY OPEN)
- VPC: < select option with 'vargrantVPC' in label >
- Inbound tab -> Add rule button (Outbound tab will have same by default)
- Set the following values
- Type: All traffic
- Protocol: All
- Port Range: 0 - 65535 or ALL
- Source: Anywhere 0.0.0.0/0
- Create button
- Copy down security group ID for use later
Allocate new Elastic IP
- Compute -> EC2
- Network & Security (in left side bar)
- Elastic IPs
- Allocate New Address button
- Yes, Allocate
- 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.
- Networking -> Route 53
- Hosted Zones
- Click on domain created for micropcf during setup
- Go to record sets
- Create record set
- Enter following lines in Value box
- Name: Leave blank
- Value: < Enter Elastic IP >
- Create button
- Create record set
- Enter following lines in Value box
- Name: *
- Value: < Enter Elastic IP >
- Create button
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
- Jarrod Vawdrey
- Email: [email protected]
- Twitter: @jjvawdrey