Giter Site home page Giter Site logo

cloudposse / terraform-aws-documentdb-cluster Goto Github PK

View Code? Open in Web Editor NEW
58.0 17.0 79.0 116 KB

Terraform module to provision a DocumentDB cluster on AWS

Home Page: https://cloudposse.com/accelerate

License: Apache License 2.0

Makefile 7.73% HCL 82.34% Go 9.93%
mongodb documentdb-cluster documentdb json database hcl2

terraform-aws-documentdb-cluster's Introduction

terraform-aws-documentdb-cluster

Latest ReleaseLast UpdatedSlack Community

Terraform module to provision an Amazon DocumentDB cluster.

Tip

๐Ÿ‘ฝ Use Atmos with Terraform

Cloud Posse uses atmos to easily orchestrate multiple environments using Terraform.
Works with Github Actions, Atlantis, or Spacelift.

Watch demo of using Atmos with Terraform
Example of running atmos to manage infrastructure from our Quick Start tutorial.

Usage

For a complete example, see examples/complete.

For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test.

module "documentdb_cluster" {
  source = "cloudposse/documentdb-cluster/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version = "x.x.x"
  namespace               = "eg"
  stage                   = "testing"
  name                    = "docdb"
  cluster_size            = 3
  master_username         = "admin1"
  master_password         = "Test123456789"
  instance_class          = "db.r4.large"
  vpc_id                  = "vpc-xxxxxxxx"
  subnet_ids              = ["subnet-xxxxxxxx", "subnet-yyyyyyyy"]
  allowed_security_groups = ["sg-xxxxxxxx"]
  zone_id                 = "Zxxxxxxxx"
}

Important

In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic approach for updating versions to avoid unexpected changes.

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code

Requirements

Name Version
terraform >= 1.3
aws >= 2.0
local >= 1.3
random >= 1.0

Providers

Name Version
aws >= 2.0
random >= 1.0

Modules

Name Source Version
dns_master cloudposse/route53-cluster-hostname/aws 0.12.2
dns_replicas cloudposse/route53-cluster-hostname/aws 0.12.2
ssm_write_db_password cloudposse/ssm-parameter-store/aws 0.11.0
this cloudposse/label/null 0.25.0

Resources

Name Type
aws_docdb_cluster.default resource
aws_docdb_cluster_instance.default resource
aws_docdb_cluster_parameter_group.default resource
aws_docdb_subnet_group.default resource
aws_security_group.default resource
aws_security_group_rule.allow_ingress_from_self resource
aws_security_group_rule.egress resource
aws_security_group_rule.ingress_cidr_blocks resource
aws_security_group_rule.ingress_security_groups resource
random_password.password resource

Inputs

Name Description Type Default Required
additional_tag_map Additional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
map(string) {} no
allow_ingress_from_self Adds the Document DB security group itself as a source for ingress rules. Useful when this security group will be shared with applications. bool false no
allowed_cidr_blocks List of CIDR blocks to be allowed to connect to the DocumentDB cluster list(string) [] no
allowed_egress_cidr_blocks List of CIDR blocks to be allowed to send traffic outside of the DocumentDB cluster list(string)
[
"0.0.0.0/0"
]
no
allowed_security_groups List of existing Security Groups to be allowed to connect to the DocumentDB cluster list(string) [] no
apply_immediately Specifies whether any cluster modifications are applied immediately, or during the next maintenance window bool true no
attributes ID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
list(string) [] no
auto_minor_version_upgrade Specifies whether any minor engine upgrades will be applied automatically to the DB instance during the maintenance window or not bool true no
ca_cert_identifier The identifier of the CA certificate for the DB instance string null no
cluster_dns_name Name of the cluster CNAME record to create in the parent DNS zone specified by zone_id. If left empty, the name will be auto-asigned using the format master.var.name string "" no
cluster_family The family of the DocumentDB cluster parameter group. For more details, see https://docs.aws.amazon.com/documentdb/latest/developerguide/db-cluster-parameter-group-create.html string "docdb3.6" no
cluster_parameters List of DB parameters to apply
list(object({
apply_method = string
name = string
value = string
}))
[] no
cluster_size Number of DB instances to create in the cluster number 3 no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
no
db_port DocumentDB port number 27017 no
deletion_protection A value that indicates whether the DB cluster has deletion protection enabled bool false no
delimiter Delimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
descriptor_formats Describe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br> format = string<br> labels = list(string)<br>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
any {} no
egress_from_port [from_port]DocumentDB initial port range for egress (e.g. 0) number 0 no
egress_protocol DocumentDB protocol for egress (e.g. -1, tcp) string "-1" no
egress_to_port [to_port]DocumentDB initial port range for egress (e.g. 65535) number 0 no
enable_performance_insights Specifies whether to enable Performance Insights for the DB Instance. bool false no
enabled Set to false to prevent the module from creating any resources bool null no
enabled_cloudwatch_logs_exports List of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquery list(string) [] no
engine The name of the database engine to be used for this DB cluster. Defaults to docdb. Valid values: docdb string "docdb" no
engine_version The version number of the database engine to use string "3.6.0" no
environment ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' string null no
external_security_group_id_list List of external security group IDs to attach to the Document DB list(string) [] no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
number null no
instance_class The instance class to use. For more details, see https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs string "db.r4.large" no
kms_key_id The ARN for the KMS encryption key. When specifying kms_key_id, storage_encrypted needs to be set to true string "" no
label_key_case Controls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
string null no
label_order The order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
list(string) null no
label_value_case Controls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
string null no
labels_as_tags Set of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
Notes:
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
set(string)
[
"default"
]
no
master_password (Required unless a snapshot_identifier is provided) Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Please refer to the DocumentDB Naming Constraints string "" no
master_username (Required unless a snapshot_identifier is provided) Username for the master DB user string "admin1" no
name ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
string null no
namespace ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique string null no
preferred_backup_window Daily time range during which the backups happen string "07:00-09:00" no
preferred_maintenance_window The window to perform maintenance in. Syntax: ddd:hh24:mi-ddd:hh24:mi. string "Mon:22:00-Mon:23:00" no
reader_dns_name Name of the reader endpoint CNAME record to create in the parent DNS zone specified by zone_id. If left empty, the name will be auto-asigned using the format replicas.var.name string "" no
regex_replace_chars Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
retention_period Number of days to retain backups for number 5 no
skip_final_snapshot Determines whether a final DB snapshot is created before the DB cluster is deleted bool true no
snapshot_identifier Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot string "" no
ssm_parameter_enabled Whether an SSM parameter store value is created to store the database password. bool false no
ssm_parameter_path_prefix The path prefix for the created SSM parameter e.g. '/docdb/master-password/dev'. ssm_parameter_enabled must be set to true for this to take affect. string "/docdb/master-password/" no
stage ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' string null no
storage_encrypted Specifies whether the DB cluster is encrypted bool true no
storage_type The storage type to associate with the DB cluster. Valid values: standard, iopt1 string "standard" no
subnet_ids List of VPC subnet IDs to place DocumentDB instances in list(string) n/a yes
tags Additional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string) {} no
tenant ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for string null no
vpc_id VPC ID to create the cluster in (e.g. vpc-a22222ee) string n/a yes
zone_id Route53 parent zone ID. If provided (not empty), the module will create sub-domain DNS records for the DocumentDB master and replicas string "" no

Outputs

Name Description
arn Amazon Resource Name (ARN) of the cluster
cluster_name Cluster Identifier
endpoint Endpoint of the DocumentDB cluster
master_host DB master hostname
master_password Password for the master DB user
master_username Username for the master DB user
reader_endpoint A read-only endpoint of the DocumentDB cluster, automatically load-balanced across replicas
replicas_host DB replicas hostname
security_group_arn ARN of the DocumentDB cluster Security Group
security_group_id ID of the DocumentDB cluster Security Group
security_group_name Name of the DocumentDB cluster Security Group

Related Projects

Check out these related projects.

References

For additional context, refer to some of these links.

Tip

Use Terraform Reference Architectures for AWS

Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.

โœ… We build it with you.
โœ… You own everything.
โœ… Your team wins.

Request Quote

๐Ÿ“š Learn More

Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.

Your team can operate like a pro today.

Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.

Day-0: Your Foundation for Success

  • Reference Architecture. You'll get everything you need from the ground up built using 100% infrastructure as code.
  • Deployment Strategy. Adopt a proven deployment strategy with GitHub Actions, enabling automated, repeatable, and reliable software releases.
  • Site Reliability Engineering. Gain total visibility into your applications and services with Datadog, ensuring high availability and performance.
  • Security Baseline. Establish a secure environment from the start, with built-in governance, accountability, and comprehensive audit logs, safeguarding your operations.
  • GitOps. Empower your team to manage infrastructure changes confidently and efficiently through Pull Requests, leveraging the full power of GitHub Actions.

