-
Notifications
You must be signed in to change notification settings - Fork 99
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Module version
1.9.0
Relevant provider source code
resource implementation:
https://github.com/microsoft/terraform-provider-power-platform/blob/main/internal/powerplatform/services/data_record/resource_data_record.go
func (r *DataRecordResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "The Power Platform Data Record Resource allows the management of configuration records that are stored in Dataverse as records. This resource is not recommended for managing business data or other data that may be changed by Dataverse users in the context of normal business activities.",
MarkdownDescription: "The Power Platform Data Record Resource allows the management of configuration records that are stored in Dataverse as records. This resource is not recommended for managing business data or other data that may be changed by Dataverse users in the context of normal business activities.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
MarkdownDescription: "Unique id (guid)",
Description: "Unique id (guid)",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"environment_id": schema.StringAttribute{
Description: "Id of the Dynamics 365 environment",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"table_logical_name": schema.StringAttribute{
Description: "Logical name of the data record table",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"columns": schema.DynamicAttribute{
Description: "Columns of the data record table",
Required: true,
},
},
}
}Terraform Configuration Files
terraform {
required_providers {
powerplatform = {
source = "microsoft/power-platform"
}
}
}
provider "powerplatform" {
use_cli = true
}
resource "powerplatform_environment" "data_record_example_env" {
display_name = "powerplatform_data_record_example"
location = "europe"
environment_type = "Sandbox"
dataverse = {
language_code = "1033"
currency_code = "USD"
security_group_id = "00000000-0000-0000-0000-000000000000"
}
}
resource "powerplatform_data_record" "account" {
environment_id = powerplatform_environment.data_record_example_env.id
table_logical_name = "account"
columns = {
name = "Contoso"
contact_customer_accounts = toset([
{
table_logical_name = "contact",
data_record_id = powerplatform_data_record.contact.id
}
])
}
}
resource "powerplatform_data_record" "contact" {
environment_id = powerplatform_environment.data_record_example_env.id
table_logical_name = "contact"
columns = {
firstname = "John"
lastname = "Doe"
}
}
Debug Output
apply.log and plan.log can be found here: https://gist.github.com/mawasile/f61ce8807e1011983b9089f97dba542b
Expected Behavior
We use dynamic type for "columns" attribute and inside that we also allow to create collection of values. if that collection is a list everything is working fine but when we use toset() then in terraform plan we get in-place update which is incorrect as nothing had changed. Just by removing toset in contact_customer_accounts from the above example, fixes that issue.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# powerplatform_data_record.account will be updated in-place
~ resource "powerplatform_data_record" "account" {
id = "830dc891-9b28-ef11-840a-000d3ab60f37"
# (3 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Actual Behavior
toset should not generate dirty state when used in dynamic attribute
Steps to Reproduce
- have a terraform resource with dynamic attribute with a set attribute inside that dynamic type
terraform applyterraform plan=> plan is not empty
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working