Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 59560b3

Browse files
authored
Disable GlobalAccelerator before deleting it (#723)
1 parent 3391629 commit 59560b3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

resources/ga-accelerators.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,22 @@ func ListGlobalAccelerators(sess *session.Session) ([]Resource, error) {
5151

5252
// Remove resource
5353
func (ga *GlobalAccelerator) Remove() error {
54-
_, err := ga.svc.DeleteAccelerator(&globalaccelerator.DeleteAcceleratorInput{
54+
accel, err := ga.svc.DescribeAccelerator(&globalaccelerator.DescribeAcceleratorInput{
55+
AcceleratorArn: ga.ARN,
56+
})
57+
if err != nil {
58+
return err
59+
}
60+
if *accel.Accelerator.Enabled {
61+
_, err := ga.svc.UpdateAccelerator(&globalaccelerator.UpdateAcceleratorInput{
62+
AcceleratorArn: ga.ARN,
63+
Enabled: aws.Bool(false),
64+
})
65+
if err != nil {
66+
return err
67+
}
68+
}
69+
_, err = ga.svc.DeleteAccelerator(&globalaccelerator.DeleteAcceleratorInput{
5570
AcceleratorArn: ga.ARN,
5671
})
5772

0 commit comments

Comments
 (0)