I have this weird behavior when running a bash script using AWS CLI: all is fine during my testing on a simple organization, but then it fails when I have too many Organizational Units.
Here is the line I used:
aws organizations list-organizational-units-for-parent \
--parent-id "$RootId" \
--query "OrganizationalUnits[?Name='$OuName'].Id | [0]" \
--output text
I'm looking for the ID of a certain OU. So I'm listing the OUs under roor, and filter by name. Then I retrieve the ID, and keep only the first element returned. This worked fine on a simple organization. However, when I have too many OUs and the command starts paginating, I have this weird result:
None
ou-1x23-abcd1234
As if the text output is applied for each page. So I had to update the line to use tr instead:
aws organizations list-organizational-units-for-parent \
--parent-id "$RootId" \
--query "OrganizationalUnits[?Name='$OuName'].Id | [0]" \
| tr -d '[:space:]"'
So, bug or feature?
No comments:
Post a Comment