Skip to content

create_public_key

create_public_key(
    public_key_config: PublicKeyConfig,
    *,
    config_overrides: Optional[CloudFrontClientConfig] = None,
) -> CreatePublicKeyResult

Uploads a public key to CloudFront that you can use with signed URLs and signed cookies, or with field-level encryption.

Parameters:

  • public_key_config (PublicKeyConfig) –

    A CloudFront public key configuration.

Raises:

Source code in docs_src/capo_cloudfront/_services/cloud_front.py
def create_public_key(
    self,
    public_key_config: "capo_cloudfront.types.public_key_config.PublicKeyConfig",
    *,
    config_overrides: Optional[CloudFrontClientConfig] = None,
) -> "capo_cloudfront.types.create_public_key_result.CreatePublicKeyResult":
    """<p>Uploads a public key to CloudFront that you can use with <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html">signed URLs and signed cookies</a>, or with <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html">field-level encryption</a>.</p>

    Args:
        public_key_config: <p>A CloudFront public key configuration.</p>

    Raises:
        capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</p>
        capo_cloudfront.errors.public_key_already_exists.PublicKeyAlreadyExists: <p>The specified public key already exists.</p>
        capo_cloudfront.errors.too_many_public_keys.TooManyPublicKeys: <p>The maximum number of public keys for field-level encryption have been created. To create a new public key, delete one of the existing keys.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudfront.types.create_public_key_request.CreatePublicKeyRequest]",
    ) -> OperationResponse[
        "capo_cloudfront.types.create_public_key_result.CreatePublicKeyResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.create_public_key

        output, http_response = (
            capo_cloudfront._operations.cloudfront2020_05_31.create_public_key.create_public_key(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePublicKey")
    )
    input_: capo_cloudfront.types.create_public_key_request.CreatePublicKeyRequest = {
        "public_key_config": public_key_config
    }

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