Skip to content

Commit

Permalink
A production environment with slightly different settings is created.
Browse files Browse the repository at this point in the history
  • Loading branch information
albers committed May 25, 2020
1 parent 3a33f82 commit fb66645
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
@@ -0,0 +1,26 @@
provider "aws" {
region = "us-east-2"
version = "~> 2.62"
}

terraform {
backend "s3" {
bucket = "terraform-book-state"
key = "module-example/prod/data-stores/mysql/terraform.tfstate"
region = "us-east-2"
dynamodb_table = "terraform-book-locks"
encrypt = true
}
}

resource "aws_db_instance" "example" {
identifier_prefix = "terraform-up-and-running"
engine = "mysql"
allocated_storage = 10
instance_class = "db.t2.micro"
skip_final_snapshot = true

name = var.db_name
username = "admin"
password = var.db_password
}
@@ -0,0 +1,9 @@
output "address" {
value = aws_db_instance.example.address
description = "Connect to the database at this endpoint"
}

output "port" {
value = aws_db_instance.example.port
description = "The port the database ist listening on"
}
@@ -0,0 +1,10 @@
variable "db_password" {
description = "The master password for the database"
type = string
}

variable "db_name" {
description = "The database name"
type = string
default = "example_database_prod"
}
@@ -0,0 +1,17 @@
provider "aws" {
region = "us-east-2"
version = "~> 2.62"
}

module "webserver_cluster" {
source = "../../../modules/services/webserver-cluster"

cluster_name = "webservers-prod"
db_remote_state_bucket = "terraform-book-state"
db_remote_state_key = "module-example/prod/data-stores/mysql/terraform.tfstate"
db_remote_state_region = "us-east-2"

instance_type = "t2.small"
min_size = 2
max_size = 10
}
@@ -0,0 +1,4 @@
output "alb_dns_name" {
value = module.webserver_cluster.alb_dns_name
description = "The domain name of the load balancer"
}
@@ -0,0 +1,23 @@
variable "cluster_name" {
description = "The name to use to namespace all the resources in the cluster"
type = string
default = "webservers-prod"
}

variable "db_remote_state_bucket" {
description = "The name of the S3 bucket used for the database's remote state storage"
type = string
default = "terraform-book-state"
}

variable "db_remote_state_key" {
description = "The name of the key in the S3 bucket used for the database's remote state storage"
type = string
default = "module-example/prod/data-stores/mysql/terraform.tfstate"
}

variable "db_remote_state_region" {
description = "The region the remote state lives in"
type = string
default = "us-east-2"
}

0 comments on commit fb66645

Please sign in to comment.