closeAccount method
Closes an Amazon Web Services member account within an organization. You
can close an account when all
features are enabled . You can't close the management account with
this API. This is an asynchronous request that Amazon Web Services
performs in the background. Because CloseAccount operates
asynchronously, it can return a successful completion message even though
account closure might still be in progress. You need to wait a few minutes
before the account is fully closed. To check the status of the request, do
one of the following:
-
Use the
AccountIdthat you sent in theCloseAccountrequest to provide as a parameter to the DescribeAccount operation.While the close account request is in progress, Account status will indicate PENDING_CLOSURE. When the close account request completes, the status will change to SUSPENDED.
-
Check the CloudTrail log for the
CloseAccountResultevent that gets published after the account closes successfully. For information on using CloudTrail with Organizations, see Logging and monitoring in Organizations in the Organizations User Guide.
AccountDepartedOrganization event with
departedMethod:Cleaned and departedTime. This
event is available only in the management account's event history.
May throw AccessDeniedException.
May throw AccountAlreadyClosedException.
May throw AccountNotFoundException.
May throw AWSOrganizationsNotInUseException.
May throw ConcurrentModificationException.
May throw ConflictException.
May throw ConstraintViolationException.
May throw InvalidInputException.
May throw ServiceException.
May throw TooManyRequestsException.
May throw UnsupportedAPIEndpointException.
Parameter accountId :
Retrieves the Amazon Web Services account Id for the current
CloseAccount API request.
Implementation
Future<void> closeAccount({
required String accountId,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSOrganizationsV20161128.CloseAccount'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'AccountId': accountId,
},
);
}