https://github.com/osgurisdosre/terraform-aws-documentdb
Terraform module which creates DocumentDB resources on AWS
https://github.com/osgurisdosre/terraform-aws-documentdb
aws documentdb terraform-aws terraform-aws-documentdb terraform-module
Last synced: 1 day ago
JSON representation
Terraform module which creates DocumentDB resources on AWS
- Host: GitHub
- URL: https://github.com/osgurisdosre/terraform-aws-documentdb
- Owner: osgurisdosre
- License: apache-2.0
- Created: 2022-12-19T12:04:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-26T12:17:25.000Z (about 3 years ago)
- Last Synced: 2023-04-26T13:50:03.873Z (about 3 years ago)
- Topics: aws, documentdb, terraform-aws, terraform-aws-documentdb, terraform-module
- Language: HCL
- Homepage: https://registry.terraform.io/modules/osgurisdosre/documentdb/aws/latest
- Size: 27.3 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS DocumentDB Terraform module
Terraform module which creates DocumentDB resources on AWS
Root module calls these modules which can also be used separately to create independent resources:
- [db_subnet_group](https://github.com/osgurisdosre/terraform-aws-documentdb/tree/main/modules/docdb_subnet_group) - creates DocumentDB subnet group
- [db_parameter_group](https://github.com/osgurisdosre/terraform-aws-documentdb/tree/main/modules/docdb_parameter_group) - creates DocumentDB parameter group
## Usage
```hcl
module "docdb" {
source = "osgurisdosre/documentdb/aws"
cluster_identifier = "demodb"
engine = "docdb"
engine_version = "4.0.0"
cluster_size = 3
instance_class = "db.t3.medium"
# Credentials
master_username = "user"
create_db_password = true
availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c"]
vpc_security_group_ids = ["sg-12345678"]
# DB subnet group
create_db_subnet_group = true
subnet_ids = ["subnet-123456789", "subnet-987654321" "subnet-123321123"]
# Database Deletion Protection
deletion_protection = true
# DB parameter group
create_db_parameter_group = true
parameters = [{
name = "tls"
value = "enabled"
}]
}
```
## Conditional creation
```hcl
module "docdb" {
source = "osgurisdosre/documentdb/aws"
# Disable creation of DocumentDB instance(s)
create_db = false
# Enable creation of a random password
create_db_password = true
# Enable creation of subnet group
create_db_subnet_group = true
# Enable creation of parameter group
create_db_parameter_group = true
}
```
### Parameter Groups
[Reference](https://docs.aws.amazon.com/documentdb/latest/developerguide/cluster_parameter_groups.html)
Users have the ability to:
- Create a new parameter group (use cluster identifier as name):
```hcl
create_db_parameter_group = true
parameters = [{
name = "tls"
value = "enabled"
}]
```
- Pass the name of a parameter group to use that has been created outside of the module:
```hcl
create_db_parameter_group = false
db_parameter_group_name = "custom-docdb-4.0" # must already exist in AWS
```
- Use a default parameter group provided by AWS
```hcl
create_db_parameter_group = false
```
## Examples
To-do:
## Notes
1. This module does not create DocumentDB security group. Use [terraform-aws-security-group](https://github.com/terraform-aws-modules/terraform-aws-security-group) module for this.
2. By default, the variable `create_db_password` is set to true. Therefore, even if the user provides a password, it will not be read. The `create_db_password` variable should be set to false and the `password` variable should have a non-null value to be read and used.
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.0 |
| [aws](#requirement\_aws) | >= 5.50 |
| [random](#requirement\_random) | >= 3.1 |
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 5.50 |
| [random](#provider\_random) | >= 3.1 |
## Modules
| Name | Source | Version |
|------|--------|---------|
| [docdb\_parameter\_group](#module\_docdb\_parameter\_group) | ./modules/docdb_parameter_group | n/a |
| [docdb\_subnet\_group](#module\_docdb\_subnet\_group) | ./modules/docdb_subnet_group | n/a |
## Resources
| Name | Type |
|------|------|
| [aws_docdb_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster) | resource |
| [aws_docdb_cluster_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster_instance) | resource |
| [random_password.master_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [apply\_immediately](#input\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. | `bool` | `false` | no |
| [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | This parameter does not apply to Amazon DocumentDB.Amazon DocumentDB does not perform minor version upgrades regardless of the value set. | `bool` | `false` | no |
| [availability\_zones](#input\_availability\_zones) | A list of EC2 Availability Zones that instances in the DB cluster can be created in. | `list(string)` | n/a | no |
| [backup\_retention\_period](#input\_backup\_retention\_period) | The days to retain backups for. | `number` | `7` | no |
| [cluster\_identifier](#input\_cluster\_identifier) | The cluster identifier. If omitted, Terraform will assign a random, unique identifier. | `string` | n/a | yes |
| [cluster\_size](#input\_cluster\_size) | Number of instances. | `number` | `3` | no |
| [create](#input\_create) | Create the resource? | `bool` | `true` | no |
| [create\_db](#input\_create\_db) | Create the resource? | `bool` | `true` | no |
| [create\_db\_parameter\_group](#input\_create\_db\_parameter\_group) | Create the resource? | `bool` | `false` | no |
| [create\_db\_password](#input\_create\_db\_password) | Create the resource? | `bool` | `false` | no |
| [create\_db\_subnet\_group](#input\_create\_db\_subnet\_group) | Create the resource? | `bool` | `false` | no |
| [db\_cluster\_parameter\_group\_name](#input\_db\_cluster\_parameter\_group\_name) | A cluster parameter group to associate with the cluster. | `string` | `null` | no |
| [db\_parameter\_group\_name](#input\_db\_parameter\_group\_name) | A cluster parameter group name. | `string` | `""` | no |
| [db\_subnet\_group\_name](#input\_db\_subnet\_group\_name) | The DB subnet group to associate with this DB instance. | `string` | `""` | no |
| [deletion\_protection](#input\_deletion\_protection) | A value that indicates whether the DB cluster has deletion protection enabled. | `bool` | `false` | no |
| [enable\_performance\_insights](#input\_enable\_performance\_insights) | A value that indicates whether to enable Performance Insights for the DB Instance. | `bool` | `true` | no |
| [enabled\_cloudwatch\_logs\_exports](#input\_enabled\_cloudwatch\_logs\_exports) | List of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: audit, profiler. | `list(string)` |
[
"audit",
"profiler"
]
| no |
| [engine](#input\_engine) | The name of the database engine to be used for this DB cluster. | `string` | `"docdb"` | no |
| [engine\_version](#input\_engine\_version) | The database engine version. Updating this argument results in an outage. | `string` | n/a | yes |
| [family](#input\_family) | The family of the documentDB cluster parameter group. | `string` | `"docdb4.0"` | no |
| [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made. | `string` | `null` | no |
| [identifier\_prefix](#input\_identifier\_prefix) | Creates a unique identifier beginning with the specified prefix. | `string` | `null` | no |
| [instance\_class](#input\_instance\_class) | The instance class to use. | `string` | `null` | no |
| [kms\_key\_id](#input\_kms\_key\_id) | The ARN for the KMS encryption key. | `string` | `null` | no |
| [master\_password](#input\_master\_password) | Password for the master DB user. | `string` | `null` | no |
| [master\_username](#input\_master\_username) | Username for the master DB user. | `string` | n/a | yes |
| [parameter\_description](#input\_parameter\_description) | Description for the parameter group. | `string` | `"Parameter group for"` | no |
| [parameters](#input\_parameters) | List of DB parameters to apply. | `list(map(string))` | `[]` | no |
| [password](#input\_password) | Password for the master DB user. | `string` | `null` | no |
| [performance\_insights\_kms\_key\_id](#input\_performance\_insights\_kms\_key\_id) | The KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key. | `string` | `null` | no |
| [port](#input\_port) | The port on which the DB accepts connections. | `number` | `27017` | no |
| [preferred\_backup\_window](#input\_preferred\_backup\_window) | The daily time range during which automated backups are created if automated backups are enabled using the BackupRetentionPeriod parameter. | `string` | `"03:00-05:00"` | no |
| [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range during which system maintenance can occur, in (UTC). | `string` | `"sat:05:00-sat:08:00"` | no |
| [promotion\_tier](#input\_promotion\_tier) | Failover Priority setting on instance level. | `number` | `0` | no |
| [random\_password\_length](#input\_random\_password\_length) | The length of the string desired. | `number` | `16` | no |
| [sg\_name\_prefix](#input\_sg\_name\_prefix) | Creates a unique name beginning with the specified prefix. | `string` | `null` | no |
| [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB cluster is deleted. | `bool` | `true` | no |
| [snapshot\_identifier](#input\_snapshot\_identifier) | Specifies whether or not to create this cluster from a snapshot. | `string` | `null` | no |
| [storage\_encrypted](#input\_storage\_encrypted) | Specifies whether the DB cluster is encrypted. | `bool` | `true` | no |
| [subnet\_description](#input\_subnet\_description) | Allowed subnets for DB cluster instances. | `string` | `null` | no |
| [subnet\_ids](#input\_subnet\_ids) | A list of VPC subnet IDs. | `list(string)` | `[]` | no |
| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | List of VPC security groups to associate with the Cluster. | `list(string)` | n/a | yes |
| [vpc\_tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |
## Outputs
| Name | Description |
|------|-------------|
| [db\_instance\_endpoint](#output\_db\_instance\_endpoint) | The DNS address of the DocDB Cluster |
| [db\_instance\_endpoint\_reader](#output\_db\_instance\_endpoint\_reader) | The DNS address of the DocDB Cluster |
| [db\_instance\_password](#output\_db\_instance\_password) | The database password (this password may be old, because Terraform doesn't track it after initial creation) |
## Authors
Module is maintained by [Emidio Neto](https://github.com/emdneto), [Leonardo Jardim](https://github.com/leojaardim) and [Yuri Azeredo](https://github.com/yuriazeredo)
## License
Apache 2 Licensed. See [LICENSE](https://github.com/osgurisdosre/terraform-aws-documentdb/blob/main/LICENSE) for full details.