hashicorp / hashicorp/terraform-plugin-sdk

provider-sdk: unknown optional+computed set produces no diff value during plan

Open
#174 1 comment 0 reactions 0 assignees View on GitHub
bug subsystem/types terraform-plugin-framework
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

### Terraform Version

```
Terraform v0.12.7
```

### Terraform Configuration Files

```hcl
resource "random_string" "temp_password2" {
length = 16
special = true
min_upper = 1
min_lower = 1
min_special = 1
}

variable "users" {
default = {
smccartney_test1 = { superuser = ["dv1", "us1"] }
smccartney_test2 = { superuser = ["dv1", "us2"] }
# smccartney_test3 = { superuser = ["dv1", "us2"] }
}
}

resource "azuread_user" "users" {
for_each = var.users
display_name = each.key
user_principal_name = format("%s%s", each.key, "@dummy.com")
password = random_string.temp_password2.result
}

resource "azuread_group" "SuperUsers_XXX" {
name = "SuperUsers_US2"
members = [
for user in azuread_user.users:
user.object_id
if contains(lookup(var.users[user.mail_nickname], "superuser", []), "us2")
]
}
```

### Debug Output

N/A

### Crash Output

N/A

### Expected Behavior

Adding a new user to AAD will also update the group member list as required.

### Actual Behavior

On the first run, users & groups are created as expected, but on subsequent work (i.e. adding a new user), the new user is created on the first pass & the set of members will be updated on the second pass. (members list can't be calculated until the azuread_user is created & the UUID known)

### Steps to Reproduce
1. `az cloud set --name AzureCloud`
2. `az login`
3. `terraform init`
4. `terraform apply` - users created, group created, users added to group: https://gist.github.com/simonmcc/ef1e01d34116f11f607a62d5c3df7ce7
5. Uncomment `smccartney_test3 = { superuser = ["dv1", "us2"] }`
6. `terraform apply` - user gets created, but not added to group: https://gist.github.com/simonmcc/cbe2b879cbd6e6d428e879eb0e3eb61a
7. `terraform apply` - group gets updated, adding `smccartney_test3`'s UUID: https://gist.github.com/simonmcc/726ef4a939e555019a6e942342340f43

### References
- https://discuss.hashicorp.com/t/for-each-for-not-tracking-resource-dependency-0-12-7/2602

Contributor guide

Open the contributing guide

Research direction

Start with the Terraform v0.12.7 configuration and the listed terraform init/apply reproduction steps, comparing the first and second plans. The issue is done when adding a user updates the group's members during the same apply rather than requiring a second apply.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, terraform
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.