Use CreateAccount with an Amazon SDK or CLI - Amazon Organizations
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use CreateAccount with an Amazon SDK or CLI

The following code examples show how to use CreateAccount.

.NET
Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Creates a new AWS Organizations account. /// </summary> public class CreateAccount { /// <summary> /// Initializes an Organizations client object and uses it to create /// the new account with the name specified in accountName. /// </summary> public static async Task Main() { IAmazonOrganizations client = new AmazonOrganizationsClient(); var accountName = "ExampleAccount"; var email = "someone@example.com"; var request = new CreateAccountRequest { AccountName = accountName, Email = email, }; var response = await client.CreateAccountAsync(request); var status = response.CreateAccountStatus; Console.WriteLine($"The staus of {status.AccountName} is {status.State}."); } }
  • For API details, see CreateAccount in Amazon SDK for .NET API Reference.

CLI
Amazon CLI

To create a member account that is automatically part of the organization

The following example shows how to create a member account in an organization. The member account is configured with the name Production Account and the email address of susan@example.com. Organizations automatically creates an IAM role using the default name of OrganizationAccountAccessRole because the roleName parameter is not specified. Also, the setting that allows IAM users or roles with sufficient permissions to access account billing data is set to the default value of ALLOW because the IamUserAccessToBilling parameter is not specified. Organizations automatically sends Susan a "Welcome to Amazon" email:

aws organizations create-account --email susan@example.com --account-name "Production Account"

The output includes a request object that shows that the status is now IN_PROGRESS:

{ "CreateAccountStatus": { "State": "IN_PROGRESS", "Id": "car-examplecreateaccountrequestid111" } }

You can later query the current status of the request by providing the Id response value to the describe-create-account-status command as the value for the create-account-request-id parameter.

For more information, see Creating an Amazon Account in Your Organization in the Amazon Organizations Users Guide.

  • For API details, see CreateAccount in Amazon CLI Command Reference.

For a complete list of Amazon SDK developer guides and code examples, see Using Amazon Organizations with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.