fix: change "attached" to "available" in igw to match aws + add describe instance types filtering for TF

This commit is contained in:
Julian Sommer
2026-03-26 12:34:32 +10:00
parent 4ad5843ff5
commit 1c194da915
3 changed files with 21 additions and 2 deletions
@@ -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,
+1 -1
View File
@@ -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 {
@@ -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) {