Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A production environment with slightly different settings is created.
- Loading branch information
Showing
6 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
code/terraform/04-terraform-modules/module-example/prod/data-stores/mysql/main.tf
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,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 | ||
} |
9 changes: 9 additions & 0 deletions
9
code/terraform/04-terraform-modules/module-example/prod/data-stores/mysql/outputs.tf
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,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" | ||
} |
10 changes: 10 additions & 0 deletions
10
code/terraform/04-terraform-modules/module-example/prod/data-stores/mysql/variables.tf
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 @@ | ||
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" | ||
} |
17 changes: 17 additions & 0 deletions
17
code/terraform/04-terraform-modules/module-example/prod/services/webserver-cluster/main.tf
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,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 | ||
} |
4 changes: 4 additions & 0 deletions
4
.../terraform/04-terraform-modules/module-example/prod/services/webserver-cluster/outputs.tf
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,4 @@ | ||
output "alb_dns_name" { | ||
value = module.webserver_cluster.alb_dns_name | ||
description = "The domain name of the load balancer" | ||
} |
23 changes: 23 additions & 0 deletions
23
...erraform/04-terraform-modules/module-example/prod/services/webserver-cluster/variables.tf
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,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" | ||
} |