Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
drpebcak committed Dec 2, 2019
0 parents commit c574eee
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.terraform
*.tfstate*
39 changes: 39 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
resource "aws_docdb_subnet_group" "docdb" {
name_prefix = var.name
subnet_ids = var.group_subnets
}

resource "aws_docdb_cluster" "api_docdb" {
cluster_identifier_prefix = var.name
db_subnet_group_name = aws_docdb_subnet_group.sn_docdb.name
db_cluster_parameter_group_name = aws_docdb_cluster_parameter_group.api_docdb.name
vpc_security_group_ids = var.cluster_security_group
engine = "docdb"
master_username = var.master_username
master_password = var.master_password
storage_encrypted = var.storage_encrypted

backup_retention_period = var.backup_retention_period
preferred_backup_window = var.preferred_backup_window
skip_final_snapshot = var.skip_final_snapshot
}

resource "aws_docdb_cluster_instance" "cluster_instances" {
count = var.cluster_instance_count
identifier = "${var.name}-${count.index}"
cluster_identifier = aws_docdb_cluster.api_docdb.id
instance_class = var.cluster_instance_class
}

resource "aws_docdb_cluster_parameter_group" "api_docdb" {
family = "docdb3.6"
name_prefix = var.name
description = "${var.name} docdb cluster parameter group"
dynamic "parameter" {
for_each = var.parameters
content {
name = parameter.value.name
value = parameter.value.value
}
}
}
27 changes: 27 additions & 0 deletions output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
output "arn" {
value = aws_docdb_cluster.api_docdb.arn
}

output "cluster_members" {
value = aws_docdb_cluster.api_docdb.cluster_members
}

output "cluster_resource_id" {
value = aws_docdb_cluster.api_docdb.cluster_resource_id
}

output "endpoint" {
value = aws_docdb_cluster.api_docdb.endpoint
}

output "hosted_zone_id" {
value = aws_docdb_cluster.api_docdb.hosted_zone_id
}

output "id" {
value = aws_docdb_cluster.api_docdb.id
}

output "reader_endpoint" {
value = aws_docdb_cluster.api_docdb.reader_endpoint
}
56 changes: 56 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
variable "group_subnets" {
type = list(string)
default = []
}

variable "cluster_security_group" {
type = list(string)
}

variable "master_password" {
type = string
}

variable "master_username" {
type = string
}

variable "cluster_instance_class" {
type = string
default = "db.r5.large"
}

variable "cluster_instance_count" {
type = number
default = 1
}

variable "name" {
type = string
}

variable "backup_retention_period" {
default = 7
type = number
}

variable "preferred_backup_window" {
default = "07:00-09:00"
type = string
}

variable "skip_final_snapshot" {
default = false
type = bool
}

variable "storage_encrypted" {
default = true
type = bool
}

variable "parameters" {
description = "additional parameters modified in parameter group"
type = list(map(any))
default = []
}

0 comments on commit c574eee

Please sign in to comment.