Skip to content

Instantly share code, notes, and snippets.

View katesclau's full-sized avatar
🏠
Working from home

Diego Rodrigues Ferreira katesclau

🏠
Working from home
View GitHub Profile
resource "aws_efs_file_system" "filesystem" {
creation_token = "${var.efs_name}"
}
resource "aws_efs_mount_target" "fs_target" {
file_system_id = "${aws_efs_file_system.filesystem.id}"
subnet_id = "${var.subnet_id}"
security_groups = ["${var.vpc_sg_ids}"]
}
@katesclau
katesclau / variables.snippet.tf
Created December 13, 2016 00:36
variables snippet for RDS
# Database =================================================
# Name
variable "rds_name" { default = "cluster-tut-mariadb" }
# Instance class
variable "db_instance_class" { default = "db.t2.micro" } # Free tier
# Storage
variable "db_storage" { default = 20 } # Free tier max
variable "db_storage_type" { default = "standard" } # Free tier
.
├── aws_credentials.tf
├── aws.pem
├── aws.pem.pub
├── database_credentials.tf
├── ec2
│   ├── cluster.tf
│   └── variables.tf
├── elb
│   ├── elb.tf
# Auto Scaling Pool
resource "aws_autoscaling_group" "asg" {
name = "${var.cluster_name}-asg"
availability_zones = ["${var.availability_zone}"]
min_size = "${var.cluster_min_size}"
max_size = "${var.cluster_max_size}"
desired_capacity = "${var.cluster_size}"
@katesclau
katesclau / elb.tf
Last active December 12, 2016 23:53
resource "aws_elb" "classic_elb" {
name = "${var.elb_name}"
internal = "${var.internal}"
availability_zones = ["${var.availability_zone}"]
idle_timeout = "${var.idle_timeout}"
connection_draining = "${var.connection_draining}"
connection_draining_timeout = "${var.connection_draining_timeout}"
variable "db_user" { default = "app" }
variable "db_password" { default = "password" }
# Network & Region
variable "vpc_sg_ids" {}
variable "sg_name" {}
variable "db_multi_az" { default = "false" }
variable "public" { default = "false" }
# Name
variable "rds_name" {}
# Instance class
@katesclau
katesclau / rds.tf
Last active December 13, 2016 00:12
resource "aws_db_instance" "database" {
identifier = "${var.rds_name}"
# Network configuration
vpc_security_group_ids = ["${var.vpc_sg_ids}"]
db_subnet_group_name = "${var.sg_name}"
# DB Engine
engine = "${var.db_engine}"
engine_version = "${var.db_engine_version}"
# MariaDB
module "database" {
source = "./rds"
sg_name = "${var.sg_name}"
vpc_sg_ids = "${var.vpc_sg_ids}"
rds_name = "${var.rds_name}"
db_instance_class = "${var.db_instance_class}"
@katesclau
katesclau / terra.cluster.initial.txt
Last active December 13, 2016 15:04
Terraform Cluster Tutorial initial configuration from previous tutorial
.
├── aws_credentials.tf # Your credentials variables. Should contain you Access key and Secret Key
├── aws.pem # Your Private key for access
├── aws.pem.pub # Your Public key
├── ec2
│   ├── server.tf # Instance configuration, it'll be transformed into our ASG configuration
│   └── variables.tf
├── keys
│   ├── keys.tf # Your Key pair description on AWS
│   └── variables.tf