Skip to content

create_subscription

create_subscription(
    plan_family: str,
    plan_tier: str,
    resource_arns: ResourceArns,
    *,
    config_overrides: Optional[PricingPlanManagerClientConfig] = None,
    usage_level: Optional[str] = None,
    approval_mode: Optional[ApprovalMode] = None,
    client_token: Optional[IdempotencyToken] = None,
) -> CreateSubscriptionOutput

Creates a flat-rate pricing subscription for the specified resources.

When approvalMode is set to MANUAL, paid-tier subscriptions are created in PENDING_APPROVAL status and require a separate ApprovePaidSubscription call before billing starts. Free-tier subscriptions are always activated immediately regardless of approval mode.

When approvalMode is set to IMMEDIATE or is not specified, the subscription is activated immediately.

Parameters:

  • plan_family (str) –

    The pricing plan family to subscribe to, such as CloudFront.

  • plan_tier (str) –

    The tier level for the subscription, such as FREE, PRO, BUSINESS, or PREMIUM.

  • usage_level (Optional[str], default: None ) –

    The usage level within the plan tier. Specify DEFAULT for the base configuration, or a higher level if your plan tier supports it.

  • resource_arns (ResourceArns) –

    The ARNs of the resources to include in the subscription. Specify one or more supported resources.

    For subscriptions in the CloudFront plan family, the resources must include exactly one Amazon CloudFront distribution and exactly one WAF web ACL. You can also include other supported resources, such as Amazon Route 53 hosted zones and CloudFront KeyValueStores.

  • approval_mode (Optional[ApprovalMode], default: None ) –

    Determines whether the subscription requires explicit approval before billing starts. Set to MANUAL to require a separate ApprovePaidSubscription call, or IMMEDIATE to activate the subscription right away. For paid tier plans, this defaults to MANUAL if not specified. For the FREE plan tier, only IMMEDIATE is supported, and it is the default.

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

    A unique, case-sensitive identifier that you provide to ensure that the request is handled only once. If you send the same request with the same client token, the API returns the original response without creating a duplicate subscription.

Raises:

  • AccessDeniedException –

    You do not have the required permissions to perform this operation. Verify that your IAM policy grants access to this action.

  • ConflictException –

    The request conflicts with the current state of the resource. This typically occurs when the ETag value in the If-Match header does not match the current version of the subscription. Retrieve the latest version and retry.

  • InternalServerException –

    An unexpected error occurred on the server. Retry the request.

  • ResourceNotFoundException –

    The specified subscription was not found. Verify that the ARN is correct and that the subscription belongs to your account.

  • ServiceQuotaExceededException –

    The request would exceed a service limit. You have reached the maximum number of subscriptions allowed for your account.

  • ThrottlingException –

    The request rate exceeds the allowed limit. Wait briefly and retry the request.

  • ValidationException –

    The request failed a business rule validation. For example, the specified resource might already be associated with another subscription, or the subscription might not be in the required state for this operation.

  • UnknownServiceError –

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

Examples:

Create a flat-rate pricing subscription (deferred approval)

