Skip to content

Commit

Permalink
fix(vpcep): remove policy_document field (#5518)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruwenqiang123 authored Sep 10, 2024
1 parent 2a2e310 commit 35edbe7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
5 changes: 0 additions & 5 deletions docs/resources/vpcep_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ The following arguments are supported:
-> Please refer to [official document](https://support.huaweicloud.com/intl/en-us/usermanual-iam/iam_01_0017.html) for
the data structure rules of the policy. Just pay attention to the fields `Effect`, `Action` and `Resource`.

* `policy_document` - (Optional, String) Specifies the IAM 5.0 policies. This parameter is only available when
`enable_policy` of the VPC endpoint services is set to **true**. Defaults to full access.
The VPC endpoint services of Object Storage Service (OBS) and Scalable File Service (SFS) do not support configuring
this parameter.

* `tags` - (Optional, Map) The key/value pairs to associate with the VPC endpoint.

## Attribute Reference
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
github.com/chnsz/golangsdk v0.0.0-20240904093004-8405480f47e9
github.com/chnsz/golangsdk v0.0.0-20240906025604-372d490f10dc
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chnsz/golangsdk v0.0.0-20240904093004-8405480f47e9 h1:TnwaufPiSeAii/Dp8QiWczguUT/1XTwg2FMnDtNMuvk=
github.com/chnsz/golangsdk v0.0.0-20240904093004-8405480f47e9/go.mod h1:Erm4hDWxXgAdbkG3+hhJFgRzEL1TvvcroWzw2Gax4uI=
github.com/chnsz/golangsdk v0.0.0-20240906025604-372d490f10dc h1:i7vU0KgfWXtnrFc93qe57Jbs10OS3n5rUwmvabIulcI=
github.com/chnsz/golangsdk v0.0.0-20240906025604-372d490f10dc/go.mod h1:Erm4hDWxXgAdbkG3+hhJFgRzEL1TvvcroWzw2Gax4uI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ func ResourceVPCEndpoint() *schema.Resource {
return equal
},
},
// Field `policy_document` was not tested due to insufficient testing conditions.
// Deprecated
// The field type provided in the API document is different from the actual returned type.
// As a result, an error is reported when the resource is imported.
"policy_document": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: utils.SchemaDesc(
`Specifies the endpoint policy information`, utils.SchemaDescInput{Deprecated: true},
),
},
"tags": common.TagsSchema(),
"status": {
Expand Down Expand Up @@ -177,7 +182,6 @@ func resourceVPCEndpointCreate(ctx context.Context, d *schema.ResourceData, meta
EnableWhitelist: utils.Bool(enableACL),
Tags: utils.ExpandResourceTags(d.Get("tags").(map[string]interface{})),
PolicyStatement: policyStatementOpts,
PolicyDocument: d.Get("policy_document").(string),
}

routeTables := d.Get("routetables").(*schema.Set)
Expand Down Expand Up @@ -250,7 +254,6 @@ func resourceVPCEndpointRead(_ context.Context, d *schema.ResourceData, meta int
d.Set("packet_id", ep.MarkerID),
d.Set("tags", utils.TagsToMap(ep.Tags)),
d.Set("policy_statement", string(policyStatements)),
d.Set("policy_document", ep.PolicyDocument),
)

// if the VPC endpoint type is interface, the field is used and need to be set
Expand Down Expand Up @@ -304,15 +307,14 @@ func resourceVPCEndpointUpdate(ctx context.Context, d *schema.ResourceData, meta
return diag.Errorf("error updating tags of VPC endpoint %s: %s", d.Id(), tagErr)
}
}
if d.HasChanges("policy_statement", "policy_document") {
if d.HasChanges("policy_statement") {
policyStatementOpts, err := buildPolicyStatement(d)
if err != nil {
return diag.FromErr(err)
}

updatePolicyOpts := endpoints.UpdatePolicyOpts{
PolicyStatement: policyStatementOpts,
PolicyDocument: d.Get("policy_document").(string),
}
_, err = endpoints.UpdatePolicy(vpcepClient, updatePolicyOpts, d.Id()).Extract()
if err != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github.com/apparentlymart/go-cidr/cidr
# github.com/apparentlymart/go-textseg/v13 v13.0.0
## explicit; go 1.16
github.com/apparentlymart/go-textseg/v13/textseg
# github.com/chnsz/golangsdk v0.0.0-20240904093004-8405480f47e9
# github.com/chnsz/golangsdk v0.0.0-20240906025604-372d490f10dc
## explicit; go 1.14
github.com/chnsz/golangsdk
github.com/chnsz/golangsdk/auth
Expand Down

0 comments on commit 35edbe7

Please sign in to comment.