Skip to content

create_environment

create_environment(
    environment_name: EnvironmentName,
    *,
    config_overrides: Optional[AssuranceClientConfig] = None,
    description: Optional[EnvironmentDescription] = None,
    domain_prefix: Optional[DomainPrefix] = None,
    operator_role: Optional[IamRoleArn] = None,
    identity_store: Optional[IdentityStoreConfig] = None,
    kms_key_arn: Optional[KmsKeyArn] = None,
    regions: Optional[RegionList] = None,
    environment_scope: Optional[EnvironmentScope] = None,
    organizational_unit_ids: Optional[OrganizationalUnitIdList] = None,
    tags: Optional[TagList] = None,
) -> CreateEnvironmentOutput

Creates a new governance environment with the specified name and service role. If you provide identityStore, AWS Assurance creates an IAM Identity Center managed application for the environment.

Parameters:

  • environment_name (EnvironmentName) –

    The name of the environment.

  • description (Optional[EnvironmentDescription], default: None ) –

    A description of the environment.

  • domain_prefix (Optional[DomainPrefix], default: None ) –

    The optional custom domain prefix for the environment portal URL. The prefix must be unique within the AWS Region. If you don't specify a prefix, AWS Assurance uses the environment ID. You can't change the prefix after you create the environment.

  • operator_role (Optional[IamRoleArn], default: None ) –

    The AWS Identity and Access Management (IAM) role that AWS Assurance assumes to issue temporary credentials to operators who use your application. You must specify this role to support operator sessions. The role's trust policy must allow the AWS Assurance service principal to call sts:AssumeRole.

  • identity_store (Optional[IdentityStoreConfig], default: None ) –

    The identity store configuration.

  • kms_key_arn (Optional[KmsKeyArn], default: None ) –

    The ARN of an optional AWS KMS key that encrypts evidence. The AWS Assurance service role must have kms:Decrypt and kms:GenerateDataKey permissions on this key.

  • regions (Optional[RegionList], default: None ) –

    The AWS Regions to evaluate across. When empty or omitted, the environment evaluates all generally available Regions in the partition. Applies to all accounts in scope.

  • environment_scope (Optional[EnvironmentScope], default: None ) –

    The set of AWS accounts that the new environment evaluates. If you omit the scope, AWS Assurance uses SINGLE_ACCOUNT. Valid values:

    • ORGANIZATION – Evaluates the member accounts in your organization in AWS Organizations. Call this operation from the management account or a delegated administrator account, with trusted access for AWS Assurance turned on.

    • SINGLE_ACCOUNT – Evaluates only the account where you create the environment.

  • organizational_unit_ids (Optional[OrganizationalUnitIdList], default: None ) –

    The organizational units to scope the organization environment's evaluation to. Only valid when the environment scope is ORGANIZATION. When omitted, the entire organization is in scope. Must contain at least one OU when provided. Accounts in nested OUs under a listed OU are included.

  • tags (Optional[TagList], default: None ) –

    The tags attached to the resource, as key-value pairs.

Raises:

Examples:

Create a governance environment Creates a single-account governance environment for the payments team to run its PCI-DSS assessment.

