Skip to content

Instantly share code, notes, and snippets.

@drnic
Last active August 29, 2015 14:13
Show Gist options
  • Save drnic/246527ccb4bf7b8d02b3 to your computer and use it in GitHub Desktop.
Save drnic/246527ccb4bf7b8d02b3 to your computer and use it in GitHub Desktop.
Terraform an AWS account where the target folder has a fog-api.yml fog file containing one set of user credentials
#!/bin/bash
# USAGE: ./bastion-ssh account-folder
TERRAFORM_DIR=${TERRAFORM_DIR:-terraform-aws-cf-install}
account_folder=$1
if [[ "${account_folder}X" = "X" || ! -d $account_folder ]]; then
echo "USAGE: bastion-ssh account-folder"
exit 1
fi
if [[ ! -f $account_folder/$TERRAFORM_DIR/terraform.tfstate ]]; then
echo "File $account_folder/$TERRAFORM_DIR/terraform.tfstate is missing; and is required"
exit 1
fi
pushd $account_folder/$TERRAFORM_DIR
ssh ubuntu@$(terraform output bastion_ip) -i $(terraform output aws_key_path)
popd
#!/bin/bash
# USAGE: ./cf-login.sh student1
TERRAFORM_DIR=${TERRAFORM_DIR:-terraform-aws-cf-install}
account_folder=$1
if [[ "${account_folder}X" = "X" || ! -d $account_folder ]]; then
echo "USAGE: cf-login account-folder"
exit 1
fi
if [[ ! -f $account_folder/$TERRAFORM_DIR/terraform.tfstate ]]; then
echo "File $account_folder/$TERRAFORM_DIR/terraform.tfstate is missing; and is required"
exit 1
fi
pushd $account_folder/$TERRAFORM_DIR
cf login --skip-ssl-validation \
-a $(terraform output cf_api) \
-u admin -p $(terraform output cf_admin_pass)
popd
#!/bin/bash
# USAGE: ./fog-account account-folder
# Then inside the repl:
# >> compute = Fog::Compute::AWS.new(Fog.credentials.merge("region" => "us-west-2"))
TERRAFORM_DIR=${TERRAFORM_DIR:-terraform-aws-cf-install}
account_folder=$1
if [[ "${account_folder}X" = "X" || ! -d $account_folder ]]; then
echo "USAGE: fog-account account-folder"
exit 1
fi
if [[ ! -f $account_folder/$TERRAFORM_DIR/terraform.tfstate ]]; then
echo "File $account_folder/$TERRAFORM_DIR/terraform.tfstate is missing; and is required"
exit 1
fi
pushd $account_folder
fog -C fog-api.yml
popd
#!/bin/bash
# USAGE: ./terraform-aws-cf-install.sh student1
account_folder=$1
if [[ "${account_folder}X" = "X" || ! -d $account_folder ]]; then
echo "USAGE: terraform-aws-cf-install account-folder"
exit 1
fi
if [[ ! -f $account_folder/fog-api.yml ]]; then
echo "File $account_folder/fog-api.yml is missing; and is required"
exit 1
fi
pushd $account_folder
rm -rf terraform-aws-cf-install
git clone https://github.com/cloudfoundry-community/terraform-aws-cf-install &&
cd terraform-aws-cf-install &&
fog_to_terraform -C ../fog-api.yml &&
make plan &&
make apply
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment