User Tools

Site Tools


aws:orgs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
aws:orgs [10/12/2024 09:55] – created andrewaws:orgs [11/02/2025 10:35] (current) andrew
Line 1: Line 1:
 ====== Organisations ====== ====== Organisations ======
 +
 +Get Root ID
 +
 +With text output:-
 +  OrgRoot=$(aws organizations list-roots --query 'Roots[0].Id' --output text)
 +
 +Using JQ:-
 +  OrgToot=$(aws organizations list-roots | jq -r .Roots.[0].Id)
  
  
 ===== Get a list of OU's in an organisation ===== ===== Get a list of OU's in an organisation =====
 +
 +
 +  OU_IDs=$(aws organizations describe-organization --query 'Organization.Id' --output text)  
 +
  
  
Line 15: Line 27:
 printf "OUs:- ${OUS}\n\n" printf "OUs:- ${OUS}\n\n"
 </code> </code>
 +
 +
 +Seearch for an OU by name:-
 +<code bash>
 +SpecificOU=$(aws organizations list-organizational-units-for-parent \
 +    --parent-id $RootId \
 +    --query 'OrganizationalUnits[?Name==`SpecificOU`].Id' --output text )
 +</code>
 +
 +
 +===== Truncate account number =====
 +
 +Sometimes you may want to point to an account, but not reveal the full account number, this code will truncate your account to a specified length.
 +
 +<code python>
 +$ cat truncate.py
 +#!/usr/bin/python3
 +
 +account = '123456784321'
 +removechar = 6
 +
 +result1 = account[removechar:]
 +result2 = account[removechar:len(account)]
 +print(result1, result2)
 +
 +$ ./truncate.py
 +784321 784321
 +
 +</code>
 +
 +
 +
 +
aws/orgs.1733824500.txt.gz · Last modified: by andrew

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki