diff --git a/spinifex/gateway/ec2/instance/DescribeInstanceTypes.go b/spinifex/gateway/ec2/instance/DescribeInstanceTypes.go index 0b38f360a..d4187d512 100644 --- a/spinifex/gateway/ec2/instance/DescribeInstanceTypes.go +++ b/spinifex/gateway/ec2/instance/DescribeInstanceTypes.go @@ -113,6 +113,14 @@ func DescribeInstanceTypes(input *ec2.DescribeInstanceTypesInput, natsConn *nats } } + // Build set of requested instance type names (if any) for filtering. + requestedTypes := make(map[string]bool) + for _, it := range input.InstanceTypes { + if it != nil { + requestedTypes[*it] = true + } + } + var finalInstanceTypes []*ec2.InstanceTypeInfo if showCapacity { finalInstanceTypes = allInstanceTypes @@ -128,6 +136,17 @@ func DescribeInstanceTypes(input *ec2.DescribeInstanceTypesInput, natsConn *nats } } + // Filter by requested instance type names if specified. + if len(requestedTypes) > 0 { + var filtered []*ec2.InstanceTypeInfo + for _, it := range finalInstanceTypes { + if it != nil && it.InstanceType != nil && requestedTypes[*it.InstanceType] { + filtered = append(filtered, it) + } + } + finalInstanceTypes = filtered + } + // Build final aggregated response output := &ec2.DescribeInstanceTypesOutput{ InstanceTypes: finalInstanceTypes, diff --git a/spinifex/handlers/ec2/igw/service_impl.go b/spinifex/handlers/ec2/igw/service_impl.go index a18b8ff4c..8b45f7c23 100644 --- a/spinifex/handlers/ec2/igw/service_impl.go +++ b/spinifex/handlers/ec2/igw/service_impl.go @@ -252,7 +252,7 @@ func (s *IGWServiceImpl) AttachInternetGateway(input *ec2.AttachInternetGatewayI } record.VpcId = vpcID - record.State = "attached" + record.State = "available" data, err := json.Marshal(record) if err != nil { diff --git a/spinifex/handlers/ec2/igw/service_impl_test.go b/spinifex/handlers/ec2/igw/service_impl_test.go index bcd2dcf82..7114c82a9 100644 --- a/spinifex/handlers/ec2/igw/service_impl_test.go +++ b/spinifex/handlers/ec2/igw/service_impl_test.go @@ -210,7 +210,7 @@ func TestAttachInternetGateway(t *testing.T) { require.Len(t, desc.InternetGateways, 1) require.Len(t, desc.InternetGateways[0].Attachments, 1) assert.Equal(t, "vpc-test123", *desc.InternetGateways[0].Attachments[0].VpcId) - assert.Equal(t, "attached", *desc.InternetGateways[0].Attachments[0].State) + assert.Equal(t, "available", *desc.InternetGateways[0].Attachments[0].State) } func TestAttachInternetGateway_NotFound(t *testing.T) {