@@ -9,13 +9,14 @@ import (
9
9
"reflect"
10
10
"strconv"
11
11
12
- "github.com/aws/aws-sdk-go/aws"
13
- "github.com/aws/aws-sdk-go/service/s3control"
14
- "github.com/hashicorp /aws-sdk-go-base/ v2/awsv1shim/v2/tfawserr "
12
+ "github.com/aws/aws-sdk-go-v2 /aws"
13
+ "github.com/aws/aws-sdk-go-v2 /service/s3control"
14
+ "github.com/aws /aws-sdk-go-v2/service/s3control/types "
15
15
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
16
16
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
17
17
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
18
18
"github.com/hashicorp/terraform-provider-aws/internal/conns"
19
+ "github.com/hashicorp/terraform-provider-aws/internal/errs"
19
20
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
20
21
"github.com/hashicorp/terraform-provider-aws/internal/verify"
21
22
)
@@ -65,24 +66,23 @@ func resourceAccountPublicAccessBlock() *schema.Resource {
65
66
}
66
67
67
68
func resourceAccountPublicAccessBlockCreate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
68
- conn := meta .(* conns.AWSClient ).S3ControlConn (ctx )
69
+ conn := meta .(* conns.AWSClient ).S3ControlClient (ctx )
69
70
70
71
accountID := meta .(* conns.AWSClient ).AccountID
71
72
if v , ok := d .GetOk ("account_id" ); ok {
72
73
accountID = v .(string )
73
74
}
74
-
75
75
input := & s3control.PutPublicAccessBlockInput {
76
76
AccountId : aws .String (accountID ),
77
- PublicAccessBlockConfiguration : & s3control .PublicAccessBlockConfiguration {
78
- BlockPublicAcls : aws . Bool ( d .Get ("block_public_acls" ).(bool ) ),
79
- BlockPublicPolicy : aws . Bool ( d .Get ("block_public_policy" ).(bool ) ),
80
- IgnorePublicAcls : aws . Bool ( d .Get ("ignore_public_acls" ).(bool ) ),
81
- RestrictPublicBuckets : aws . Bool ( d .Get ("restrict_public_buckets" ).(bool ) ),
77
+ PublicAccessBlockConfiguration : & types .PublicAccessBlockConfiguration {
78
+ BlockPublicAcls : d .Get ("block_public_acls" ).(bool ),
79
+ BlockPublicPolicy : d .Get ("block_public_policy" ).(bool ),
80
+ IgnorePublicAcls : d .Get ("ignore_public_acls" ).(bool ),
81
+ RestrictPublicBuckets : d .Get ("restrict_public_buckets" ).(bool ),
82
82
},
83
83
}
84
84
85
- _ , err := conn .PutPublicAccessBlockWithContext (ctx , input )
85
+ _ , err := conn .PutPublicAccessBlock (ctx , input )
86
86
87
87
if err != nil {
88
88
return diag .Errorf ("creating S3 Account Public Access Block (%s): %s" , accountID , err )
@@ -91,7 +91,7 @@ func resourceAccountPublicAccessBlockCreate(ctx context.Context, d *schema.Resou
91
91
d .SetId (accountID )
92
92
93
93
_ , err = tfresource .RetryWhenNotFound (ctx , propagationTimeout , func () (interface {}, error ) {
94
- return FindPublicAccessBlockByAccountID (ctx , conn , d .Id ())
94
+ return findPublicAccessBlockByAccountID (ctx , conn , d .Id ())
95
95
})
96
96
97
97
if err != nil {
@@ -102,9 +102,9 @@ func resourceAccountPublicAccessBlockCreate(ctx context.Context, d *schema.Resou
102
102
}
103
103
104
104
func resourceAccountPublicAccessBlockRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
105
- conn := meta .(* conns.AWSClient ).S3ControlConn (ctx )
105
+ conn := meta .(* conns.AWSClient ).S3ControlClient (ctx )
106
106
107
- output , err := FindPublicAccessBlockByAccountID (ctx , conn , d .Id ())
107
+ output , err := findPublicAccessBlockByAccountID (ctx , conn , d .Id ())
108
108
109
109
if ! d .IsNewResource () && tfresource .NotFound (err ) {
110
110
log .Printf ("[WARN] S3 Account Public Access Block (%s) not found, removing from state" , d .Id ())
@@ -126,20 +126,20 @@ func resourceAccountPublicAccessBlockRead(ctx context.Context, d *schema.Resourc
126
126
}
127
127
128
128
func resourceAccountPublicAccessBlockUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
129
- conn := meta .(* conns.AWSClient ).S3ControlConn (ctx )
129
+ conn := meta .(* conns.AWSClient ).S3ControlClient (ctx )
130
130
131
- publicAccessBlockConfiguration := & s3control .PublicAccessBlockConfiguration {
132
- BlockPublicAcls : aws . Bool ( d .Get ("block_public_acls" ).(bool ) ),
133
- BlockPublicPolicy : aws . Bool ( d .Get ("block_public_policy" ).(bool ) ),
134
- IgnorePublicAcls : aws . Bool ( d .Get ("ignore_public_acls" ).(bool ) ),
135
- RestrictPublicBuckets : aws . Bool ( d .Get ("restrict_public_buckets" ).(bool ) ),
131
+ publicAccessBlockConfiguration := & types .PublicAccessBlockConfiguration {
132
+ BlockPublicAcls : d .Get ("block_public_acls" ).(bool ),
133
+ BlockPublicPolicy : d .Get ("block_public_policy" ).(bool ),
134
+ IgnorePublicAcls : d .Get ("ignore_public_acls" ).(bool ),
135
+ RestrictPublicBuckets : d .Get ("restrict_public_buckets" ).(bool ),
136
136
}
137
137
input := & s3control.PutPublicAccessBlockInput {
138
138
AccountId : aws .String (d .Id ()),
139
139
PublicAccessBlockConfiguration : publicAccessBlockConfiguration ,
140
140
}
141
141
142
- _ , err := conn .PutPublicAccessBlockWithContext (ctx , input )
142
+ _ , err := conn .PutPublicAccessBlock (ctx , input )
143
143
144
144
if err != nil {
145
145
return diag .Errorf ("updating S3 Account Public Access Block (%s): %s" , d .Id (), err )
@@ -153,14 +153,14 @@ func resourceAccountPublicAccessBlockUpdate(ctx context.Context, d *schema.Resou
153
153
}
154
154
155
155
func resourceAccountPublicAccessBlockDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
156
- conn := meta .(* conns.AWSClient ).S3ControlConn (ctx )
156
+ conn := meta .(* conns.AWSClient ).S3ControlClient (ctx )
157
157
158
158
log .Printf ("[DEBUG] Deleting S3 Account Public Access Block: %s" , d .Id ())
159
- _ , err := conn .DeletePublicAccessBlockWithContext (ctx , & s3control.DeletePublicAccessBlockInput {
159
+ _ , err := conn .DeletePublicAccessBlock (ctx , & s3control.DeletePublicAccessBlockInput {
160
160
AccountId : aws .String (d .Id ()),
161
161
})
162
162
163
- if tfawserr . ErrCodeEquals (err , s3control . ErrCodeNoSuchPublicAccessBlockConfiguration ) {
163
+ if errs. IsA [ * types. NoSuchPublicAccessBlockConfiguration ] (err ) {
164
164
return nil
165
165
}
166
166
@@ -171,14 +171,14 @@ func resourceAccountPublicAccessBlockDelete(ctx context.Context, d *schema.Resou
171
171
return nil
172
172
}
173
173
174
- func FindPublicAccessBlockByAccountID (ctx context.Context , conn * s3control.S3Control , accountID string ) (* s3control .PublicAccessBlockConfiguration , error ) {
174
+ func findPublicAccessBlockByAccountID (ctx context.Context , conn * s3control.Client , accountID string ) (* types .PublicAccessBlockConfiguration , error ) {
175
175
input := & s3control.GetPublicAccessBlockInput {
176
176
AccountId : aws .String (accountID ),
177
177
}
178
178
179
- output , err := conn .GetPublicAccessBlockWithContext (ctx , input )
179
+ output , err := conn .GetPublicAccessBlock (ctx , input )
180
180
181
- if tfawserr . ErrCodeEquals (err , s3control . ErrCodeNoSuchPublicAccessBlockConfiguration ) {
181
+ if errs. IsA [ * types. NoSuchPublicAccessBlockConfiguration ] (err ) {
182
182
return nil , & retry.NotFoundError {
183
183
LastError : err ,
184
184
LastRequest : input ,
@@ -196,9 +196,9 @@ func FindPublicAccessBlockByAccountID(ctx context.Context, conn *s3control.S3Con
196
196
return output .PublicAccessBlockConfiguration , nil
197
197
}
198
198
199
- func statusPublicAccessBlockEqual (ctx context.Context , conn * s3control.S3Control , accountID string , target * s3control .PublicAccessBlockConfiguration ) retry.StateRefreshFunc {
199
+ func statusPublicAccessBlockEqual (ctx context.Context , conn * s3control.Client , accountID string , target * types .PublicAccessBlockConfiguration ) retry.StateRefreshFunc {
200
200
return func () (interface {}, string , error ) {
201
- output , err := FindPublicAccessBlockByAccountID (ctx , conn , accountID )
201
+ output , err := findPublicAccessBlockByAccountID (ctx , conn , accountID )
202
202
203
203
if tfresource .NotFound (err ) {
204
204
return nil , "" , nil
@@ -212,7 +212,7 @@ func statusPublicAccessBlockEqual(ctx context.Context, conn *s3control.S3Control
212
212
}
213
213
}
214
214
215
- func waitPublicAccessBlockEqual (ctx context.Context , conn * s3control.S3Control , accountID string , target * s3control .PublicAccessBlockConfiguration ) (* s3control .PublicAccessBlockConfiguration , error ) {
215
+ func waitPublicAccessBlockEqual (ctx context.Context , conn * s3control.Client , accountID string , target * types .PublicAccessBlockConfiguration ) (* types .PublicAccessBlockConfiguration , error ) {
216
216
stateConf := & retry.StateChangeConf {
217
217
Pending : []string {strconv .FormatBool (false )},
218
218
Target : []string {strconv .FormatBool (true )},
@@ -224,7 +224,7 @@ func waitPublicAccessBlockEqual(ctx context.Context, conn *s3control.S3Control,
224
224
225
225
outputRaw , err := stateConf .WaitForStateContext (ctx )
226
226
227
- if output , ok := outputRaw .(* s3control .PublicAccessBlockConfiguration ); ok {
227
+ if output , ok := outputRaw .(* types .PublicAccessBlockConfiguration ); ok {
228
228
return output , err
229
229
}
230
230
0 commit comments