-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and extend to launch logsearch-workspace spot instance on AWS
- Loading branch information
1 parent
33f7ec4
commit 0bb566d
Showing
6 changed files
with
78 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
0. Setup your AWS credentials | ||
``` | ||
export TF_VAR_access_key=$AWS_ACCESS_KEY_ID | ||
export TF_VAR_secret_key=$AWS_SECRET_ACCESS_KEY | ||
export TF_VAR_workspace_key_name="pcf" | ||
export TF_VAR_workspace_subnet_id="subnet-fcd4838b" #pcf-public-az-a | ||
export TF_VAR_workspace_security_group_id0="sg-2032c147" #workspace | ||
export TF_VAR_workspace_security_group_id1="sg-6a1a080e" #stayup-pcf-VMs | ||
export TF_VAR_workspace_security_group_id2="sg-65fa4302" #staff_office_ips | ||
``` | ||
Make sure that you had `ssh-add`ed the key to your keychain | ||
|
||
0. `/path/to/logsearch-workspace/_setup/terraform/aws-workspace$ terraform apply` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
provider "aws" { | ||
access_key = "${var.access_key}" | ||
secret_key = "${var.secret_key}" | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_spot_instance_request" "workspace_instance" { | ||
ami = "ami-3fee3b54" #BOSH lite 9000.38 | ||
instance_type = "m3.xlarge" | ||
spot_price = "0.15" | ||
|
||
wait_for_fulfillment = true | ||
key_name = "${var.workspace_key_name}" | ||
tags { | ||
Name = "workspace_instance" | ||
} | ||
|
||
subnet_id = "${var.workspace_subnet_id}" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
#vpc_security_group_ids = ["${var.workspace_security_group_id0}", "${var.workspace_security_group_id1}", "${var.workspace_security_group_id2}"] | ||
|
||
root_block_device { | ||
volume_type = "gp2" | ||
volume_size = 100 | ||
} | ||
|
||
provisioner "remote-exec" { | ||
script = "provision.sh" | ||
connection { | ||
user = "ubuntu" | ||
} | ||
} | ||
} | ||
|
||
resource "aws_ebs_volume" "workspace_disk" { | ||
availability_zone = "us-east-1a" | ||
size = 40 | ||
tags { | ||
Name = "workspace_disk" | ||
} | ||
} | ||
|
||
resource "aws_volume_attachment" "workspace_ebs_att" { | ||
device_name = "/dev/sdf" | ||
volume_id = "${aws_ebs_volume.workspace_disk.id}" | ||
instance_id = "${aws_spot_instance_request.workspace_instance.spot_instance_id}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
echo "Provisioning!" | ||
|
||
apt-get -y install git | ||
|
||
exit 0 | ||
|
||
git clone https://github.com/logsearch/workspace /root/logsearch-workspace | ||
cd /root/logsearch-workspace | ||
_setup/runtime/install_dependancies |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
variable "access_key" {} | ||
variable "secret_key" {} | ||
variable "workspace_key_name" {} | ||
variable "workspace_subnet_id" {} | ||
variable "workspace_security_group_id0" {} | ||
variable "workspace_security_group_id1" {} | ||
variable "workspace_security_group_id2" {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Looks like there is a bug in Terraform 0.6.1 that prevents starting a spot instance in a VPC subnet. hashicorp/terraform#2919