-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to not return err when instance is already terminated #6978
Fix to not return err when instance is already terminated #6978
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this @kterada0509! 🚀
--- PASS: TestAccAWSInstance_ipv6AddressCountAndSingleAddressCausesError (10.41s)
--- PASS: TestAccAWSInstance_importInDefaultVpcBySgId (83.98s)
--- PASS: TestAccAWSInstance_ipv6_supportAddressCountWithIpv4 (83.91s)
--- PASS: TestAccAWSInstance_rootInstanceStore (95.05s)
--- PASS: TestAccAWSInstance_ipv6_supportAddressCount (95.52s)
--- PASS: TestAccAWSInstance_importInEc2Classic (97.14s)
--- PASS: TestAccAWSInstance_importBasic (103.57s)
--- PASS: TestAccAWSInstance_basic (119.88s)
--- PASS: TestAccAWSInstance_sourceDestCheck (141.98s)
--- PASS: TestAccAWSInstance_userDataBase64 (157.33s)
--- PASS: TestAccAWSInstance_noAMIEphemeralDevices (164.08s)
--- PASS: TestAccAWSInstance_volumeTags (78.86s)
--- PASS: TestAccAWSInstance_placementGroup (177.02s)
--- PASS: TestAccAWSInstance_GP2IopsDevice (180.10s)
--- PASS: TestAccAWSInstance_GP2WithIopsValue (182.39s)
--- PASS: TestAccAWSInstance_blockDevices (183.38s)
--- PASS: TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs (101.60s)
--- PASS: TestAccAWSInstance_vpc (192.70s)
--- PASS: TestAccAWSInstance_volumeTagsComputed (98.65s)
--- PASS: TestAccAWSInstance_importInDefaultVpcBySgName (197.24s)
--- PASS: TestAccAWSInstance_tags (119.61s)
--- PASS: TestAccAWSInstance_NetworkInstanceSecurityGroups (207.21s)
--- PASS: TestAccAWSInstance_privateIP (89.49s)
--- PASS: TestAccAWSInstance_instanceProfileChange (120.07s)
--- PASS: TestAccAWSInstance_NetworkInstanceRemovingAllSecurityGroups (212.10s)
--- PASS: TestAccAWSInstance_associatePublicIPAndPrivateIP (92.06s)
--- PASS: TestAccAWSInstance_disableApiTermination (246.64s)
--- PASS: TestAccAWSInstance_primaryNetworkInterface (80.86s)
--- PASS: TestAccAWSInstance_associatePublic_defaultPrivate (71.12s)
--- PASS: TestAccAWSInstance_addSecondaryInterface (84.16s)
--- PASS: TestAccAWSInstance_multipleRegions (271.50s)
--- PASS: TestAccAWSInstance_associatePublic_overridePublic (80.18s)
--- PASS: TestAccAWSInstance_associatePublic_overridePrivate (86.44s)
--- PASS: TestAccAWSInstance_creditSpecification_unspecifiedDefaultsToStandard (70.11s)
--- PASS: TestAccAWSInstance_withIamInstanceProfile (239.13s)
--- PASS: TestAccAWSInstance_creditSpecification_isNotAppliedToNonBurstable (76.34s)
--- PASS: TestAccAWSInstance_rootBlockDeviceMismatch (181.37s)
--- PASS: TestAccAWSInstance_keyPairCheck (193.72s)
--- PASS: TestAccAWSInstance_creditSpecification_unlimitedCpuCredits (91.89s)
--- PASS: TestAccAWSInstance_creditSpecification_updateCpuCredits (89.21s)
--- PASS: TestAccAWSInstance_creditSpecification_standardCpuCredits (108.92s)
--- PASS: TestAccAWSInstance_associatePublic_defaultPublic (180.19s)
--- PASS: TestAccAWSInstance_getPasswordData_trueToFalse (154.62s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_unlimitedCpuCredits (88.29s)
--- PASS: TestAccAWSInstance_associatePublic_explicitPublic (192.06s)
--- PASS: TestAccAWSInstance_getPasswordData_falseToTrue (175.79s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_updateCpuCredits (94.46s)
--- PASS: TestAccAWSInstance_primaryNetworkInterfaceSourceDestCheck (224.59s)
--- PASS: TestAccAWSInstance_forceNewAndTagsDrift (239.48s)
--- PASS: TestAccAWSInstance_associatePublic_explicitPrivate (234.79s)
--- PASS: TestAccAWSInstance_UserData_EmptyStringToUnspecified (115.72s)
--- PASS: TestAccAWSInstance_UserData_UnspecifiedToEmptyString (115.44s)
--- PASS: TestAccAWSInstance_addSecurityGroupNetworkInterface (287.64s)
--- PASS: TestAccAWSInstance_changeInstanceType (332.98s)
--- PASS: TestAccAWSInstance_disappears (206.87s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_unspecifiedDefaultsToUnlimited (295.97s)
--- PASS: TestAccAWSInstance_creditSpecificationT3_standardCpuCredits (289.25s)
--- PASS: TestAccAWSInstance_creditSpecification_unlimitedCpuCredits_t2Tot3Taint (357.40s)
--- PASS: TestAccAWSInstance_creditSpecification_standardCpuCredits_t2Tot3Taint (509.95s)
@@ -1925,9 +1925,16 @@ func awsTerminateInstance(conn *ec2.EC2, id string, timeout time.Duration) error | |||
InstanceIds: []*string{aws.String(id)}, | |||
} | |||
if _, err := conn.TerminateInstances(req); err != nil { | |||
if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "InvalidInstanceID.NotFound" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We have a helper function for these, e.g. isAWSErr(err, "InvalidInstanceID.NotFound", "")
, definitely not a blocker though
@@ -1942,6 +1942,27 @@ func TestAccAWSInstance_creditSpecification_unlimitedCpuCredits_t2Tot3Taint(t *t | |||
}) | |||
} | |||
|
|||
func TestAccAWSInstance_disappears(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
This has been released in version 1.55.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Fixes #445 (?)
Changes proposed in this pull request:
Output from acceptance testing: