@@ -66,32 +66,33 @@ var checkCommand = &cobra.Command{ // nolint:gochecknoglobals
66
66
log .Infof ("ℹ️ Found duplicate subnets. We'll test each subnet '%v' only once." , distinctSubnets )
67
67
}
68
68
69
- log .Infof ("ℹ️ Launching EC2 instances in Main subnets" )
69
+ log .Info ("ℹ️ Launching EC2 instances in Main subnets" )
70
70
mainInstanceIds , err := launchInstances (cmd .Context (), ec2Client , networkConfig .MainSubnets , instanceProfile .Arn )
71
71
if err != nil {
72
72
return err
73
73
}
74
74
log .Infof ("ℹ️ Main EC2 instances: %v" , mainInstanceIds )
75
75
InstanceIds = append (InstanceIds , mainInstanceIds ... )
76
76
77
- log .Infof ("ℹ️ Launching EC2 instances in a Pod subnets" )
77
+ log .Info ("ℹ️ Launching EC2 instances in a Pod subnets" )
78
78
podInstanceIds , err := launchInstances (cmd .Context (), ec2Client , networkConfig .PodSubnets , instanceProfile .Arn )
79
79
if err != nil {
80
80
return err
81
81
}
82
82
log .Infof ("ℹ️ Pod EC2 instances: %v" , podInstanceIds )
83
83
InstanceIds = append (InstanceIds , podInstanceIds ... )
84
84
85
- log .Infof ("ℹ️ Waiting for EC2 instances to become Running (times out in 4 minutes)" )
85
+ log .Info ("ℹ️ Waiting for EC2 instances to become Running (times out in 5 minutes)" )
86
86
runningWaiter := ec2 .NewInstanceRunningWaiter (ec2Client , func (irwo * ec2.InstanceRunningWaiterOptions ) {
87
87
irwo .MaxDelay = 15 * time .Second
88
88
irwo .MinDelay = 5 * time .Second
89
89
})
90
- err = runningWaiter .Wait (cmd .Context (), & ec2.DescribeInstancesInput {InstanceIds : InstanceIds }, * aws .Duration (4 * time .Minute ))
90
+ err = runningWaiter .Wait (cmd .Context (), & ec2.DescribeInstancesInput {InstanceIds : InstanceIds }, * aws .Duration (5 * time .Minute ))
91
91
if err != nil {
92
92
return fmt .Errorf ("❌ Nodes never got Running: %v" , err )
93
93
}
94
- log .Infof ("ℹ️ Waiting for EC2 instances to become Healthy (times out in 5 minutes)" )
94
+ log .Info ("✅ EC2 instances are now Running." )
95
+ log .Info ("ℹ️ Waiting for EC2 instances to become Healthy (times out in 5 minutes)" )
95
96
waitstatusOK := ec2 .NewInstanceStatusOkWaiter (ec2Client , func (isow * ec2.InstanceStatusOkWaiterOptions ) {
96
97
isow .MaxDelay = 15 * time .Second
97
98
isow .MinDelay = 5 * time .Second
@@ -100,7 +101,7 @@ var checkCommand = &cobra.Command{ // nolint:gochecknoglobals
100
101
if err != nil {
101
102
return fmt .Errorf ("❌ Nodes never got Healthy: %v" , err )
102
103
}
103
- log .Info ("✅ EC2 Instances are now running successfully " )
104
+ log .Info ("✅ EC2 Instances are now healthy/Ok " )
104
105
105
106
log .Infof ("ℹ️ Connecting to SSM..." )
106
107
err = ensureSessionManagerIsUp (cmd .Context (), ssmClient )
@@ -199,6 +200,7 @@ func checkSMPrerequisites(ctx context.Context, ec2Client *ec2.Client) error {
199
200
},
200
201
}
201
202
203
+ var prereqErrs []string
202
204
for _ , endpoint := range vpcEndpoints {
203
205
response , err := ec2Client .DescribeVpcEndpoints (ctx , & ec2.DescribeVpcEndpointsInput {
204
206
Filters : []types.Filter {
@@ -214,31 +216,38 @@ func checkSMPrerequisites(ctx context.Context, ec2Client *ec2.Client) error {
214
216
}
215
217
216
218
if len (response .VpcEndpoints ) == 0 {
217
- if strings .Contains (endpoint .Endpoint , "execute-api" ) {
218
- log .Infof ("ℹ️ Deferring connectivity test for %s service until testing main subnet" , endpoint .PrivateDnsName )
219
+ if strings .Contains (endpoint .Endpoint , "execute-api" ) && networkConfig .ApiEndpoint != "" {
220
+ log .Infof ("ℹ️ 'api-endpoint' parameter exists, deferring connectivity test for execute-api VPC endpoint until testing main subnet connectivity" )
221
+ continue
222
+ } else if strings .Contains (endpoint .Endpoint , "execute-api" ) && networkConfig .ApiEndpoint == "" {
223
+ errMsg := "Add a VPC endpoint for execute-api in this account or use the 'api-endpoint' parameter to specify a centralized one in another account, and test again"
224
+ log .Errorf ("❌ %s" , errMsg )
225
+ prereqErrs = append (prereqErrs , errMsg )
219
226
continue
220
227
}
221
- log .Infof ("ℹ️ VPC endpoint %s is not configured, testing service connectivity..." , endpoint .Endpoint )
222
228
_ , err := TestServiceConnectivity (ctx , endpoint .PrivateDnsName , 5 * time .Second )
223
229
if err != nil {
224
- log .Errorf ("❌ Service %s connectivity test failed: %v\n " , endpoint .PrivateDnsName , err )
225
- } else if endpoint .PrivateDnsRequired {
226
- log .Warnf ("✅ Service %s has connectivity, ensure Private DNS is enabled 🙏" , endpoint .PrivateDnsName )
227
- } else if ! endpoint .PrivateDnsRequired {
228
- log .Infof ("✅ Service %s has connectivity" , endpoint .PrivateDnsName )
230
+ errMsg := fmt .Sprintf ("Service %s connectivity test failed: %v\n " , endpoint .PrivateDnsName , err )
231
+ log .Error ("❌ %w" , errMsg )
232
+ prereqErrs = append (prereqErrs , errMsg )
229
233
}
234
+ log .Infof ("✅ Service %s has connectivity" , endpoint .PrivateDnsName )
230
235
} else {
231
236
for _ , e := range response .VpcEndpoints {
232
237
if e .PrivateDnsEnabled != nil && ! * e .PrivateDnsEnabled && endpoint .PrivateDnsRequired {
233
- log .Errorf ("❌ VPC endpoint '%s' has private DNS disabled, it must be enabled" , * e .VpcEndpointId )
238
+ errMsg := fmt .Sprintf ("VPC endpoint '%s' has private DNS disabled, it must be enabled" , * e .VpcEndpointId )
239
+ log .Errorf ("❌ %s" , errMsg )
240
+ prereqErrs = append (prereqErrs , errMsg )
234
241
}
235
242
}
236
243
log .Infof ("✅ VPC endpoint %s is configured" , endpoint .Endpoint )
237
244
}
238
245
}
239
246
247
+ if len (prereqErrs ) > 0 {
248
+ return fmt .Errorf ("%s" , strings .Join (prereqErrs , "; " ))
249
+ }
240
250
return nil
241
-
242
251
}
243
252
244
253
func ensureSessionManagerIsUp (ctx context.Context , ssmClient * ssm.Client ) error {
0 commit comments