55 "net"
66 "os"
77 "strings"
8+ "time"
89
910 awssdk "github.com/aws/aws-sdk-go-v2/aws"
1011 "github.com/aws/aws-sdk-go-v2/service/ec2/types"
@@ -15,6 +16,7 @@ import (
1516 "github.com/awslabs/eksdemo/pkg/application/storage/ebs_csi"
1617 "github.com/awslabs/eksdemo/pkg/aws"
1718 "github.com/awslabs/eksdemo/pkg/cmd"
19+ "github.com/awslabs/eksdemo/pkg/eksctl"
1820 "github.com/awslabs/eksdemo/pkg/kubernetes"
1921 "github.com/awslabs/eksdemo/pkg/resource"
2022 "github.com/awslabs/eksdemo/pkg/resource/cloudformation_stack"
@@ -46,9 +48,10 @@ type ClusterOptions struct {
4648 appsForIrsa []* application.Application
4749 IrsaTemplate * template.TextTemplate
4850 IrsaRoles []* resource.Resource
51+ Timeout time.Duration
4952}
5053
51- func addOptions (res * resource.Resource ) * resource.Resource {
54+ func addOptions (res * resource.Resource , resMgr * eksctl. ResourceManager ) * resource.Resource {
5255 ngOptions , ngFlags , _ := nodegroup .NewOptions ()
5356
5457 options := & ClusterOptions {
@@ -175,7 +178,7 @@ func addOptions(res *resource.Resource) *resource.Resource {
175178 CommandFlag : cmd.CommandFlag {
176179 Name : "vpc-cidr" ,
177180 Description : "CIDR to use for EKS Cluster VPC" ,
178- Validate : func (cmd * cobra.Command , args []string ) error {
181+ Validate : func (_ * cobra.Command , _ []string ) error {
179182 _ , _ , err := net .ParseCIDR (options .VpcCidr )
180183 if err != nil {
181184 return fmt .Errorf ("failed parsing --vpc-cidr, %w" , err )
@@ -199,6 +202,20 @@ func addOptions(res *resource.Resource) *resource.Resource {
199202 },
200203 Option : & options .Addons ,
201204 },
205+ & cmd.DurationFlag {
206+ CommandFlag : cmd.CommandFlag {
207+ Name : "timeout" ,
208+ Description : "maximum waiting time for any long-running operation" ,
209+ Validate : func (_ * cobra.Command , _ []string ) error {
210+ if options .Timeout .Seconds () > 0 {
211+ resMgr .CreateFlags = append (resMgr .CreateFlags ,
212+ fmt .Sprintf ("--timeout=%s" , options .Timeout .String ()))
213+ }
214+ return nil
215+ },
216+ },
217+ Option : & options .Timeout ,
218+ },
202219 }
203220
204221 res .CreateFlags = append (ngFlags , flags ... )
0 commit comments