Skip to content

Instantly share code, notes, and snippets.

@scode
Created January 13, 2017 01:47
Show Gist options
  • Save scode/e939eca78113ff377df1a835a10a4e26 to your computer and use it in GitHub Desktop.
Save scode/e939eca78113ff377df1a835a10a4e26 to your computer and use it in GitHub Desktop.
Minor aws .tf file changes required to make cockroach launch in a VPC.
diff --git a/cloud/aws/main.tf b/cloud/aws/main.tf
index 7e7fd6c..b0c3101 100644
--- a/cloud/aws/main.tf
+++ b/cloud/aws/main.tf
@@ -6,10 +6,12 @@ resource "aws_instance" "cockroach" {
tags {
Name = "${var.key_name}-${count.index}"
}
+ subnet_id = "${var.aws_subnet_id}"
+ associate_public_ip_address = true
ami = "${var.aws_ami_id}"
availability_zone = "${var.aws_availability_zone}"
instance_type = "${var.aws_instance_type}"
- security_groups = ["${aws_security_group.default.name}"]
+ vpc_security_group_ids = ["${aws_security_group.default.id}"]
key_name = "${var.key_name}"
count = "${var.num_instances}"
}
diff --git a/cloud/aws/security_group.tf b/cloud/aws/security_group.tf
index 9c2bdb2..aac9ab5 100644
--- a/cloud/aws/security_group.tf
+++ b/cloud/aws/security_group.tf
@@ -1,5 +1,6 @@
resource "aws_security_group" "default" {
name = "${var.key_name}-security-group"
+ vpc_id = "${var.aws_vpc_id}"
ingress {
from_port = 22
to_port = 22
diff --git a/cloud/aws/variables.tf b/cloud/aws/variables.tf
index 383faca..078bf04 100644
--- a/cloud/aws/variables.tf
+++ b/cloud/aws/variables.tf
@@ -16,6 +16,9 @@ variable "supervisor_port" {
default = "9001"
}
+variable aws_vpc_id {}
+variable aws_subnet_id {}
+
# AWS region to use. WARNING: changing this will break the AMI ID.
variable "aws_region" {
default = "us-east-1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment