@@ -13,11 +13,9 @@ import (
13
13
14
14
"github.com/aws/aws-sdk-go-v2/aws"
15
15
"github.com/aws/aws-sdk-go-v2/service/ec2"
16
- awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types"
17
16
"github.com/hashicorp/aws-sdk-go-base/v2/tfawserr"
18
17
"github.com/hashicorp/terraform-plugin-log/tflog"
19
18
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
20
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
21
19
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
22
20
"github.com/hashicorp/terraform-provider-aws/internal/conns"
23
21
"github.com/hashicorp/terraform-provider-aws/internal/create"
@@ -206,48 +204,6 @@ func volumeAttachmentID(name, volumeID, instanceID string) string {
206
204
return fmt .Sprintf ("vai-%d" , create .StringHashcode (buf .String ()))
207
205
}
208
206
209
- func findVolumeAttachment (ctx context.Context , conn * ec2.Client , volumeID , instanceID , deviceName string ) (* awstypes.VolumeAttachment , error ) {
210
- input := ec2.DescribeVolumesInput {
211
- Filters : newAttributeFilterList (map [string ]string {
212
- "attachment.device" : deviceName ,
213
- "attachment.instance-id" : instanceID ,
214
- }),
215
- VolumeIds : []string {volumeID },
216
- }
217
-
218
- output , err := findEBSVolume (ctx , conn , & input )
219
-
220
- if err != nil {
221
- return nil , err
222
- }
223
-
224
- if state := output .State ; state == awstypes .VolumeStateAvailable || state == awstypes .VolumeStateDeleted {
225
- return nil , & retry.NotFoundError {
226
- Message : string (state ),
227
- LastRequest : input ,
228
- }
229
- }
230
-
231
- // Eventual consistency check.
232
- if aws .ToString (output .VolumeId ) != volumeID {
233
- return nil , & retry.NotFoundError {
234
- LastRequest : input ,
235
- }
236
- }
237
-
238
- for _ , v := range output .Attachments {
239
- if v .State == awstypes .VolumeAttachmentStateDetached {
240
- continue
241
- }
242
-
243
- if aws .ToString (v .Device ) == deviceName && aws .ToString (v .InstanceId ) == instanceID {
244
- return & v , nil
245
- }
246
- }
247
-
248
- return nil , & retry.NotFoundError {}
249
- }
250
-
251
207
func stopVolumeAttachmentInstance (ctx context.Context , conn * ec2.Client , id string , force bool , timeout time.Duration ) error {
252
208
tflog .Info (ctx , "Stopping EC2 Instance" , map [string ]any {
253
209
"ec2_instance_id" : id ,
0 commit comments