in AccountCreationLambda.py [0:0]
def create_account(accountname, accountemail, accountrole, access_to_billing, scp, root_id, accountbilling):
"""Creates a new child account."""
account_id = 'None'
client = get_client('organizations')
try:
create_account_response = client.create_account(Email=accountemail, AccountName=accountname,
RoleName=accountrole,
IamUserAccessToBilling=access_to_billing,
Tags=[
{
"Key": "AccountBilling",
"Value": accountbilling
}
])
except botocore.exceptions.ClientError as exception:
print(exception)
sys.exit(1)
# time.sleep(30)
create_account_status_response = client.describe_create_account_status(
CreateAccountRequestId=create_account_response.get('CreateAccountStatus').get('Id'))
account_id = create_account_status_response.get('CreateAccountStatus').get('AccountId')
while account_id is None:
create_account_status_response = client.describe_create_account_status(
CreateAccountRequestId=create_account_response.get('CreateAccountStatus').get('Id'))
account_id = create_account_status_response.get('CreateAccountStatus').get('AccountId')
return (create_account_response, account_id)