Request Quote

Day-2: Your Operational Mastery

  • Training. Equip your team with the knowledge and skills to confidently manage the infrastructure, ensuring long-term success and self-sufficiency.
  • Support. Benefit from a seamless communication over Slack with our experts, ensuring you have the support you need, whenever you need it.
  • Troubleshooting. Access expert assistance to quickly resolve any operational challenges, minimizing downtime and maintaining business continuity.
  • Code Reviews. Enhance your teamโ€™s code quality with our expert feedback, fostering continuous improvement and collaboration.
  • Bug Fixes. Rely on our team to troubleshoot and resolve any issues, ensuring your systems run smoothly.
  • Migration Assistance. Accelerate your migration process with our dedicated support, minimizing disruption and speeding up time-to-value.
  • Customer Workshops. Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate.

Request Quote

โœจ Contributing

This project is under active development, and we encourage contributions from our community.

Many thanks to our outstanding contributors:

For ๐Ÿ› bug reports & feature requests, please use the issue tracker.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Review our Code of Conduct and Contributor Guidelines.
  2. Fork the repo on GitHub
  3. Clone the project to your own machine
  4. Commit changes to your own branch
  5. Push your work back up to your fork
  6. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

๐ŸŒŽ Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

๐Ÿ“ฐ Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week โ€” and usually a 5-minute read.

๐Ÿ“† Office Hours

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you canโ€™t find anywhere else. It's FREE for everyone!

License

License

Preamble to the Apache License, Version 2.0

Complete license is available in the LICENSE file.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright ยฉ 2017-2024 Cloud Posse, LLC

README footer

Beacon

terraform-aws-documentdb-cluster's People

Contributors

adubeniuk avatar aknysh avatar brunordias avatar cloudpossebot avatar dylanbannon avatar froks avatar gowiem avatar haidargit avatar kevcube avatar korenyoni avatar krsh-off avatar max-lobur avatar maximmi avatar michael-careplanner avatar osterman avatar petur avatar rabihaggle avatar rasta-rocket avatar renovate[bot] avatar sergirf avatar sherifkayad avatar tomasbackman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-aws-documentdb-cluster's Issues

Issue with count for allowed_security_groups

Hello again, I'm back. I've run into an issue with allowed_security_groups, which I assume would also affect allowed_cidr_blocks

The issue is related to passing list variables around, as seen here: hashicorp/terraform#13103

As I've been tying the pieces of a large stack together, I finally had my bastion host all set up and attempted to add the SG to the allowed_security_groups declaration:

allowed_security_groups = ["${module.bastion.bastion_host_security_group}"]

Which gives me this error:

* module.documentdb_cluster.aws_security_group_rule.ingress_security_groups: aws_security_group_rule.ingress_security_groups: value of 'count' cannot be computed

This seems to be because the length(var.allowed_security_groups) is not seeing a list, due to aforementioned TF bug with list variables. From what I can tell it's that TF doesn't know what to do with "dynamic" length lists. I think y'all even have a writeup on it....here

I tried several things, as you can see in this godawful commit history. I landed on just using an allowed_security_groups_count variable, which isn't ideal but did allow me to finally create the stack. I was hoping y'all had some further expertise that might lead to a better solution, and if not I can modify my solution to better match your current config and open a PR.

Thanks again for making this!

readme incorrect

Forgive me for opening an issue, but it seems like you use some doc generation tool and I'm not sure what all would need to be touched to update the readme.

admin_user and admin_password are listed in the docs, but the module uses master_username and master_password. Small thing and simple fix :)

Global cluster or not?

Could you please confirm if this repo supports to create DocumentDB Global cluster or not?

I'd like to use it to create a global cluster with replicas in other 2 regions.

updates.

reviewed the codes and run the example, I can confirm this repo is still regional cluster, not global cluster.

This global cluster feature was only announced recently in June.

https://aws.amazon.com/about-aws/whats-new/2021/06/announcing-global-clusters-for-amazon-documentdb-with-mongodb-compatibility/

Maybe its aws provider doesn't support this feature yet.

