7
7
"context"
8
8
"log"
9
9
10
- "github.com/aws/aws-sdk-go/aws"
11
- "github.com/aws/aws-sdk-go/service/ec2"
12
- "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/ tfawserr"
10
+ "github.com/aws/aws-sdk-go-v2 /aws"
11
+ "github.com/aws/aws-sdk-go-v2 /service/ec2"
12
+ "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr"
13
13
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
14
14
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
15
15
"github.com/hashicorp/terraform-provider-aws/internal/conns"
@@ -41,13 +41,13 @@ func ResourceVPCEndpointServiceAllowedPrincipal() *schema.Resource {
41
41
42
42
func resourceVPCEndpointServiceAllowedPrincipalCreate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
43
43
var diags diag.Diagnostics
44
- conn := meta .(* conns.AWSClient ).EC2Conn (ctx )
44
+ conn := meta .(* conns.AWSClient ).EC2Client (ctx )
45
45
46
46
serviceID := d .Get ("vpc_endpoint_service_id" ).(string )
47
47
principalARN := d .Get ("principal_arn" ).(string )
48
48
49
- output , err := conn .ModifyVpcEndpointServicePermissionsWithContext (ctx , & ec2.ModifyVpcEndpointServicePermissionsInput {
50
- AddAllowedPrincipals : aws . StringSlice ( []string {principalARN }) ,
49
+ output , err := conn .ModifyVpcEndpointServicePermissions (ctx , & ec2.ModifyVpcEndpointServicePermissionsInput {
50
+ AddAllowedPrincipals : []string {principalARN },
51
51
ServiceId : aws .String (serviceID ),
52
52
})
53
53
@@ -56,8 +56,8 @@ func resourceVPCEndpointServiceAllowedPrincipalCreate(ctx context.Context, d *sc
56
56
}
57
57
58
58
for _ , v := range output .AddedPrincipals {
59
- if aws .StringValue (v .Principal ) == principalARN {
60
- d .SetId (aws .StringValue (v .ServicePermissionId ))
59
+ if aws .ToString (v .Principal ) == principalARN {
60
+ d .SetId (aws .ToString (v .ServicePermissionId ))
61
61
}
62
62
}
63
63
@@ -66,12 +66,12 @@ func resourceVPCEndpointServiceAllowedPrincipalCreate(ctx context.Context, d *sc
66
66
67
67
func resourceVPCEndpointServiceAllowedPrincipalRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
68
68
var diags diag.Diagnostics
69
- conn := meta .(* conns.AWSClient ).EC2Conn (ctx )
69
+ conn := meta .(* conns.AWSClient ).EC2Client (ctx )
70
70
71
71
serviceID := d .Get ("vpc_endpoint_service_id" ).(string )
72
72
principalARN := d .Get ("principal_arn" ).(string )
73
73
74
- output , err := FindVPCEndpointServicePermission (ctx , conn , serviceID , principalARN )
74
+ output , err := findVPCEndpointServicePermissionV2 (ctx , conn , serviceID , principalARN )
75
75
76
76
if ! d .IsNewResource () && tfresource .NotFound (err ) {
77
77
log .Printf ("[WARN] EC2 VPC Endpoint Service Allowed Principal %s not found, removing from state" , d .Id ())
@@ -83,20 +83,20 @@ func resourceVPCEndpointServiceAllowedPrincipalRead(ctx context.Context, d *sche
83
83
return sdkdiag .AppendErrorf (diags , "reading EC2 VPC Endpoint Service (%s) Allowed Principal (%s): %s" , serviceID , principalARN , err )
84
84
}
85
85
86
- d .SetId (aws .StringValue (output .ServicePermissionId ))
86
+ d .SetId (aws .ToString (output .ServicePermissionId ))
87
87
88
88
return diags
89
89
}
90
90
91
91
func resourceVPCEndpointServiceAllowedPrincipalDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
92
92
var diags diag.Diagnostics
93
- conn := meta .(* conns.AWSClient ).EC2Conn (ctx )
93
+ conn := meta .(* conns.AWSClient ).EC2Client (ctx )
94
94
95
95
serviceID := d .Get ("vpc_endpoint_service_id" ).(string )
96
96
principalARN := d .Get ("principal_arn" ).(string )
97
97
98
- _ , err := conn .ModifyVpcEndpointServicePermissionsWithContext (ctx , & ec2.ModifyVpcEndpointServicePermissionsInput {
99
- RemoveAllowedPrincipals : aws . StringSlice ( []string {principalARN }) ,
98
+ _ , err := conn .ModifyVpcEndpointServicePermissions (ctx , & ec2.ModifyVpcEndpointServicePermissionsInput {
99
+ RemoveAllowedPrincipals : []string {principalARN },
100
100
ServiceId : aws .String (serviceID ),
101
101
})
102
102
0 commit comments