Sort results from EC2 API

0

Hello,

I am starting with AWS SDK (for Go v2) and I cannot get my head wrapped around pagination - specifically I am unable to find out how do I sort list of any resource for example. It looks like DescribeInstanceTypes always return types in random order and there is literally nothing in the documentation about sort order. How pagination is useful when order is always random? I do not understand, is this only to workaround API limits/throttling? Are applications supposed to do ordering on their own?

Thanks for explanation, cheers!

2개 답변
2

Hello Lzap,

You can order your results in your own. For example, with the AWS CLI you can use JMESPath as it indicates the official documentation:

As an example, using AWS CLI you can order the DescribeInstanceTypes API invoking the API as:

aws ec2 describe-instance-types --query 'sort_by(InstanceTypes, &InstanceType)[].InstanceType'

Hope it helps.

Joan_B
답변함 2년 전
1

Sorting isn't supported server-side, so is done client-side after results are returned by the API (e.g. the CLI example Joan_B mentioned). You can filter server-side with some API calls by passing a Filter parameter. That, and pagination, are for coping with large numbers of records.

전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