Azure / Azure/terraform

Error in Postgres module

Open
#29 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HCL
Stars
925
Forks
930
Avg merge
4d 15h
Merged PRs (30d)
5

Description

The [postgres](https://registry.terraform.io/modules/sjones-sot/database-for-postgres/azurerm/0.2.0) module behaves differently in terraform 0.11.14 and 0.12. Error and input posted below. This issue is peeled off of https://github.com/Azure/terraform/issues/16

**Error**
```
Error: Missing resource instance key

on .terraform\modules\demo_db\sjones-sot-terraform-azurerm-database-for-postgres-59b1e13\postgres.tf line 10, in resource "azurerm_postgresql_server" "postgresql_server": 10: resource_group_name = "${var.resource_group_name == "" ? azurerm_resource_group.resource_group.name : var.resource_group_name}"
Because azurerm_resource_group.resource_group has "count" set, its attributes
must be accessed on specific instances.

For example, to correlate with indices of a referring resource, use:
azurerm_resource_group.resource_group[count.index]

```

**Input**
```
module "demo_db" {
source = "sjones-sot/database-for-postgres/azurerm"
resource_group_name = "${var.az_rg_name}"
location = "${var.az_region_default}"
service_name = "testdb"
db_admin_password = "${var.az_fake_password}"
sku_compute_units = 1
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the supplied module input with Terraform 0.11.14 and 0.12, then inspect .terraform/modules/demo_db/.../postgres.tf at line 10 and the resource_group definition that sets count. Done means the Postgres module no longer produces the reported missing resource instance key error under the supported Terraform version.

Written by the indexing model from the issue text.

Assessment

Tech stack
terraform
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.