Skip to content

assign_permission_set

assign_permission_set(
    environment_arn: EnvironmentArn,
    principal_type: PrincipalType,
    principal_id: PrincipalId,
    permission_set_id: PermissionSetId,
    *,
    config_overrides: Optional[AssuranceClientConfig] = None,
    scopes: Optional[AssignmentScopeList] = None,
) -> AssignPermissionSetOutput

Assigns a permission set to a principal with optional scopes.

Parameters:

  • environment_arn (EnvironmentArn) –

    The ARN of this governance environment.

  • principal_type (PrincipalType) –

    The type of principal the permission set is assigned to.

  • principal_id (PrincipalId) –

    The unique identifier of the principal the permission set is assigned to.

  • permission_set_id (PermissionSetId) –

    The identifier of the permission set.

  • scopes (Optional[AssignmentScopeList], default: None ) –

    The scopes the assignment applies to.

Raises:

Examples:

Assign a permission set Assigns the payments auditor permission set to an auditor's IAM Identity Center user, scoped to the payments-prod project.

>>> client.assign_permission_set(environment_arn='arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111', principal_type='USER', principal_id='a1b2c3d4-5678-90ab-cdef-EXAMPLE12345', permission_set_id='a1b2c3d4-5678-90ab-cdef-EXAMPLE88888', scopes=[{'type': 'PROJECT', 'id': 'payments-prod'}])
Source code in docs_src/capo_assurance/_services/assurance.py
def assign_permission_set(
    self,
    environment_arn: "capo_assurance.types.environment_arn.EnvironmentArn",
    principal_type: "capo_assurance.types.principal_type.PrincipalType",
    principal_id: "capo_assurance.types.principal_id.PrincipalId",
    permission_set_id: "capo_assurance.types.permission_set_id.PermissionSetId",
    *,
    config_overrides: Optional[AssuranceClientConfig] = None,
    scopes: Optional[
        "capo_assurance.types.assignment_scope_list.AssignmentScopeList"
    ] = None,
) -> "capo_assurance.types.assign_permission_set_output.AssignPermissionSetOutput":
    """<p>Assigns a permission set to a principal with optional scopes.</p>

    Args:
        environment_arn: <p>The ARN of this governance environment.</p>
        principal_type: <p>The type of principal the permission set is assigned to.</p>
        principal_id: <p>The unique identifier of the principal the permission set is assigned to.</p>
        permission_set_id: <p>The identifier of the permission set.</p>
        scopes: <p>The scopes the assignment applies to.</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.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource was not found.</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:
        Assign a permission set
        Assigns the payments auditor permission set to an auditor's IAM Identity Center user, scoped to the payments-prod project.

        >>> client.assign_permission_set(environment_arn='arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111', principal_type='USER', principal_id='a1b2c3d4-5678-90ab-cdef-EXAMPLE12345', permission_set_id='a1b2c3d4-5678-90ab-cdef-EXAMPLE88888', scopes=[{'type': 'PROJECT', 'id': 'payments-prod'}])
    """

    def _handler(
        req: "OperationRequest[capo_assurance.types.assign_permission_set_input.AssignPermissionSetInput]",
    ) -> OperationResponse[
        "capo_assurance.types.assign_permission_set_output.AssignPermissionSetOutput"
    ]:
        import capo_assurance._operations.assurance.assign_permission_set

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssignPermissionSet")
    )
    input_: capo_assurance.types.assign_permission_set_input.AssignPermissionSetInput = {
        "environment_arn": environment_arn,
        "principal_type": principal_type,
        "principal_id": principal_id,
        "permission_set_id": permission_set_id,
    }
    if scopes is not None:
        input_["scopes"] = scopes

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