Last active
August 29, 2015 14:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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