rosswickman
1/23/2026 - 6:24 PM

Update AWS Account Contacts from Org

This snippet provides a comprehensive solution for managing contact details across an entire AWS Organization. It combines two automation workflows to ensure both Primary and Alternate contact records are standardized and up-to-date across all member accounts.

⚙️ Capabilities

  • Alternate Contact Automation: Updates specialized roles (Security, Operations, and Billing) across the organization using the account service client.
  • Primary Contact Standardization: Mass-updates primary corporate information, including full name, address, phone number, and company details.
  • Selective Targeting: Features a built-in exclusion logic to skip Management or sensitive accounts (e.g., 111111111111) during the update process.
  • Full Org Discovery: Uses the organizations paginator to ensure no accounts are missed in large environments.

🛠️ Configuration Notes

  • Permissions: Ensure the execution role has organizations:ListAccounts and account:PutContactInformation permissions.
  • Service Linked Roles: This script assumes the management account has the necessary permissions to manage these settings for member accounts.
  • Customization: Fill in the empty strings in the AlternateContactType and ContactInformation dictionaries with your corporate standard data before execution.

Supporting Blog Post: https://blog.sentri.cloud/automating-contact-updates-across-accounts-in-your-organization

import boto3

# Assuming org_client is already initialized
org_client = boto3.client('organizations')

# Collect all accounts using paginator
accounts = []
paginator = org_client.get_paginator('list_accounts')
for page in paginator.paginate():
    accounts.extend(page['Accounts'])

# Update the alternate contact details for each account in the organization
for account in accounts:
    account_id = account['Id']

    # Initialize a session using the AWS account
    account_session = boto3.Session()
    account_client = account_session.client('account')

    # Now you can use account_client to update alternate contact details or perform other actions
    try:
        # Update alternate contact details for the account
        account_client.put_alternate_contact(
            AccountId=account_id,
            AlternateContactType='SECURITY',
            Title='',
            EmailAddress='',
            Name='',
            PhoneNumber=''
        )
        account_client.put_alternate_contact(
            AccountId=account_id,
            AlternateContactType='OPERATIONS',
            Title='',
            EmailAddress='',
            Name='',
            PhoneNumber=''
        )
        account_client.put_alternate_contact(
            AccountId=account_id,
            AlternateContactType='BILLING',
            Title='',
            EmailAddress='',
            Name='',
            PhoneNumber=''
        )

        print(f"Updated alternate contact details for account: {account_id}")
    except Exception as e:
        print(f"Failed to update alternate contact details for account: {account_id}. Error: {e}")
import boto3

def put_contact_information(account_id):
    account_client = boto3.client('account')
    response = account_client.put_contact_information(
      AccountId=account_id,
      ContactInformation={
        'FullName': '',
        'AddressLine1': '',
        'City': '',
        'CountryCode': '',
        'CompanyName': '',
        'FullName': '',
        'PhoneNumber': '',
        'PostalCode': '',
        'StateOrRegion': '',
        'WebsiteUrl': '',
      }
  )

    if response['ResponseMetadata']['HTTPStatusCode'] == 200:
        print('Successfully updated contact information for account ID: {}'.format(account_id))
    else:
        print('Failed to update contact information for account ID: {}'.format(account_id))


def get_account_name(account_id):
    """
    Retrieve the name of the AWS account.

    :param account_id: ID of the AWS account
    :return: Name of the AWS account
    """
    client = boto3.client('organizations')
    response = client.describe_account(AccountId=account_id)
    return response['Account']['Name']

def main():
    """Loops through all accounts in an AWS organization and updates primary account information."""

    organizations_client = boto3.client('organizations')
    response = organizations_client.list_accounts()

    for account in response['Accounts']:
        account_id = account['Id']
        # Skip/Exclude the master account(s)
        if account_id != '222222222222' and account_id != '111111111111':
            put_contact_information(account_id)

if __name__ == '__main__':
    main()