Skip to content

Commit ad62278

Browse files
authored
Fix restriction_policy_resource_id format for private locations (#3310)
Fix restriction_policy_resource_id format for private locations The computed field was generating the wrong format, causing restriction policies to appear as "Unrestricted" in the UI despite being created successfully in Terraform. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: matt.cameron <matt.cameron@datadoghq.com>
1 parent e69224d commit ad62278

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

datadog/fwprovider/resource_datadog_synthetics_private_location.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ func (r *syntheticsPrivateLocationResource) updateState(ctx context.Context, sta
268268
state.Description = types.StringValue(resp.GetDescription())
269269
state.Name = types.StringValue(resp.GetName())
270270
state.Tags, _ = types.ListValueFrom(ctx, types.StringType, resp.Tags)
271-
state.RestrictionPolicyResourceId = types.StringValue(fmt.Sprintf("synthetics-private-location%s", resp.GetId()[2:]))
271+
// Convert the private location ID to the format expected by restriction policies
272+
// The format should be: synthetics-private-location:pl:xxx (keep the pl: prefix)
273+
privateLocationId := resp.GetId()
274+
restrictionPolicyId := fmt.Sprintf("synthetics-private-location:%s", privateLocationId)
275+
state.RestrictionPolicyResourceId = types.StringValue(restrictionPolicyId)
272276

273277
if metadata, ok := resp.GetMetadataOk(); ok {
274278
if restrictedRoles, ok := metadata.GetRestrictedRolesOk(); ok {

datadog/tests/resource_datadog_synthetics_private_location_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func createSyntheticsPrivateLocationStep(ctx context.Context, accProvider *fwpro
102102
"datadog_synthetics_private_location.foo", "config"),
103103
resource.TestCheckResourceAttrSet(
104104
"datadog_synthetics_private_location.foo", "id"),
105-
checkRessourceAttributeRegex("datadog_synthetics_private_location.foo", "restriction_policy_resource_id", "synthetics-private-location:.*"),
105+
checkRessourceAttributeRegex("datadog_synthetics_private_location.foo", "restriction_policy_resource_id", "synthetics-private-location:pl:.*"),
106106
),
107107
}
108108
}
@@ -141,7 +141,7 @@ func updateSyntheticsPrivateLocationStep(ctx context.Context, accProvider *fwpro
141141
"datadog_synthetics_private_location.foo", "config"),
142142
resource.TestCheckResourceAttrSet(
143143
"datadog_synthetics_private_location.foo", "id"),
144-
checkRessourceAttributeRegex("datadog_synthetics_private_location.foo", "restriction_policy_resource_id", "synthetics-private-location:.*"),
144+
checkRessourceAttributeRegex("datadog_synthetics_private_location.foo", "restriction_policy_resource_id", "synthetics-private-location:pl:.*"),
145145
),
146146
}
147147
}

0 commit comments

Comments
 (0)