createOrganization method

Future<CreateOrganizationResponse> createOrganization({
  1. OrganizationFeatureSet? featureSet,
})

Creates an Amazon Web Services organization. The account whose user is calling the CreateOrganization operation automatically becomes the management account of the new organization.

This operation must be called using credentials from the account that is to become the new organization's management account. The principal must also have the relevant IAM permissions.

By default (or if you set the FeatureSet parameter to ALL), the new organization is created with all features enabled and service control policies automatically enabled in the root. If you instead choose to create the organization supporting only the consolidated billing features by setting the FeatureSet parameter to CONSOLIDATED_BILLING, no policy types are enabled by default and you can't use organization policies.

The AccountJoinedOrganization event is logged in CloudTrail and is available only in the management account's event history. This event includes joinedMethod:Invited and joinedTime fields to provide context on how and when the account joined the organization.

May throw AccessDeniedException. May throw AccessDeniedForDependencyException. May throw AlreadyInOrganizationException. May throw ConcurrentModificationException. May throw ConstraintViolationException. May throw InvalidInputException. May throw ServiceException. May throw TooManyRequestsException.

Parameter featureSet : Specifies the feature set supported by the new organization. Each feature set supports different levels of functionality.

  • CONSOLIDATED_BILLING: All member accounts have their bills consolidated to and paid by the management account. For more information, see Consolidated billing in the Organizations User Guide.

    The consolidated billing feature subset isn't available for organizations in the Amazon Web Services GovCloud (US) Region.

  • ALL: In addition to all the features supported by the consolidated billing feature set, the management account can also apply any policy type to any member account in the organization. For more information, see All features in the Organizations User Guide.

Implementation

Future<CreateOrganizationResponse> createOrganization({
  OrganizationFeatureSet? featureSet,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSOrganizationsV20161128.CreateOrganization'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (featureSet != null) 'FeatureSet': featureSet.value,
    },
  );

  return CreateOrganizationResponse.fromJson(jsonResponse.body);
}