Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Fallback to user-provided cluster from metadata #2269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
dist/
/.idea/
/.vscode/
1 change: 1 addition & 0 deletions ecs/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type API interface {
GetStackID(ctx context.Context, name string) (string, error)
ListStacks(ctx context.Context) ([]api.Stack, error)
GetStackClusterID(ctx context.Context, stack string) (string, error)
GetStackMetadataClusterID(ctx context.Context, stack string) (string, error)
GetServiceTaskDefinition(ctx context.Context, cluster string, serviceArns []string) (map[string]string, error)
ListStackServices(ctx context.Context, stack string) ([]string, error)
GetServiceTasks(ctx context.Context, cluster string, service string, stopped bool) ([]*ecs.Task, error)
Expand Down
6 changes: 6 additions & 0 deletions ecs/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func (b *ecsAPIService) checkStackState(ctx context.Context, name string) error
svcNames[r.ARN] = r.LogicalID
}
}
if len(cluster) == 0 {
cluster, err = b.aws.GetStackMetadataClusterID(ctx, name)
if err != nil {
return err
}
}
if len(svcArns) == 0 {
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions ecs/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ func (s sdk) GetStackClusterID(ctx context.Context, stack string) (string, error
token = response.NextToken
}
// stack is using user-provided cluster
return s.GetStackMetadataClusterID(ctx, stack)
}

func (s sdk) GetStackMetadataClusterID(ctx context.Context, stack string) (string, error) {
res, err := s.CF.GetTemplateSummaryWithContext(ctx, &cloudformation.GetTemplateSummaryInput{
StackName: aws.String(stack),
})
Expand Down
Loading