fix: return InvalidGatewayID.NotFound with AWS's message when deleting a missing egress-only gateway

This commit is contained in:
Julian Sommer
2026-09-30 10:06:12 +10:00
parent 666ea4bb4b
commit 5f60b2c7c7
3 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -2645,7 +2645,7 @@ func TestDelegateHandlers_EIGW(t *testing.T) {
topic: "ec2.test.DeleteEgressOnlyIGW",
handler: asMsgHandler(handleNATSRequest(daemon.node, daemon.eigwService.DeleteEgressOnlyInternetGateway)),
input: &ec2.DeleteEgressOnlyInternetGatewayInput{EgressOnlyInternetGatewayId: aws.String("eigw-nonexistent")},
expectedCode: awserrors.ErrorInvalidEgressOnlyInternetGatewayIdNotFound,
expectedCode: awserrors.ErrorInvalidGatewayIDNotFound,
},
{
name: "DescribeEgressOnlyInternetGateways",
+1 -1
View File
@@ -129,7 +129,7 @@ func (s *EgressOnlyIGWServiceImpl) DeleteEgressOnlyInternetGateway(ctx context.C
// Verify the EIGW exists before deleting
if _, err := s.eigwKV.Get(ctx, key); err != nil {
if errors.Is(err, jetstream.ErrKeyNotFound) {
return nil, errors.New(awserrors.ErrorInvalidEgressOnlyInternetGatewayIdNotFound)
return nil, awserrors.Errorf(awserrors.ErrorInvalidGatewayIDNotFound, "The eigw ID '%s' does not exist", eigwID)
}
return nil, errors.New(awserrors.ErrorServerInternal)
}
@@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mulgadc/spinifex/spinifex/awserrors"
handlers_ec2_vpc "github.com/mulgadc/spinifex/spinifex/handlers/ec2/vpc"
"github.com/mulgadc/spinifex/spinifex/testutil"
"github.com/mulgadc/spinifex/spinifex/utils"
@@ -133,7 +134,10 @@ func TestDeleteEgressOnlyInternetGateway_NotFound(t *testing.T) {
_, err := svc.DeleteEgressOnlyInternetGateway(context.Background(), &ec2.DeleteEgressOnlyInternetGatewayInput{
EgressOnlyInternetGatewayId: aws.String("eigw-nonexistent"),
}, testAccountID)
assert.ErrorContains(t, err, "InvalidEgressOnlyInternetGatewayId.NotFound")
code, msg, ok := awserrors.ResolveErrorDetail(err)
require.True(t, ok, "error %v carries no AWS code", err)
assert.Equal(t, awserrors.ErrorInvalidGatewayIDNotFound, code)
assert.Equal(t, "The eigw ID 'eigw-nonexistent' does not exist", msg)
}
func TestDeleteEgressOnlyInternetGateway_MissingID(t *testing.T) {