Skip to content

create_key_group async

create_key_group(
    key_group_config: KeyGroupConfig,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> CreateKeyGroupResult

Creates a key group that you can use with CloudFront signed URLs and signed cookies.

To create a key group, you must specify at least one public key for the key group. After you create a key group, you can reference it from one or more cache behaviors. When you reference a key group in a cache behavior, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with a private key whose corresponding public key is in the key group. The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see Serving private content in the Amazon CloudFront Developer Guide.

Parameters:

Raises:

  • InvalidArgument –

    An argument is invalid.

  • KeyGroupAlreadyExists –

    A key group with this name already exists. You must provide a unique name. To modify an existing key group, use UpdateKeyGroup.

  • TooManyKeyGroups –

    You have reached the maximum number of key groups for this Amazon Web Services account. For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide.

  • TooManyPublicKeysInKeyGroup –

    The number of public keys in this key group is more than the maximum allowed. For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide.

  • UnknownServiceError –

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

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def create_key_group(
    self,
    key_group_config: "capo_cloudfront.types.key_group_config.KeyGroupConfig",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> "capo_cloudfront.types.create_key_group_result.CreateKeyGroupResult":
    """<p>Creates a key group that you can use with <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html">CloudFront signed URLs and signed cookies</a>.</p> <p>To create a key group, you must specify at least one public key for the key group. After you create a key group, you can reference it from one or more cache behaviors. When you reference a key group in a cache behavior, CloudFront requires signed URLs or signed cookies for all requests that match the cache behavior. The URLs or cookies must be signed with a private key whose corresponding public key is in the key group. The signed URL or cookie contains information about which public key CloudFront should use to verify the signature. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html">Serving private content</a> in the <i>Amazon CloudFront Developer Guide</i>.</p>

    Args:
        key_group_config: <p>A key group configuration.</p>

    Raises:
        capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</p>
        capo_cloudfront.errors.key_group_already_exists.KeyGroupAlreadyExists: <p>A key group with this name already exists. You must provide a unique name. To modify an existing key group, use <code>UpdateKeyGroup</code>.</p>
        capo_cloudfront.errors.too_many_key_groups.TooManyKeyGroups: <p>You have reached the maximum number of key groups for this Amazon Web Services account. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_public_keys_in_key_group.TooManyPublicKeysInKeyGroup: <p>The number of public keys in this key group is more than the maximum allowed. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.create_key_group_request.CreateKeyGroupRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudfront.types.create_key_group_result.CreateKeyGroupResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.create_key_group

        (
            output,
            http_response,
        ) = await capo_cloudfront._operations.cloudfront2020_05_31.create_key_group.async_create_key_group(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateKeyGroup")
    )
    input_: capo_cloudfront.types.create_key_group_request.CreateKeyGroupRequest = {
        "key_group_config": key_group_config
    }

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