Skip to content

put_resource_policy async

put_resource_policy(
    resource_arn: ResourceArn,
    policy: PolicyString,
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
) -> PutResourcePolicyResponse

Attaches a resource-based permission policy to the Amazon Web Services Migration Hub Refactor Spaces environment. The policy must contain the same actions and condition statements as the arn:aws:ram::aws:permission/AWSRAMDefaultPermissionRefactorSpacesEnvironment permission in Resource Access Manager. The policy must not contain new lines or blank lines.

Parameters:

  • resource_arn (ResourceArn) –

    The Amazon Resource Name (ARN) of the resource to which the policy is being attached.

  • policy (PolicyString) –

    A JSON-formatted string for an Amazon Web Services resource-based policy.

Raises:

Source code in docs_src/capo_migration_hub_refactor_spaces/_services/async_migration_hub_refactor_spaces.py
async def put_resource_policy(
    self,
    resource_arn: "capo_migration_hub_refactor_spaces.types.resource_arn.ResourceArn",
    policy: "capo_migration_hub_refactor_spaces.types.policy_string.PolicyString",
    *,
    config_overrides: Optional[AsyncMigrationHubRefactorSpacesClientConfig] = None,
) -> "capo_migration_hub_refactor_spaces.types.put_resource_policy_response.PutResourcePolicyResponse":
    """<p>Attaches a resource-based permission policy to the Amazon Web Services Migration Hub Refactor Spaces environment. The policy must contain the same actions and condition statements as the <code>arn:aws:ram::aws:permission/AWSRAMDefaultPermissionRefactorSpacesEnvironment</code> permission in Resource Access Manager. The policy must not contain new lines or blank lines. </p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource to which the policy is being attached. </p>
        policy: <p>A JSON-formatted string for an Amazon Web Services resource-based policy. </p>

    Raises:
        capo_migration_hub_refactor_spaces.errors.access_denied_exception.AccessDeniedException: <p>The user does not have sufficient access to perform this action. </p>
        capo_migration_hub_refactor_spaces.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred while processing the request.</p>
        capo_migration_hub_refactor_spaces.errors.invalid_resource_policy_exception.InvalidResourcePolicyException: <p>The resource policy is not valid.</p>
        capo_migration_hub_refactor_spaces.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource that does not exist. </p>
        capo_migration_hub_refactor_spaces.errors.throttling_exception.ThrottlingException: <p>Request was denied because the request was throttled. </p>
        capo_migration_hub_refactor_spaces.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Service. </p>
        capo_migration_hub_refactor_spaces.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_migration_hub_refactor_spaces.types.put_resource_policy_request.PutResourcePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_migration_hub_refactor_spaces.types.put_resource_policy_response.PutResourcePolicyResponse"
    ]:
        import capo_migration_hub_refactor_spaces._operations.refactor_spaces.put_resource_policy

        (
            output,
            http_response,
        ) = await capo_migration_hub_refactor_spaces._operations.refactor_spaces.put_resource_policy.async_put_resource_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutResourcePolicy")
    )
    input_: capo_migration_hub_refactor_spaces.types.put_resource_policy_request.PutResourcePolicyRequest = {
        "resource_arn": resource_arn,
        "policy": policy,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output