Error in ouputs sensitive values with terraform v0.15.0

Hi, with terraform v0.15.0 it give the next error:

Error: Output refers to sensitive values
โ”‚ 
โ”‚   on .terraform/modules/documentdb_cluster/outputs.tf line 1:
โ”‚    1: output "master_username" {
โ”‚ 
โ”‚ Expressions used in outputs can only refer to sensitive values if the sensitive attribute is true.

module version: 0.13.0

Thanks!

allow optional / no egress security rule

Describe the Feature

I would like the option to disable the egress security rule deployed by the module

resource "aws_security_group_rule" "egress" {
  count             = module.this.enabled ? 1 : 0
  type              = "egress"
  description       = "Allow all egress traffic"
  from_port         = 0
  to_port           = 0
  protocol          = "-1"
  cidr_blocks       = ["0.0.0.0/0"]
  security_group_id = join("", aws_security_group.default.*.id)
}

Expected Behavior

Allow to disable (optional) to remove the security group. The outbound rule isn't required as security groups are statefull and the document db itself won't open a connection to the outside.

Use Case

Scanning the file with TF_SEC throws an error

Problem 1

  [AWS007][WARNING] Resource 'module.docdb_cluster:aws_security_group_rule.egress' defines a fully open egress security group rule.

      13 |   from_port         = 0
      14 |   to_port           = 0
      15 |   protocol          = "-1"
      16 |   cidr_blocks       = ["0.0.0.0/0"]
      17 |   security_group_id = join("", aws_security_group.default.*.id)
      18 | }
      19 | 

  See https://tfsec.dev/docs/aws/AWS007/ for more information.

  disk i/o             114.710197ms
  parsing HCL          576.897ยตs
  evaluating values    94.868063ms
  running checks       996.996ยตs
  files loaded         23

1 potential problems detected.

Describe Ideal Solution

Allow to disable (optional) to remove the security group. The outbound rule isn't required as security groups are statefull and the document db itself won't open a connection to the outside.

Error: Invalid count argument for random_password resource

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

After upgrading to version 0.15.0, terraform plan fails with the error "Invalid count argument" when planning on an empty configuration (no existing resources) if the variable master_password is set from a random_password resource.

Expected Behavior

The configuration should be planned.

Steps to Reproduce

This is a minimal configuration to reproduce:

resource "random_password" "documentdb" {
  length  = 22
  special = false
}

module "documentdb_cluster" {
  source  = "cloudposse/documentdb-cluster/aws"
  version = "0.15.0"

  master_password = random_password.documentdb.result

  name = "foo"
  vpc_id = ""
  subnet_ids = [""]
}

Run terraform plan to get the error.

Screenshots

โ•ท
โ”‚ Error: Invalid count argument
โ”‚ 
โ”‚   on .terraform/modules/documentdb_cluster/main.tf line 43, in resource "random_password" "password":
โ”‚   43:   count   = module.this.enabled && var.master_password != "" ? 0 : 1
โ”‚ 
โ”‚ The "count" value depends on resource attributes that cannot be determined
โ”‚ until apply, so Terraform cannot predict how many instances will be
โ”‚ created. To work around this, use the -target argument to first apply only
โ”‚ the resources that the count depends on.
โ•ต

Environment (please complete the following information):

  • OS: Linux
  • Terraform version: 1.1.8
  • Version: 0.15.0

Additional Context

The separate random_password resource is there because this code was written against version 0.14.

The easy workaround for this would be to remove the random_password resource and use the one provided by the module, but that doesn't work for our purposes because the module doesn't return the generated password (in our case, it gets stored in Secrets Manager).

Providing the password as an output would be the easiest fix for this, but another way would be to add a separate generate_password boolean parameter.

Aside - it looks like there may be another bug in the count condition:

count   = module.this.enabled && var.master_password != "" ? 0 : 1

If module.this.enabled is false, then count is always set to 1 - this should surely be the other way around?

Add possibility for adding several security groups

Describe the Feature

Currently there is no way to have several security groups on the created cluster.
I would like to be able to add extra security groups, not only as rules in the main security group but as separate rules.

Expected Behavior

The resource for security group can take a list, so the current only security group that is added to the cluster should bascially be made into a merged list of that and an input list variable with more ids).

So solution is an optional list variable with security groups, so that the resource can be setup/modified both with and without those extra groups.

Use Case

