diff --git a/TODO.md b/TODO.md
index 1f9f9f753..3419f5c36 100644
--- a/TODO.md
+++ b/TODO.md
@@ -134,8 +134,8 @@ Instance `dmesg`:
| Command | Implemented Flags | Missing Flags | Prerequisites | Basic Logic | Test Cases | Status |
|---------|-------------------|---------------|---------------|-------------|------------|--------|
-| `describe-regions` | *(returns configured region from config — all input params ignored)* | `--region-names`, `--filters`, `--all-regions`, `--dry-run` | None | Return configured region from hive init config (e.g. us-east-1) → local-only response, no NATS | 1. List all regions
2. Filter by region name
3. Verify endpoint URL returned | **DONE** |
-| `describe-availability-zones` | — | `--zone-names`, `--filters`, `--all-availability-zones` | None | Return configured AZ from hive init (e.g. ap-southeast-2a) → single AZ for Hive v1 | 1. List all AZs
2. Filter by zone name
3. Verify zone state is available | **NOT STARTED** |
+| `describe-regions` | *(returns configured region, endpoint, opt-in status from config — input params ignored)* | `--region-names`, `--filters`, `--all-regions`, `--dry-run` | None | Return configured region from hive init config with Endpoint and OptInStatus → local-only response, no NATS | 1. List all regions
2. Filter by region name
3. Verify endpoint URL returned
4. Verify OptInStatus returned | **DONE** |
+| `describe-availability-zones` | *(returns configured AZ, region, zone ID, state, opt-in status from config — input params ignored)* | `--zone-names`, `--filters`, `--all-availability-zones` | None | Return configured AZ from hive init config with zone ID, state, group name, network border group → local-only response, no NATS | 1. List all AZs
2. Filter by zone name
3. Verify zone state is available
4. Verify region name matches config | **DONE** |
### EC2 - VPC Networking (Core)
diff --git a/hive/gateway/ec2.go b/hive/gateway/ec2.go
index f29fb0fe6..7a6941f06 100644
--- a/hive/gateway/ec2.go
+++ b/hive/gateway/ec2.go
@@ -10,8 +10,8 @@ import (
gateway_ec2_image "github.com/mulgadc/hive/hive/gateway/ec2/image"
gateway_ec2_instance "github.com/mulgadc/hive/hive/gateway/ec2/instance"
gateway_ec2_key "github.com/mulgadc/hive/hive/gateway/ec2/key"
- gateway_ec2_regions "github.com/mulgadc/hive/hive/gateway/ec2/regions"
gateway_ec2_volume "github.com/mulgadc/hive/hive/gateway/ec2/volume"
+ gateway_ec2_zone "github.com/mulgadc/hive/hive/gateway/ec2/zone"
"github.com/mulgadc/hive/hive/utils"
)
@@ -291,7 +291,7 @@ func (gw *GatewayConfig) EC2_Request(ctx *fiber.Ctx) error {
return err
}
- output, err := gateway_ec2_regions.DescribeRegions(input, gw.Region)
+ output, err := gateway_ec2_zone.DescribeRegions(input, gw.Region)
if err != nil {
return err
@@ -305,6 +305,28 @@ func (gw *GatewayConfig) EC2_Request(ctx *fiber.Ctx) error {
return errors.New("failed to marshal response to XML")
}
+ case "DescribeAvailabilityZones":
+ var input = &ec2.DescribeAvailabilityZonesInput{}
+ err = awsec2query.QueryParamsToStruct(queryArgs, input)
+
+ if err != nil {
+ return err
+ }
+
+ output, err := gateway_ec2_zone.DescribeAvailabilityZones(input, gw.Region, gw.AZ)
+
+ if err != nil {
+ return err
+ }
+
+ // Convert to XML
+ payload := utils.GenerateXMLPayload("DescribeAvailabilityZonesResponse", output)
+ xmlOutput, err = utils.MarshalToXML(payload)
+
+ if err != nil {
+ return errors.New("failed to marshal response to XML")
+ }
+
case "DescribeVolumes":
var input = &ec2.DescribeVolumesInput{}
err = awsec2query.QueryParamsToStruct(queryArgs, input)
diff --git a/hive/gateway/ec2/regions/DescribeRegions.go b/hive/gateway/ec2/regions/DescribeRegions.go
deleted file mode 100644
index 7c6f05d2b..000000000
--- a/hive/gateway/ec2/regions/DescribeRegions.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package gateway_ec2_regions
-
-import (
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/service/ec2"
-)
-
-// uses the loaded config file to get the region.
-func DescribeRegions(input *ec2.DescribeRegionsInput, region string) (output *ec2.DescribeRegionsOutput, err error) {
-
- output = &ec2.DescribeRegionsOutput{
- Regions: []*ec2.Region{
- {
- RegionName: aws.String(region),
- },
- }}
-
- return output, nil
-}
diff --git a/hive/gateway/ec2/zone/AvailabilityZone.go b/hive/gateway/ec2/zone/AvailabilityZone.go
new file mode 100644
index 000000000..c525a0c54
--- /dev/null
+++ b/hive/gateway/ec2/zone/AvailabilityZone.go
@@ -0,0 +1,42 @@
+package gateway_ec2_zone
+
+import (
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/service/ec2"
+)
+
+func DescribeAvailabilityZones(input *ec2.DescribeAvailabilityZonesInput, region string, az string) (output *ec2.DescribeAvailabilityZonesOutput, err error) {
+
+ output = &ec2.DescribeAvailabilityZonesOutput{
+ AvailabilityZones: []*ec2.AvailabilityZone{
+ {
+ State: aws.String("available"),
+ OptInStatus: aws.String("opt-in-not-required"),
+ RegionName: aws.String(region),
+ ZoneName: aws.String(az),
+ ZoneId: aws.String("hivez1"),
+ GroupName: aws.String(region),
+ NetworkBorderGroup: aws.String(region),
+ ZoneType: aws.String("availability-zone"),
+ Messages: []*ec2.AvailabilityZoneMessage{},
+ },
+ },
+ }
+
+ return output, nil
+}
+
+func DescribeRegions(input *ec2.DescribeRegionsInput, region string) (output *ec2.DescribeRegionsOutput, err error) {
+
+ output = &ec2.DescribeRegionsOutput{
+ Regions: []*ec2.Region{
+ {
+ Endpoint: aws.String("https://localhost:9999"),
+ RegionName: aws.String(region),
+ OptInStatus: aws.String("opt-in-not-required"),
+ },
+ },
+ }
+
+ return output, nil
+}
diff --git a/hive/gateway/gateway.go b/hive/gateway/gateway.go
index e50a1f2b4..ce2094f59 100644
--- a/hive/gateway/gateway.go
+++ b/hive/gateway/gateway.go
@@ -26,6 +26,7 @@ type GatewayConfig struct {
Config string // Shared AWS Gateway config for S3 auth
ExpectedNodes int // Number of expected hive nodes for multi-node operations
Region string // Region this gateway is running in
+ AZ string // Availability zone this gateway is running in
AccessKey string // AWS Access Key ID for authentication
SecretKey string // AWS Secret Access Key for authentication
}
diff --git a/hive/services/awsgw/awsgw.go b/hive/services/awsgw/awsgw.go
index e667bba06..c1ea0729d 100644
--- a/hive/services/awsgw/awsgw.go
+++ b/hive/services/awsgw/awsgw.go
@@ -92,6 +92,7 @@ func launchService(config *config.ClusterConfig) (err error) {
Config: nodeConfig.AWSGW.Config,
ExpectedNodes: len(config.Nodes),
Region: nodeConfig.Region,
+ AZ: nodeConfig.AZ,
AccessKey: nodeConfig.AccessKey,
SecretKey: nodeConfig.SecretKey,
}