Skip to content

create_permission async

create_permission(
    name: PermissionName,
    resource_type: String,
    policy_template: Policy,
    *,
    config_overrides: Optional[AsyncRAMClientConfig] = None,
    client_token: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreatePermissionResponse

Creates a customer managed permission for a specified resource type that you can attach to resource shares. It is created in the Amazon Web Services Region in which you call the operation.

Parameters:

  • name (PermissionName) –

    Specifies the name of the customer managed permission. The name must be unique within the Amazon Web Services Region.

  • resource_type (String) –

    Specifies the name of the resource type that this customer managed permission applies to.

    The format is : and is case sensitive. For example, to specify an Amazon EC2 Subnet, you can use the string ec2:Subnet. To see the list of valid values for this parameter, query the ListResourceTypes operation. This value must match the display name of the resource (available in ListResourceTypes).

  • policy_template (Policy) –

    A string in JSON format string that contains the following elements of a resource-based policy:

    • Effect: must be set to ALLOW.

    • Action: specifies the actions that are allowed by this customer managed permission. The list must contain only actions that are supported by the specified resource type. For a list of all actions supported by each resource type, see Actions, resources, and condition keys for Amazon Web Services services in the Identity and Access Management User Guide.

    • Condition: (optional) specifies conditional parameters that must evaluate to true when a user attempts an action for that action to be allowed. For more information about the Condition element, see IAM policies: Condition element in the Identity and Access Management User Guide.

    This template can't include either the Resource or Principal elements. Those are both filled in by RAM when it instantiates the resource-based policy on each resource shared using this managed permission. The Resource comes from the ARN of the specific resource that you are sharing. The Principal comes from the list of identities added to the resource share.

  • client_token (Optional[String], default: None ) –

    Specifies a unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value..

    If you don't provide this value, then Amazon Web Services generates a random one for you.

    If you retry the operation with the same ClientToken, but with different parameters, the retry fails with an IdempotentParameterMismatch error.

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

    Specifies a list of one or more tag key and value pairs to attach to the permission.

Raises:

Source code in docs_src/capo_ram/_services/async_ram.py
async def create_permission(
    self,
    name: "capo_ram.types.permission_name.PermissionName",
    resource_type: "capo_ram.types.string.String",
    policy_template: "capo_ram.types.policy.Policy",
    *,
    config_overrides: Optional[AsyncRAMClientConfig] = None,
    client_token: Optional["capo_ram.types.string.String"] = None,
    tags: Optional["capo_ram.types.tag_list.TagList"] = None,
) -> "capo_ram.types.create_permission_response.CreatePermissionResponse":
    """<p>Creates a customer managed permission for a specified resource type that you can attach to resource shares. It is created in the Amazon Web Services Region in which you call the operation.</p>

    Args:
        name: <p>Specifies the name of the customer managed permission. The name must be unique within the Amazon Web Services Region.</p>
        resource_type: <p>Specifies the name of the resource type that this customer managed permission applies to.</p> <p>The format is <code> <i><service-code></i>:<i><resource-type></i> </code> and is case sensitive. For example, to specify an Amazon EC2 Subnet, you can use the string <code>ec2:Subnet</code>. To see the list of valid values for this parameter, query the <a>ListResourceTypes</a> operation. This value must match the display name of the resource (available in <code>ListResourceTypes</code>).</p>
        policy_template: <p>A string in JSON format string that contains the following elements of a resource-based policy:</p> <ul> <li> <p> <b>Effect</b>: must be set to <code>ALLOW</code>.</p> </li> <li> <p> <b>Action</b>: specifies the actions that are allowed by this customer managed permission. The list must contain only actions that are supported by the specified resource type. For a list of all actions supported by each resource type, see <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html">Actions, resources, and condition keys for Amazon Web Services services</a> in the <i>Identity and Access Management User Guide</i>.</p> </li> <li> <p> <b>Condition</b>: (optional) specifies conditional parameters that must evaluate to true when a user attempts an action for that action to be allowed. For more information about the Condition element, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html">IAM policies: Condition element</a> in the <i>Identity and Access Management User Guide</i>.</p> </li> </ul> <p>This template can't include either the <code>Resource</code> or <code>Principal</code> elements. Those are both filled in by RAM when it instantiates the resource-based policy on each resource shared using this managed permission. The <code>Resource</code> comes from the ARN of the specific resource that you are sharing. The <code>Principal</code> comes from the list of identities added to the resource share.</p>
        client_token: <p>Specifies a unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a <a href="https://wikipedia.org/wiki/Universally_unique_identifier">UUID type of value.</a>.</p> <p>If you don't provide this value, then Amazon Web Services generates a random one for you.</p> <p>If you retry the operation with the same <code>ClientToken</code>, but with different parameters, the retry fails with an <code>IdempotentParameterMismatch</code> error.</p>
        tags: <p>Specifies a list of one or more tag key and value pairs to attach to the permission.</p>

    Raises:
        capo_ram.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>The operation failed because the client token input parameter matched one that was used with a previous call to the operation, but at least one of the other input parameters is different from the previous call.</p>
        capo_ram.errors.invalid_client_token_exception.InvalidClientTokenException: <p>The operation failed because the specified client token isn't valid.</p>
        capo_ram.errors.invalid_parameter_exception.InvalidParameterException: <p>The operation failed because a parameter you specified isn't valid.</p>
        capo_ram.errors.invalid_policy_exception.InvalidPolicyException: <p>The operation failed because a policy you specified isn't valid.</p>
        capo_ram.errors.malformed_policy_template_exception.MalformedPolicyTemplateException: <p>The operation failed because the policy template that you provided isn't valid.</p>
        capo_ram.errors.operation_not_permitted_exception.OperationNotPermittedException: <p>The operation failed because the requested operation isn't permitted.</p>
        capo_ram.errors.permission_already_exists_exception.PermissionAlreadyExistsException: <p>The operation failed because a permission with the specified name already exists in the requested Amazon Web Services Region. Choose a different name.</p>
        capo_ram.errors.permission_limit_exceeded_exception.PermissionLimitExceededException: <p>The operation failed because it would exceed the maximum number of permissions you can create in each Amazon Web Services Region. To view the limits for your Amazon Web Services account, see the <a href="https://console.aws.amazon.com/servicequotas/home/services/ram/quotas">RAM page in the Service Quotas console</a>.</p>
        capo_ram.errors.server_internal_exception.ServerInternalException: <p>The operation failed because the service could not respond to the request due to an internal problem. Try again later.</p>
        capo_ram.errors.service_unavailable_exception.ServiceUnavailableException: <p>The operation failed because the service isn't available. Try again later.</p>
        capo_ram.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ram.types.create_permission_request.CreatePermissionRequest]",
    ) -> AsyncOperationResponse[
        "capo_ram.types.create_permission_response.CreatePermissionResponse"
    ]:
        import capo_ram._operations.amazon_resource_sharing.create_permission

        (
            output,
            http_response,
        ) = await capo_ram._operations.amazon_resource_sharing.create_permission.async_create_permission(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePermission")
    )
    input_: capo_ram.types.create_permission_request.CreatePermissionRequest = {
        "name": name,
        "resource_type": resource_type,
        "policy_template": policy_template,
    }
    if client_token is not None:
        input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

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