Filter out ECS anywhere instance IDs

This commit is contained in:
John Preston 2022-04-28 13:24:08 +01:00 committed by GitHub
parent 95257d2ee1
commit 6c2eb6eef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -392,6 +392,13 @@ func (p *Provider) lookupEc2Instances(ctx context.Context, client *awsClient, cl
for _, container := range resp.ContainerInstances { for _, container := range resp.ContainerInstances {
instanceIds[aws.StringValue(container.Ec2InstanceId)] = aws.StringValue(container.ContainerInstanceArn) 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) instanceArns = append(instanceArns, container.Ec2InstanceId)
} }
} }