This file contains hidden or 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
resource "aws_lb" "lb" { | |
name = "${var.lb_name}" | |
security_groups = ["${aws_security_group.lb.id}"] | |
subnets = ["${var.subnet_ids}"] | |
tags = "${merge(var.tags, map("Name", "${var.lb_name}"))}" | |
} | |
resource "aws_security_group" "lb" { | |
name = "${var.lb_name}" |
This file contains hidden or 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
resource "aws_security_group" "client" { | |
name_prefix = "${var.client_asg_name}" | |
description = "Security Group for ${var.client_asg_name}" | |
vpc_id = "${var.vpc_id}" | |
tags = "${merge(var.tags, map("Name", "${var.client_asg_name}"))}" | |
# aws_launch_configuration.launch_configuration in this module sets create_before_destroy to true, which means | |
# everything it depends on, including this resource, must set it as well, or you'll get cyclic dependency errors | |
# when you try to do a terraform destroy. |
This file contains hidden or 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
resource "aws_launch_configuration" "client" { | |
name_prefix = "${var.client_asg_name}" | |
image_id = "${data.aws_ami.ubuntu.image_id}" | |
instance_type = "${var.instance_type}" | |
user_data = "${data.template_file.client_user_data.rendered}" | |
associate_public_ip_address = false | |
security_groups = ["${aws_security_group.client.id}"] |
This file contains hidden or 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
resource "aws_autoscaling_group" "client" { | |
launch_configuration = "${aws_launch_configuration.client.name}" | |
name = "${var.client_asg_name}" | |
vpc_zone_identifier = "${var.subnet_ids}" | |
min_size = "${var.client_size}" | |
max_size = "${var.client_size}" | |
desired_capacity = "${var.client_size}" |
This file contains hidden or 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
####################################### | |
# Optional Variables | |
####################################### | |
variable "aws_region" { | |
description = "Region to deploy to" | |
default = "ap-southeast-1" | |
} | |
variable "tags" { | |
description = "Tags to add to all resources that support tags" |
This file contains hidden or 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
####################################### | |
# Required Variables | |
####################################### | |
variable "vpc_id" { | |
description = "VPC ID to launch resources in" | |
} | |
variable "subnet_ids" { | |
description = "A list of subnet IDs to launch instances in." | |
type = "list" |
This file contains hidden or 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
# The "main" file defines the providers and some other "main" things | |
provider "aws" { | |
version = "~> 1.33" | |
region = "${var.aws_region}" | |
} | |
locals { | |
client_port = 8080 | |
server_port = 8084 |
This file contains hidden or 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
#[macro_use] | |
extern crate diesel; | |
#[macro_use] | |
extern crate diesel_codegen; | |
extern crate r2d2; | |
extern crate r2d2_diesel; | |
use r2d2::{ManageConnection, PooledConnection}; | |
use r2d2_diesel::ConnectionManager; |