Skip to content

associate_access_policy async

associate_access_policy(
    cluster_name: String,
    principal_arn: String,
    policy_arn: String,
    access_scope: AccessScope,
    *,
    config_overrides: Optional[AsyncEKSClientConfig] = None,
) -> AssociateAccessPolicyResponse

Associates an access policy and its scope to an access entry. For more information about associating access policies, see Associating and disassociating access policies to and from access entries in the Amazon EKS User Guide.

Parameters:

  • cluster_name (String) –

    The name of your cluster.

  • principal_arn (String) –

    The Amazon Resource Name (ARN) of the IAM user or role for the AccessEntry that you're associating the access policy to.

  • policy_arn (String) –

    The ARN of the AccessPolicy that you're associating. For a list of ARNs, use ListAccessPolicies.

  • access_scope (AccessScope) –

    The scope for the AccessPolicy. You can scope access policies to an entire cluster or to specific Kubernetes namespaces.

Raises:

  • InvalidParameterException –

    The specified parameter is invalid. Review the available parameters for the API request.

  • InvalidRequestException –

    The request is invalid given the state of the cluster. Check the state of the cluster and the associated operations.

  • ResourceNotFoundException –

    The specified resource could not be found. You can view your available clusters with ListClusters. You can view your available managed node groups with ListNodegroups. Amazon EKS clusters and node groups are Amazon Web Services Region specific.

  • ServerException –

    These errors are usually caused by a server-side issue.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_eks/_services/async_eks.py
async def associate_access_policy(
    self,
    cluster_name: "capo_eks.types.string.String",
    principal_arn: "capo_eks.types.string.String",
    policy_arn: "capo_eks.types.string.String",
    access_scope: "capo_eks.types.access_scope.AccessScope",
    *,
    config_overrides: Optional[AsyncEKSClientConfig] = None,
) -> (
    "capo_eks.types.associate_access_policy_response.AssociateAccessPolicyResponse"
):
    """<p>Associates an access policy and its scope to an access entry. For more information about associating access policies, see <a href="https://docs.aws.amazon.com/eks/latest/userguide/access-policies.html">Associating and disassociating access policies to and from access entries</a> in the <i>Amazon EKS User Guide</i>.</p>

    Args:
        cluster_name: <p>The name of your cluster.</p>
        principal_arn: <p>The Amazon Resource Name (ARN) of the IAM user or role for the <code>AccessEntry</code> that you're associating the access policy to. </p>
        policy_arn: <p>The ARN of the <code>AccessPolicy</code> that you're associating. For a list of ARNs, use <code>ListAccessPolicies</code>.</p>
        access_scope: <p>The scope for the <code>AccessPolicy</code>. You can scope access policies to an entire cluster or to specific Kubernetes namespaces.</p>

    Raises:
        capo_eks.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_eks.errors.invalid_request_exception.InvalidRequestException: <p>The request is invalid given the state of the cluster. Check the state of the cluster and the associated operations.</p>
        capo_eks.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource could not be found. You can view your available clusters with <code>ListClusters</code>. You can view your available managed node groups with <code>ListNodegroups</code>. Amazon EKS clusters and node groups are Amazon Web Services Region specific.</p>
        capo_eks.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_eks.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_eks.types.associate_access_policy_request.AssociateAccessPolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_eks.types.associate_access_policy_response.AssociateAccessPolicyResponse"
    ]:
        import capo_eks._operations.aws_wesley_frontend.associate_access_policy

        (
            output,
            http_response,
        ) = await capo_eks._operations.aws_wesley_frontend.associate_access_policy.async_associate_access_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateAccessPolicy")
    )
    input_: capo_eks.types.associate_access_policy_request.AssociateAccessPolicyRequest = {
        "cluster_name": cluster_name,
        "principal_arn": principal_arn,
        "policy_arn": policy_arn,
        "access_scope": access_scope,
    }

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