dubiety / terraform-aws-elasticsearch-cloudwatch-sns-alarms

terraform module that configures important alarms for AWS elasticsearch and send them to SNS topic
Apache License 2.0
30 stars 44 forks source link

Fix #11, make create_sns_topic use consistent #14

Closed timcosta closed 3 years ago

timcosta commented 3 years ago

Currently running a plan or apply using this module when the SNS topic hasnt been created but you want to create it outside of this module will fail.

╷
│ Error: Invalid count argument
│
│   on .terraform/modules/es_cloudwatch_alarms/main.tf line 11, in resource "aws_sns_topic" "default":
│   11:   count = var.sns_topic != "" && var.create_sns_topic == true ? 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.

This is because var.sns_topic is a pointer to a yet-to-be-determined string that depends on the creation of the sns topic completing. Half of the places create_sns_topic was used had the empty string check and the other half didnt, so I removed it which allows this module to be planned/applied at the same time as an SNS topic, and it makes internal usage of create_sns_topic consistent.

dubiety commented 3 years ago

LGTM. Thank you for sending th pull request!

timcosta commented 3 years ago

Thank you for merging and releasing this and #13 so quickly! It's very appreciated!