For example Glue requires that both the job and the database have the same security group (that have ALL traffic open attached to both). So more security groups need to be added. Now we have to add manually, and they get removed with each terraform apply and need to be readded, quite annoying..

Argument "storage_type" for aws_docdb_cluster is not expected with AWS provider < 5.29.0, Module Version 0.25.0

Describe the Bug

Module version 0.25.0 allows for "storage_type" variable for aws_docdb_cluster. This is not supported by lower AWS providers. Version 5.29.0 required for this. https://registry.terraform.io/providers/hashicorp/aws/5.29.0/docs/resources/docdb_cluster

Fix requirements: https://github.com/cloudposse/terraform-aws-documentdb-cluster/blob/main/versions.tf#L7 or make optional.

Validation failed: modules/main
โ•ท
โ”‚ Error: Unsupported argument
โ”‚ 
โ”‚   on .terraform/modules/documentdb_cluster/main.tf line 72, in resource "aws_docdb_cluster" "default":
โ”‚   72:   storage_type                    = var.storage_type
โ”‚ 
โ”‚ An argument named "storage_type" is not expected here.

Expected Behavior

Allows for plan with lower AWS versions error

Steps to Reproduce

Pin an AWS version lower than 5.29.0 and attempt to plan with latest module (0.25.0).

Screenshots

No response

Environment

No response

Additional Context

No response

Invalid count argument when password provide using random_password

Describe the Bug

โ•ท
โ”‚ Error: Invalid count argument
โ”‚
โ”‚ on .terraform/modules/ac2ui_documentdb_cluster/main.tf line 43, in resource "random_password" "password":
โ”‚ 43: count = module.this.enabled && var.master_password != "" ? 0 : 1
โ”‚
โ”‚ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict
โ”‚ how many instances will be created. To work around this, use the -target argument to first apply only the resources
โ”‚ that the count depends on.

Expected Behavior

Terraform plan should be applied without this issue.

Steps to Reproduce

set password to the value of an ssm param, for example:

resource "random_password" "ac2ui_master_password" {
  length  = 8
  special = false
}
master_password  =  random_password.master_password.result

Screenshots

No response

Environment

No response

Additional Context

No response

Allow passing existing subnet-group

