-
-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow to customizable instance settings (#146)
- Loading branch information
Showing
5 changed files
with
148 additions
and
6 deletions.
There are no files selected for viewing
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
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,81 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
###################################### | ||
# Data sources to get VPC and subnets | ||
###################################### | ||
data "aws_vpc" "default" { | ||
default = true | ||
} | ||
|
||
data "aws_subnet_ids" "all" { | ||
vpc_id = data.aws_vpc.default.id | ||
} | ||
|
||
############# | ||
# RDS Aurora | ||
############# | ||
module "aurora" { | ||
source = "../../" | ||
name = "aurora-example-postgresql" | ||
engine = "aurora-postgresql" | ||
engine_version = "11.6" | ||
subnets = data.aws_subnet_ids.all.ids | ||
vpc_id = data.aws_vpc.default.id | ||
replica_count = 3 | ||
instance_type = "db.r5.large" | ||
apply_immediately = true | ||
skip_final_snapshot = true | ||
db_parameter_group_name = aws_db_parameter_group.aurora_db_postgres11_parameter_group.id | ||
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_cluster_postgres11_parameter_group.id | ||
// enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] | ||
security_group_description = "" | ||
|
||
instances_parameters = [ | ||
// List index should be equal to `replica_count` | ||
// Omitted keys replaced by module defaults | ||
{ | ||
instance_type = "db.r5.2xlarge" | ||
publicly_accessible = true | ||
}, | ||
{ | ||
instance_type = "db.r5.2xlarge" | ||
}, | ||
{ | ||
instance_name = "reporting" | ||
instance_type = "db.r5.large" | ||
instance_promotion_tier = 15 | ||
} | ||
] | ||
} | ||
|
||
resource "aws_db_parameter_group" "aurora_db_postgres11_parameter_group" { | ||
name = "test-aurora-db-postgres11-parameter-group" | ||
family = "aurora-postgresql11" | ||
description = "test-aurora-db-postgres11-parameter-group" | ||
} | ||
|
||
resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres11_parameter_group" { | ||
name = "test-aurora-postgres11-cluster-parameter-group" | ||
family = "aurora-postgresql11" | ||
description = "test-aurora-postgres11-cluster-parameter-group" | ||
} | ||
|
||
############################ | ||
# Example of security group | ||
############################ | ||
resource "aws_security_group" "app_servers" { | ||
name_prefix = "app-servers-" | ||
description = "For application servers" | ||
vpc_id = data.aws_vpc.default.id | ||
} | ||
|
||
resource "aws_security_group_rule" "allow_access" { | ||
type = "ingress" | ||
from_port = module.aurora.this_rds_cluster_port | ||
to_port = module.aurora.this_rds_cluster_port | ||
protocol = "tcp" | ||
source_security_group_id = aws_security_group.app_servers.id | ||
security_group_id = module.aurora.this_security_group_id | ||
} |
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,54 @@ | ||
// aws_rds_cluster | ||
output "this_rds_cluster_id" { | ||
description = "The ID of the cluster" | ||
value = module.aurora.this_rds_cluster_id | ||
} | ||
|
||
output "this_rds_cluster_resource_id" { | ||
description = "The Resource ID of the cluster" | ||
value = module.aurora.this_rds_cluster_resource_id | ||
} | ||
|
||
output "this_rds_cluster_endpoint" { | ||
description = "The cluster endpoint" | ||
value = module.aurora.this_rds_cluster_endpoint | ||
} | ||
|
||
output "this_rds_cluster_reader_endpoint" { | ||
description = "The cluster reader endpoint" | ||
value = module.aurora.this_rds_cluster_reader_endpoint | ||
} | ||
|
||
output "this_rds_cluster_database_name" { | ||
description = "Name for an automatically created database on cluster creation" | ||
value = module.aurora.this_rds_cluster_database_name | ||
} | ||
|
||
output "this_rds_cluster_master_password" { | ||
description = "The master password" | ||
value = module.aurora.this_rds_cluster_master_password | ||
sensitive = true | ||
} | ||
|
||
output "this_rds_cluster_port" { | ||
description = "The port" | ||
value = module.aurora.this_rds_cluster_port | ||
} | ||
|
||
output "this_rds_cluster_master_username" { | ||
description = "The master username" | ||
value = module.aurora.this_rds_cluster_master_username | ||
} | ||
|
||
// aws_rds_cluster_instance | ||
output "this_rds_cluster_instance_endpoints" { | ||
description = "A list of all cluster instance endpoints" | ||
value = module.aurora.this_rds_cluster_instance_endpoints | ||
} | ||
|
||
// aws_security_group | ||
output "this_security_group_id" { | ||
description = "The security group ID of the cluster" | ||
value = module.aurora.this_security_group_id | ||
} | ||
|
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
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