Skip to content

Commit af9c3f1

Browse files
committed
ec2: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
1 parent 5f44bc7 commit af9c3f1

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

internal/service/ec2/vpc_endpoint.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
2121
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2222
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure"
23-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
2423
"github.com/hashicorp/terraform-provider-aws/internal/conns"
2524
"github.com/hashicorp/terraform-provider-aws/internal/enum"
2625
"github.com/hashicorp/terraform-provider-aws/internal/errs"
2726
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
2827
"github.com/hashicorp/terraform-provider-aws/internal/flex"
28+
"github.com/hashicorp/terraform-provider-aws/internal/sdkv2"
2929
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
3030
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
3131
"github.com/hashicorp/terraform-provider-aws/internal/verify"
@@ -117,18 +117,7 @@ func resourceVPCEndpoint() *schema.Resource {
117117
Type: schema.TypeString,
118118
Computed: true,
119119
},
120-
names.AttrPolicy: {
121-
Type: schema.TypeString,
122-
Optional: true,
123-
Computed: true,
124-
ValidateFunc: validation.StringIsJSON,
125-
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
126-
DiffSuppressOnRefresh: true,
127-
StateFunc: func(v any) string {
128-
json, _ := structure.NormalizeJsonString(v)
129-
return json
130-
},
131-
},
120+
names.AttrPolicy: sdkv2.IAMPolicyDocumentSchemaOptionalComputed(),
132121
"prefix_list_id": {
133122
Type: schema.TypeString,
134123
Computed: true,

internal/service/ec2/vpc_endpoint_policy.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1616
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure"
17-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1817
"github.com/hashicorp/terraform-provider-aws/internal/conns"
1918
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
19+
"github.com/hashicorp/terraform-provider-aws/internal/sdkv2"
2020
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
2121
"github.com/hashicorp/terraform-provider-aws/internal/verify"
2222
"github.com/hashicorp/terraform-provider-aws/names"
@@ -34,18 +34,7 @@ func resourceVPCEndpointPolicy() *schema.Resource {
3434
},
3535

3636
Schema: map[string]*schema.Schema{
37-
names.AttrPolicy: {
38-
Type: schema.TypeString,
39-
Optional: true,
40-
Computed: true,
41-
ValidateFunc: validation.StringIsJSON,
42-
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
43-
DiffSuppressOnRefresh: true,
44-
StateFunc: func(v any) string {
45-
json, _ := structure.NormalizeJsonString(v)
46-
return json
47-
},
48-
},
37+
names.AttrPolicy: sdkv2.IAMPolicyDocumentSchemaOptionalComputed(),
4938
names.AttrVPCEndpointID: {
5039
Type: schema.TypeString,
5140
Required: true,

internal/service/ec2/vpc_endpoint_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1414
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1515
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
16+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
1617
"github.com/hashicorp/terraform-plugin-testing/terraform"
1718
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
1819
"github.com/hashicorp/terraform-provider-aws/internal/conns"
@@ -440,6 +441,11 @@ func TestAccVPCEndpoint_gatewayPolicy(t *testing.T) {
440441
Check: resource.ComposeTestCheckFunc(
441442
testAccCheckVPCEndpointExists(ctx, resourceName, &endpoint),
442443
),
444+
ConfigPlanChecks: resource.ConfigPlanChecks{
445+
PreApply: []plancheck.PlanCheck{
446+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate),
447+
},
448+
},
443449
},
444450
{
445451
ResourceName: resourceName,
@@ -451,6 +457,11 @@ func TestAccVPCEndpoint_gatewayPolicy(t *testing.T) {
451457
Check: resource.ComposeTestCheckFunc(
452458
testAccCheckVPCEndpointExists(ctx, resourceName, &endpoint),
453459
),
460+
ConfigPlanChecks: resource.ConfigPlanChecks{
461+
PreApply: []plancheck.PlanCheck{
462+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate),
463+
},
464+
},
454465
},
455466
},
456467
})
@@ -473,10 +484,22 @@ func TestAccVPCEndpoint_ignoreEquivalent(t *testing.T) {
473484
Check: resource.ComposeTestCheckFunc(
474485
testAccCheckVPCEndpointExists(ctx, resourceName, &endpoint),
475486
),
487+
ConfigPlanChecks: resource.ConfigPlanChecks{
488+
PreApply: []plancheck.PlanCheck{
489+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate),
490+
},
491+
},
476492
},
477493
{
478-
Config: testAccVPCEndpointConfig_newOrderPolicy(rName),
479-
PlanOnly: true,
494+
Config: testAccVPCEndpointConfig_newOrderPolicy(rName),
495+
ConfigPlanChecks: resource.ConfigPlanChecks{
496+
PreApply: []plancheck.PlanCheck{
497+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
498+
},
499+
PostApplyPostRefresh: []plancheck.PlanCheck{
500+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
501+
},
502+
},
480503
},
481504
},
482505
})

0 commit comments

Comments
 (0)