Is it possible to allow existing subnet-group to be passed? I think its not much of change just some more check.
change in resource "aws_docdb_cluster" "default" {:
db_subnet_group_name = join("", aws_docdb_subnet_group.default.*.name)
to
db_subnet_group_name = var.db_subnet_group ? va.db_subnet_group: join("", aws_docdb_subnet_group.default.*.name)

and
change in resource "aws_docdb_subnet_group" "default" {
count = var.enabled ? 1 : 0
to
count = var.enabled && !var.db_subnet_group? 1 : 0

I would make a pull request but I still have no idea how. So just suggestions.

Add support for copy_tags_to_snapshot in aws_docdb_cluster_instance resource

Describe the Feature

Please add support for copy_tags_to_snapshot argument in aws_docdb_cluster_instance resource so that tags are copied to snapshots created for documentdb clusters

Expected Behavior

There is no support for copy_tags_to_snapshot argument in aws_docdb_cluster_instance resource which was added by AWS in version 5.21.0.

Use Case

The reason why we need this is because, snapshots generated for document_db clusters are untagged which in our case needs to be same as the ones provided on cluster_instance

Describe Ideal Solution

Update the resource as follows:

resource "aws_docdb_cluster_instance" "default" {
  count                        = module.this.enabled ? var.cluster_size : 0
  identifier                   = "${module.this.id}-${count.index + 1}"
  cluster_identifier           = join("", aws_docdb_cluster.default[*].id)
  apply_immediately            = var.apply_immediately
  preferred_maintenance_window = var.preferred_maintenance_window
  instance_class               = var.instance_class
  engine                       = var.engine
  auto_minor_version_upgrade   = var.auto_minor_version_upgrade
  enable_performance_insights  = var.enable_performance_insights
  ca_cert_identifier           = var.ca_cert_identifier
  tags                         = module.this.tags
  copy_tags_to_snapshot =  true
}

Alternatives Considered

No response

Additional Context

No response

random password resource still generated even if module is disabled

Describe the Bug

Hi.
I encountered a bug where the random_password resource is still generated even if the module was disabled

I opened a PR for a fix and would appreciate an approval:
#64

Expected Behavior

Password to not generate if module is disabled

Steps to Reproduce

set var.enabled to false

Screenshots

No response

Environment

No response

Additional Context

No response

allowed_security_groups not working as intended

Describe the Bug

The allowed_security_groups does not allow passing an SG to allow specific traffic from specific IPs. E.g. for dev testing in a dev environment.

The problem is that the allowed_security_group id's are being attached as a source for the default security group, which makes little to no sense. These ID's should be passed to aws_docdb_cluster directly:

E.g.

  vpc_security_group_ids          = concat(join("", aws_security_group.default[*].id)], var.allowed_security_groups)

Expected Behavior

I expect that should I pass an allowed_security_group id that the rules in that security group would be applied.

Steps to Reproduce

Simply pass a security group that allows ingress from an IP range and test, it wont work.

Screenshots

No response

Environment

No response

Additional Context

No response

Error: Invalid count argument when password comes from an aws_ssm_parameter resource

Describe the Bug

โ”‚ Error: Invalid count argument
โ”‚ 
โ”‚   on .terraform/modules/cms.db/main.tf line 54, in resource "random_password" "password":
โ”‚   54:   count   = module.this.enabled && var.master_password == "" ? 1 : 0
โ”‚ 
โ”‚ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on.

Expected Behavior

Terraform plan can be applied without resource targeting.

Steps to Reproduce

set password to the value of an ssm param, for example:

master_password  = aws_ssm_parameter.db_password.value

Screenshots

No response

Environment

Terraform 1.5

Additional Context

No response

`preferred_maintenance_window` from the variables isn't propagated to the `docdb_cluster_instance` resources

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Using the module and specificying a certain preferred_maintenance_window, that's set only on the cluster level and not the cluster instances. That should change to match.

Expected Behavior

The preferrred maintenance window should be the same on the cluster and its instances to give the user control when the database can be patched / changed.

Steps to Reproduce

N.A.

Screenshots

N.A.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: WSL

Additional Context

N.A.

Issue with attributes

According to the documentation, the 'attributes' input is not required.
Why am I getting this error?

Error: Invalid function argument

  on .terraform/modules/documentdb-cluster.label/main.tf line 80, in locals:
  80:     attributes  = "${lower(join(local.delimiter, local.attributes))}"
    |----------------
    | local.attributes is tuple with 1 element

Invalid value for "lists" parameter: element 0: string required.

Implement deletion_protection option

An official aws_docdb_cluster resource supports deletion_protection option, while this module not. It would be good to add this attribute.

Expected Behavior

The module accepts deletion_protection boolean parameter and toggles the option accordingly.

Use Case

It would be good to have an additional guardrail for a production environment.

enabled_cloudwatch_logs_exports description is incorrect

Describe the Bug

The input variable enabled_cloudwatch_logs_exports description is incorrect compared to the the Terraform AWS provider version 3.47.0. Resource: aws_docdb_cluster enabled_cloudwatch_logs_exports states:

enabled_cloudwatch_logs_exports - (Optional) List of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: audit, profiler.

The resulting error is:

Error: expected enabled_cloudwatch_logs_exports.1 to be one of [audit profiler], got error

  on .terraform/modules/documentdb_cluster/main.tf line 63, in resource "aws_docdb_cluster" "default":
  63:   enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports

Expected Behavior

Variable documentation should not contradict the AWS provider's capabilities.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Set module input to enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"]
  2. Run 'terraform plan'
  3. See error

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • Module Version: 0.13.0
$ terraform version
Terraform v0.13.7
+ provider registry.terraform.io/hashicorp/aws v3.46.0
+ provider registry.terraform.io/hashicorp/external v2.1.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

terraform
examples/complete/main.tf
  • cloudposse/dynamic-subnets/aws 2.3.0
  • cloudposse/vpc/aws 2.1.0
examples/complete/versions.tf
  • aws >= 2.0
  • local >= 1.3
  • hashicorp/terraform >= 1.3
main.tf
  • cloudposse/route53-cluster-hostname/aws 0.12.2
  • cloudposse/route53-cluster-hostname/aws 0.12.2
  • cloudposse/ssm-parameter-store/aws 0.11.0
versions.tf
  • aws >= 2.0
  • local >= 1.3
  • random >= 1.0
  • hashicorp/terraform >= 1.3

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.