>>> client.create_subscription(plan_family='CloudFront', plan_tier='PRO', resource_arns=['arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE', 'arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/a1b2c3d4'], approval_mode='MANUAL')
Create a subscription with approval mode
>>> client.create_subscription(plan_family='CloudFront', plan_tier='PRO', resource_arns=['arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE', 'arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/a1b2c3d4'], approval_mode='IMMEDIATE')
Source code in docs_src/capo_pricing_plan_manager/_services/pricing_plan_manager.py
def create_subscription(
    self,
    plan_family: str,
    plan_tier: str,
    resource_arns: "capo_pricing_plan_manager.types.resource_arns.ResourceArns",
    *,
    config_overrides: Optional[PricingPlanManagerClientConfig] = None,
    usage_level: Optional[str] = None,
    approval_mode: Optional[
        "capo_pricing_plan_manager.types.approval_mode.ApprovalMode"
    ] = None,
    client_token: Optional[
        "capo_pricing_plan_manager.types.idempotency_token.IdempotencyToken"
    ] = None,
) -> "capo_pricing_plan_manager.types.create_subscription_output.CreateSubscriptionOutput":
    """<p>Creates a flat-rate pricing subscription for the specified resources.</p> <note> <p>When <code>approvalMode</code> is set to <code>MANUAL</code>, paid-tier subscriptions are created in <code>PENDING_APPROVAL</code> status and require a separate <code>ApprovePaidSubscription</code> call before billing starts. Free-tier subscriptions are always activated immediately regardless of approval mode.</p> <p>When <code>approvalMode</code> is set to <code>IMMEDIATE</code> or is not specified, the subscription is activated immediately.</p> </note>

    Args:
        plan_family: <p>The pricing plan family to subscribe to, such as <code>CloudFront</code>.</p>
        plan_tier: <p>The tier level for the subscription, such as <code>FREE</code>, <code>PRO</code>, <code>BUSINESS</code>, or <code>PREMIUM</code>.</p>
        usage_level: <p>The usage level within the plan tier. Specify <code>DEFAULT</code> for the base configuration, or a higher level if your plan tier supports it.</p>
        resource_arns: <p>The ARNs of the resources to include in the subscription. Specify one or more supported resources.</p> <note> <p>For subscriptions in the CloudFront plan family, the resources must include exactly one Amazon CloudFront distribution and exactly one WAF web ACL. You can also include other supported resources, such as Amazon Route 53 hosted zones and CloudFront KeyValueStores.</p> </note>
        approval_mode: <p>Determines whether the subscription requires explicit approval before billing starts. Set to <code>MANUAL</code> to require a separate <code>ApprovePaidSubscription</code> call, or <code>IMMEDIATE</code> to activate the subscription right away. For paid tier plans, this defaults to <code>MANUAL</code> if not specified. For the <code>FREE</code> plan tier, only <code>IMMEDIATE</code> is supported, and it is the default.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure that the request is handled only once. If you send the same request with the same client token, the API returns the original response without creating a duplicate subscription.</p>

    Raises:
        capo_pricing_plan_manager.errors.access_denied_exception.AccessDeniedException: <p>You do not have the required permissions to perform this operation. Verify that your IAM policy grants access to this action.</p>
        capo_pricing_plan_manager.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. This typically occurs when the <code>ETag</code> value in the <code>If-Match</code> header does not match the current version of the subscription. Retrieve the latest version and retry.</p>
        capo_pricing_plan_manager.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred on the server. Retry the request.</p>
        capo_pricing_plan_manager.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified subscription was not found. Verify that the ARN is correct and that the subscription belongs to your account.</p>
        capo_pricing_plan_manager.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service limit. You have reached the maximum number of subscriptions allowed for your account.</p>
        capo_pricing_plan_manager.errors.throttling_exception.ThrottlingException: <p>The request rate exceeds the allowed limit. Wait briefly and retry the request.</p>
        capo_pricing_plan_manager.errors.validation_exception.ValidationException: <p>The request failed a business rule validation. For example, the specified resource might already be associated with another subscription, or the subscription might not be in the required state for this operation.</p>
        capo_pricing_plan_manager.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create a flat-rate pricing subscription (deferred approval)

        >>> client.create_subscription(plan_family='CloudFront', plan_tier='PRO', resource_arns=['arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE', 'arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/a1b2c3d4'], approval_mode='MANUAL')
        Create a subscription with approval mode

        >>> client.create_subscription(plan_family='CloudFront', plan_tier='PRO', resource_arns=['arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE', 'arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/a1b2c3d4'], approval_mode='IMMEDIATE')
    """

    def _handler(
        req: "OperationRequest[capo_pricing_plan_manager.types.create_subscription_input.CreateSubscriptionInput]",
    ) -> OperationResponse[
        "capo_pricing_plan_manager.types.create_subscription_output.CreateSubscriptionOutput"
    ]:
        import capo_pricing_plan_manager._operations.aws_pricing_plan_manager.create_subscription

        output, http_response = (
            capo_pricing_plan_manager._operations.aws_pricing_plan_manager.create_subscription.create_subscription(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSubscription")
    )
    input_: capo_pricing_plan_manager.types.create_subscription_input.CreateSubscriptionInput = {
        "plan_family": plan_family,
        "plan_tier": plan_tier,
        "resource_arns": resource_arns,
    }
    if usage_level is not None:
        input_["usage_level"] = usage_level
    if approval_mode is not None:
        input_["approval_mode"] = approval_mode
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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