>>> client.create_environment(environment_name='payments-governance', description="Governance environment for the payments team's PCI-DSS assessment.", domain_prefix='payments-prod', environment_scope='SINGLE_ACCOUNT')
Source code in docs_src/capo_assurance/_services/assurance.py
def create_environment(
    self,
    environment_name: "capo_assurance.types.environment_name.EnvironmentName",
    *,
    config_overrides: Optional[AssuranceClientConfig] = None,
    description: Optional[
        "capo_assurance.types.environment_description.EnvironmentDescription"
    ] = None,
    domain_prefix: Optional[
        "capo_assurance.types.domain_prefix.DomainPrefix"
    ] = None,
    operator_role: Optional["capo_assurance.types.iam_role_arn.IamRoleArn"] = None,
    identity_store: Optional[
        "capo_assurance.types.identity_store_config.IdentityStoreConfig"
    ] = None,
    kms_key_arn: Optional["capo_assurance.types.kms_key_arn.KmsKeyArn"] = None,
    regions: Optional["capo_assurance.types.region_list.RegionList"] = None,
    environment_scope: Optional[
        "capo_assurance.types.environment_scope.EnvironmentScope"
    ] = None,
    organizational_unit_ids: Optional[
        "capo_assurance.types.organizational_unit_id_list.OrganizationalUnitIdList"
    ] = None,
    tags: Optional["capo_assurance.types.tag_list.TagList"] = None,
) -> "capo_assurance.types.create_environment_output.CreateEnvironmentOutput":
    """<p>Creates a new governance environment with the specified name and service role. If you provide <code>identityStore</code>, AWS Assurance creates an IAM Identity Center managed application for the environment.</p>

    Args:
        environment_name: <p>The name of the environment.</p>
        description: <p>A description of the environment.</p>
        domain_prefix: <p>The optional custom domain prefix for the environment portal URL. The prefix must be unique within the AWS Region. If you don't specify a prefix, AWS Assurance uses the environment ID. You can't change the prefix after you create the environment.</p>
        operator_role: <p>The AWS Identity and Access Management (IAM) role that AWS Assurance assumes to issue temporary credentials to operators who use your application. You must specify this role to support operator sessions. The role's trust policy must allow the AWS Assurance service principal to call <code>sts:AssumeRole</code>.</p>
        identity_store: <p>The identity store configuration.</p>
        kms_key_arn: <p>The ARN of an optional AWS KMS key that encrypts evidence. The AWS Assurance service role must have <code>kms:Decrypt</code> and <code>kms:GenerateDataKey</code> permissions on this key.</p>
        regions: <p>The AWS Regions to evaluate across. When empty or omitted, the environment evaluates all generally available Regions in the partition. Applies to all accounts in scope.</p>
        environment_scope: <p>The set of AWS accounts that the new environment evaluates. If you omit the scope, AWS Assurance uses <code>SINGLE_ACCOUNT</code>. Valid values:</p> <ul> <li> <p> <code>ORGANIZATION</code> – Evaluates the member accounts in your organization in AWS Organizations. Call this operation from the management account or a delegated administrator account, with trusted access for AWS Assurance turned on.</p> </li> <li> <p> <code>SINGLE_ACCOUNT</code> – Evaluates only the account where you create the environment.</p> </li> </ul>
        organizational_unit_ids: <p>The organizational units to scope the organization environment's evaluation to. Only valid when the environment scope is ORGANIZATION. When omitted, the entire organization is in scope. Must contain at least one OU when provided. Accounts in nested OUs under a listed OU are included.</p>
        tags: <p>The tags attached to the resource, as key-value pairs.</p>

    Raises:
        capo_assurance.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action. This error occurs when the request is unauthenticated, or is authenticated but lacks permission to invoke the operation.</p>
        capo_assurance.errors.conflict_exception.ConflictException: <p>A conflict occurred (for example, resource already exists).</p>
        capo_assurance.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred.</p>
        capo_assurance.errors.throttling_exception.ThrottlingException: <p>The request was throttled.</p>
        capo_assurance.errors.validation_exception.ValidationException: <p>The request failed validation.</p>
        capo_assurance.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create a governance environment
        Creates a single-account governance environment for the payments team to run its PCI-DSS assessment.

        >>> client.create_environment(environment_name='payments-governance', description="Governance environment for the payments team's PCI-DSS assessment.", domain_prefix='payments-prod', environment_scope='SINGLE_ACCOUNT')
    """

    def _handler(
        req: "OperationRequest[capo_assurance.types.create_environment_input.CreateEnvironmentInput]",
    ) -> OperationResponse[
        "capo_assurance.types.create_environment_output.CreateEnvironmentOutput"
    ]:
        import capo_assurance._operations.assurance.create_environment

        output, http_response = (
            capo_assurance._operations.assurance.create_environment.create_environment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEnvironment")
    )
    input_: capo_assurance.types.create_environment_input.CreateEnvironmentInput = {
        "environment_name": environment_name
    }
    if description is not None:
        input_["description"] = description
    if domain_prefix is not None:
        input_["domain_prefix"] = domain_prefix
    if operator_role is not None:
        input_["operator_role"] = operator_role
    if identity_store is not None:
        input_["identity_store"] = identity_store
    if kms_key_arn is not None:
        input_["kms_key_arn"] = kms_key_arn
    if regions is not None:
        input_["regions"] = regions
    if environment_scope is not None:
        input_["environment_scope"] = environment_scope
    if organizational_unit_ids is not None:
        input_["organizational_unit_ids"] = organizational_unit_ids
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output