diff --git a/spinifex/daemon/daemon_handlers_test.go b/spinifex/daemon/daemon_handlers_test.go index 4af608046..cf4a963b5 100644 --- a/spinifex/daemon/daemon_handlers_test.go +++ b/spinifex/daemon/daemon_handlers_test.go @@ -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", diff --git a/spinifex/handlers/ec2/eigw/service_impl.go b/spinifex/handlers/ec2/eigw/service_impl.go index 54d3665b3..7bb9fa72c 100644 --- a/spinifex/handlers/ec2/eigw/service_impl.go +++ b/spinifex/handlers/ec2/eigw/service_impl.go @@ -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) } diff --git a/spinifex/handlers/ec2/eigw/service_impl_test.go b/spinifex/handlers/ec2/eigw/service_impl_test.go index 2249ad916..731ea1d22 100644 --- a/spinifex/handlers/ec2/eigw/service_impl_test.go +++ b/spinifex/handlers/ec2/eigw/service_impl_test.go @@ -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) {