From 6c2eb6eef31d37b72e240ae82d662f613106501a Mon Sep 17 00:00:00 2001 From: John Preston <1236150+JohnPreston@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:24:08 +0100 Subject: [PATCH] Filter out ECS anywhere instance IDs --- pkg/provider/ecs/ecs.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/provider/ecs/ecs.go b/pkg/provider/ecs/ecs.go index 13dafd8d8..0cde14508 100644 --- a/pkg/provider/ecs/ecs.go +++ b/pkg/provider/ecs/ecs.go @@ -392,6 +392,13 @@ func (p *Provider) lookupEc2Instances(ctx context.Context, client *awsClient, cl for _, container := range resp.ContainerInstances { instanceIds[aws.StringValue(container.Ec2InstanceId)] = aws.StringValue(container.ContainerInstanceArn) + // Disallow Instance IDs of the form mi-* + // This prevents considering external instances in ECS Anywhere setups + // and getting InvalidInstanceID.Malformed error when calling the describe-instances endpoint. + if strings.HasPrefix(aws.StringValue(container.Ec2InstanceId), "mi-") { + continue + } + instanceArns = append(instanceArns, container.Ec2InstanceId) } }