Skip to content

Commit

Permalink
Fallback to user-provided cluster from metadata (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
austindrenski authored Nov 8, 2023
1 parent 5e94b1a commit 8b2912f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
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 *ComposeECS) 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

0 comments on commit 8b2912f

Please sign in to comment.