Skip to content

Commit b71fd01

Browse files
committed
exec command
1 parent 02f844a commit b71fd01

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

cmd/exec.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var execCmd = &cobra.Command{
4141
if err != nil {
4242
log.WithError(err).Error("Can't run task in Fargate mode")
4343
}
44-
//os.Exit(exitCode)
4544
},
4645
}
4746

lib/exec.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
var sessionInstance *ecs.Client
1414
var sessionConfig aws.Config // Variable for session configuration
1515

16-
// InitAWS initializes a new AWS session with the specified profile
16+
// InitAWS initializes a new AWS session with the specified profile for Ecsta realization
1717
func InitAWS(profile string) error {
1818
if sessionInstance == nil {
1919
cfg, err := config.LoadDefaultConfig(context.TODO(),
@@ -45,11 +45,9 @@ func ExecFargate(profile, cluster, service, containerName, command string) error
4545
configPath := "/app/.ssm-parent.yaml"
4646
fullCommand := fmt.Sprintf("%s -c %s run -- %s", entrypoint, configPath, command)
4747
execOpt := ecsta.ExecOption{
48-
Service: aws.String(service),
49-
Container: containerName,
5048
Command: fullCommand,
5149
}
52-
50+
fmt.Println(execOpt)
5351
if err := ecstaApp.RunExec(context.Background(), &execOpt); err != nil {
5452
return fmt.Errorf("failed to execute command: %w", err)
5553
}
@@ -58,18 +56,4 @@ func ExecFargate(profile, cluster, service, containerName, command string) error
5856
return nil
5957
}
6058

61-
// FindLatestTaskArn locates the most recent task ARN for a specified ECS service
62-
func FindLatestTaskArn(client *ecs.Client, clusterName, serviceName string) (string, error) {
63-
resp, err := client.ListTasks(context.TODO(), &ecs.ListTasksInput{
64-
Cluster: aws.String(clusterName),
65-
ServiceName: aws.String(serviceName),
66-
})
67-
if err != nil {
68-
return "", fmt.Errorf("error listing tasks: %w", err)
69-
}
70-
if len(resp.TaskArns) == 0 {
71-
return "", fmt.Errorf("no tasks found for service %s on cluster %s", serviceName, clusterName)
72-
}
7359

74-
return resp.TaskArns[0], nil
75-
}

0 commit comments

Comments
 (0)