Generates an account status report. The report is generated asynchronously, and can take several hours to complete.
The report provides the current status of all attributes supported by declarative policies for the accounts within the specified scope. The scope is determined by the specified TargetId, which can represent an individual account, or all the accounts that fall under the specified organizational unit (OU) or root (the entire Amazon Web Services Organization).
The report is saved to your specified S3 bucket, using the following path structure (with the capitalized placeholders representing your specific values):
s3://AMZN-S3-DEMO-BUCKET/YOUR-OPTIONAL-S3-PREFIX/ec2_TARGETID_REPORTID_YYYYMMDDTHHMMZ.csv
Prerequisites for generating a report
-
The StartDeclarativePoliciesReport API can only be called by the management account or delegated administrators for the organization.
-
An S3 bucket must be available before generating the report (you can create a new one or use an existing one), it must be in the same Region where the report generation request is made, and it must have an appropriate bucket policy. For a sample S3 policy, see Sample Amazon S3 policy under Examples.
-
Trusted access must be enabled for the service for which the declarative policy will enforce a baseline configuration. If you use the Amazon Web Services Organizations console, this is done automatically when you enable declarative policies. The API uses the following service principal to identify the EC2 service: ec2.amazonaws.com. For more information on how to enable trusted access with the Amazon Web Services CLI and Amazon Web Services SDKs, see Using Organizations with other Amazon Web Services services in the Amazon Web Services Organizations User Guide.
-
Only one report per organization can be generated at a time. Attempting to generate a report while another is in progress will result in an error.
For more information, including the required IAM permissions to run this API, see Generating the account status report for declarative policies in the Amazon Web Services Organizations User Guide.
Parameters:
-
dry_run
(Optional[Boolean], default:
None
)
–
Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
-
s3_bucket
(Optional[String], default:
None
)
–
The name of the S3 bucket where the report will be saved. The bucket must be in the same Region where the report generation request is made.
-
s3_prefix
(Optional[String], default:
None
)
–
The prefix for your S3 object.
-
target_id
(Optional[String], default:
None
)
–
The root ID, organizational unit ID, or account ID.
Format:
-
tag_specifications
(Optional[TagSpecificationList], default:
None
)
–
Raises:
Source code in docs_src/capo_ec2/_services/async_ec2.py
| async def start_declarative_policies_report(
self,
*,
config_overrides: Optional[AsyncEC2ClientConfig] = None,
dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
s3_bucket: Optional["capo_ec2.types.string.String"] = None,
s3_prefix: Optional["capo_ec2.types.string.String"] = None,
target_id: Optional["capo_ec2.types.string.String"] = None,
tag_specifications: Optional[
"capo_ec2.types.tag_specification_list.TagSpecificationList"
] = None,
) -> "capo_ec2.types.start_declarative_policies_report_result.StartDeclarativePoliciesReportResult":
"""<p>Generates an account status report. The report is generated asynchronously, and can take several hours to complete.</p> <p>The report provides the current status of all attributes supported by declarative policies for the accounts within the specified scope. The scope is determined by the specified <code>TargetId</code>, which can represent an individual account, or all the accounts that fall under the specified organizational unit (OU) or root (the entire Amazon Web Services Organization).</p> <p>The report is saved to your specified S3 bucket, using the following path structure (with the capitalized placeholders representing your specific values):</p> <p> <code>s3://AMZN-S3-DEMO-BUCKET/YOUR-OPTIONAL-S3-PREFIX/ec2_TARGETID_REPORTID_YYYYMMDDTHHMMZ.csv</code> </p> <p class="title"> <b>Prerequisites for generating a report</b> </p> <ul> <li> <p>The <code>StartDeclarativePoliciesReport</code> API can only be called by the management account or delegated administrators for the organization.</p> </li> <li> <p>An S3 bucket must be available before generating the report (you can create a new one or use an existing one), it must be in the same Region where the report generation request is made, and it must have an appropriate bucket policy. For a sample S3 policy, see <i>Sample Amazon S3 policy</i> under <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_StartDeclarativePoliciesReport.html#API_StartDeclarativePoliciesReport_Examples">Examples</a>.</p> </li> <li> <p>Trusted access must be enabled for the service for which the declarative policy will enforce a baseline configuration. If you use the Amazon Web Services Organizations console, this is done automatically when you enable declarative policies. The API uses the following service principal to identify the EC2 service: <code>ec2.amazonaws.com</code>. For more information on how to enable trusted access with the Amazon Web Services CLI and Amazon Web Services SDKs, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services.html">Using Organizations with other Amazon Web Services services</a> in the <i>Amazon Web Services Organizations User Guide</i>.</p> </li> <li> <p>Only one report per organization can be generated at a time. Attempting to generate a report while another is in progress will result in an error.</p> </li> </ul> <p>For more information, including the required IAM permissions to run this API, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_declarative_status-report.html">Generating the account status report for declarative policies</a> in the <i>Amazon Web Services Organizations User Guide</i>.</p>
Args:
dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
s3_bucket: <p>The name of the S3 bucket where the report will be saved. The bucket must be in the same Region where the report generation request is made.</p>
s3_prefix: <p>The prefix for your S3 object.</p>
target_id: <p>The root ID, organizational unit ID, or account ID.</p> <p>Format:</p> <ul> <li> <p>For root: <code>r-ab12</code> </p> </li> <li> <p>For OU: <code>ou-ab12-cdef1234</code> </p> </li> <li> <p>For account: <code>123456789012</code> </p> </li> </ul>
tag_specifications: <p>The tags to apply.</p>
Raises:
capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_ec2.types.start_declarative_policies_report_request.StartDeclarativePoliciesReportRequest]",
) -> AsyncOperationResponse[
"capo_ec2.types.start_declarative_policies_report_result.StartDeclarativePoliciesReportResult"
]:
import capo_ec2._operations.amazon_ec2.start_declarative_policies_report
(
output,
http_response,
) = await capo_ec2._operations.amazon_ec2.start_declarative_policies_report.async_start_declarative_policies_report(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("StartDeclarativePoliciesReport")
)
input_: capo_ec2.types.start_declarative_policies_report_request.StartDeclarativePoliciesReportRequest = {}
if dry_run is not None:
input_["dry_run"] = dry_run
if s3_bucket is not None:
input_["s3_bucket"] = s3_bucket
if s3_prefix is not None:
input_["s3_prefix"] = s3_prefix
if target_id is not None:
input_["target_id"] = target_id
if tag_specifications is not None:
input_["tag_specifications"] = tag_specifications
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|