|
|
@@ -89,7 +89,15 @@ func (c *GetClusterInfoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
|
|
|
|
|
|
ec2Svc := ec2.New(awsSession, awsConf)
|
|
|
|
|
|
- subnetsInfo, err := ec2Svc.DescribeSubnets(&ec2.DescribeSubnetsInput{
|
|
|
+ res := &types.GetAWSClusterInfoResponse{
|
|
|
+ Name: clusterName,
|
|
|
+ ARN: *clusterInfo.Cluster.Arn,
|
|
|
+ Status: *clusterInfo.Cluster.Status,
|
|
|
+ K8sVersion: *clusterInfo.Cluster.Version,
|
|
|
+ EKSVersion: *clusterInfo.Cluster.PlatformVersion,
|
|
|
+ }
|
|
|
+
|
|
|
+ err = ec2Svc.DescribeSubnetsPages(&ec2.DescribeSubnetsInput{
|
|
|
Filters: []*ec2.Filter{
|
|
|
{
|
|
|
Name: aws.String("vpc-id"),
|
|
|
@@ -98,28 +106,26 @@ func (c *GetClusterInfoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
+ }, func(page *ec2.DescribeSubnetsOutput, lastPage bool) bool {
|
|
|
+ if page == nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, subnet := range page.Subnets {
|
|
|
+ res.Subnets = append(res.Subnets, &types.AWSSubnet{
|
|
|
+ SubnetID: *subnet.SubnetId,
|
|
|
+ AvailabilityZone: *subnet.AvailabilityZone,
|
|
|
+ AvailableIPAddressCount: *subnet.AvailableIpAddressCount,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ return !lastPage
|
|
|
})
|
|
|
|
|
|
- if err != nil || len(subnetsInfo.Subnets) == 0 {
|
|
|
+ if err != nil {
|
|
|
c.HandleAPIError(w, r, apierrors.NewErrInternal(err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- res := &types.GetAWSClusterInfoResponse{
|
|
|
- Name: clusterName,
|
|
|
- ARN: *clusterInfo.Cluster.Arn,
|
|
|
- Status: *clusterInfo.Cluster.Status,
|
|
|
- K8sVersion: *clusterInfo.Cluster.Version,
|
|
|
- EKSVersion: *clusterInfo.Cluster.PlatformVersion,
|
|
|
- }
|
|
|
-
|
|
|
- for _, subnet := range subnetsInfo.Subnets {
|
|
|
- res.Subnets = append(res.Subnets, &types.AWSSubnet{
|
|
|
- SubnetID: *subnet.SubnetId,
|
|
|
- AvailabilityZone: *subnet.AvailabilityZone,
|
|
|
- AvailableIPAddressCount: *subnet.AvailableIpAddressCount,
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
c.WriteResult(w, r, res)
|
|
|
}
|