diff --git a/internal/service/fms/policy.go b/internal/service/fms/policy.go index 3ec1b780129..fda3629c9fd 100644 --- a/internal/service/fms/policy.go +++ b/internal/service/fms/policy.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/create" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" @@ -21,6 +22,10 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) +const ( + ResNamePolicy = "Policy" +) + // @SDKResource("aws_fms_policy", name="Policy") // @Tags(identifierAttribute="arn") func ResourcePolicy() *schema.Resource { @@ -338,20 +343,20 @@ func resourcePolicyFlattenPolicy(d *schema.ResourceData, resp *fms.GetPolicyOutp d.Set("name", resp.Policy.PolicyName) d.Set("exclude_resource_tags", resp.Policy.ExcludeResourceTags) if err := d.Set("exclude_map", flattenPolicyMap(resp.Policy.ExcludeMap)); err != nil { - return err + return create.SettingError(names.FMS, ResNamePolicy, d.Id(), "exclude_resource_tags", err) } if err := d.Set("include_map", flattenPolicyMap(resp.Policy.IncludeMap)); err != nil { - return err + return create.SettingError(names.FMS, ResNamePolicy, d.Id(), "include_map", err) } d.Set("remediation_enabled", resp.Policy.RemediationEnabled) if err := d.Set("resource_type_list", resp.Policy.ResourceTypeList); err != nil { - return err + return create.SettingError(names.FMS, ResNamePolicy, d.Id(), "remediation_enabled", err) } d.Set("delete_unused_fm_managed_resources", resp.Policy.DeleteUnusedFMManagedResources) d.Set("resource_type", resp.Policy.ResourceType) d.Set("policy_update_token", resp.Policy.PolicyUpdateToken) if err := d.Set("resource_tags", flattenResourceTags(resp.Policy.ResourceTags)); err != nil { - return err + return create.SettingError(names.FMS, ResNamePolicy, d.Id(), "policy_update_token", err) } securityServicePolicy := []map[string]interface{}{{ @@ -361,7 +366,7 @@ func resourcePolicyFlattenPolicy(d *schema.ResourceData, resp *fms.GetPolicyOutp }} if err := d.Set("security_service_policy_data", securityServicePolicy); err != nil { - return err + return create.SettingError(names.FMS, ResNamePolicy, d.Id(), "security_service_policy_data", err) } return nil