Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only set monitoring_role_arn if monitoring_interval > 0 #32

Merged
merged 4 commits into from
Feb 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Terraform module to create an Amazon Web Services (AWS) PostgreSQL Relational

## Usage

```javascript
```hcl
module "postgresql_rds" {
source = "github.com/azavea/terraform-aws-postgresql-rds"
vpc_id = "vpc-20f74844"
Expand Down Expand Up @@ -40,6 +40,26 @@ module "postgresql_rds" {
}
```

### Note about Enhanced Monitoring Support
rbreslow marked this conversation as resolved.
Show resolved Hide resolved

If the `monitoring_interval` passed as an input to this module is `0`, an empty `monitoring_role_arn` value will be threaded into the `aws_db_instance` resource.

This is because, if a value for `monitoring_role_arn` is threaded into an `aws_db_instance`, along with a `monitoring_interval` of `0`, the following error will occur:

```bash
InvalidParameterCombination: You must specify a MonitoringInterval value other than 0 when you specify a MonitoringRoleARN value.
```

This behavior doesn't match the information in the [Terraform docs](https://www.terraform.io/docs/providers/aws/r/db_instance.html#monitoring_interval) for the resource. Both the `monitoring_role_arn` and `monitoring_interval` arguments to `aws_db_instance` should be optional, and setting a `monitoring_interval` to `0` should be enough to disable enhanced monitoring, irrespective of the value of `monitoring_role_arn`.

See the following open issues for the Terraform AWS provider:

https://github.com/terraform-providers/terraform-provider-aws/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+MonitoringInterval+

See a good explaination of what's causing this here:

https://github.com/terraform-providers/terraform-provider-aws/issues/315#issuecomment-437404518

## Variables

- `vpc_id` - ID of VPC meant to house database
Expand Down Expand Up @@ -92,4 +112,3 @@ module "postgresql_rds" {
- `endpoint` - Public DNS name and port separated by a `:`
- `hosted_zone_id` - The zone id for the autogenerated DNS name given in `endpoint`.
Use this when creating a short-name DNS [alias](https://www.terraform.io/docs/providers/aws/r/route53_record.html#alias-record) for the `endpoint`

2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ resource "aws_db_instance" "postgresql" {
parameter_group_name = "${var.parameter_group}"
storage_encrypted = "${var.storage_encrypted}"
monitoring_interval = "${var.monitoring_interval}"
monitoring_role_arn = "${aws_iam_role.enhanced_monitoring.arn}"
monitoring_role_arn = "${var.monitoring_interval > 0 ? aws_iam_role.enhanced_monitoring.arn : ""}"

tags {
Name = "DatabaseServer"
Expand Down