Skip to content

create_branch async

create_branch(
    app_id: AppId,
    branch_name: BranchName,
    *,
    config_overrides: Optional[AsyncAmplifyClientConfig] = None,
    description: Optional[Description] = None,
    stage: Optional[Stage] = None,
    framework: Optional[Framework] = None,
    enable_notification: Optional[EnableNotification] = None,
    enable_auto_build: Optional[EnableAutoBuild] = None,
    enable_skew_protection: Optional[EnableSkewProtection] = None,
    environment_variables: Optional[EnvironmentVariables] = None,
    basic_auth_credentials: Optional[BasicAuthCredentials] = None,
    enable_basic_auth: Optional[EnableBasicAuth] = None,
    enable_performance_mode: Optional[EnablePerformanceMode] = None,
    tags: Optional[TagMap] = None,
    build_spec: Optional[BuildSpec] = None,
    ttl: Optional[TTL] = None,
    display_name: Optional[DisplayName] = None,
    enable_pull_request_preview: Optional[EnablePullRequestPreview] = None,
    pull_request_environment_name: Optional[PullRequestEnvironmentName] = None,
    backend_environment_arn: Optional[BackendEnvironmentArn] = None,
    backend: Optional[Backend] = None,
    compute_role_arn: Optional[ComputeRoleArn] = None,
) -> CreateBranchResult

Creates a new branch for an Amplify app.

Parameters:

  • app_id (AppId) –

    The unique ID for an Amplify app.

  • branch_name (BranchName) –

    The name for the branch.

  • description (Optional[Description], default: None ) –

    The description for the branch.

  • stage (Optional[Stage], default: None ) –

    Describes the current stage for the branch.

  • framework (Optional[Framework], default: None ) –

    The framework for the branch.

  • enable_notification (Optional[EnableNotification], default: None ) –

    Enables notifications for the branch.

  • enable_auto_build (Optional[EnableAutoBuild], default: None ) –

    Enables auto building for the branch.

  • enable_skew_protection (Optional[EnableSkewProtection], default: None ) –

    Specifies whether the skew protection feature is enabled for the branch.

    Deployment skew protection is available to Amplify applications to eliminate version skew issues between client and servers in web applications. When you apply skew protection to a branch, you can ensure that your clients always interact with the correct version of server-side assets, regardless of when a deployment occurs. For more information about skew protection, see Skew protection for Amplify deployments in the Amplify User Guide.

  • environment_variables (Optional[EnvironmentVariables], default: None ) –

    The environment variables for the branch.

  • basic_auth_credentials (Optional[BasicAuthCredentials], default: None ) –

    The basic authorization credentials for the branch. You must base64-encode the authorization credentials and provide them in the format user:password.

  • enable_basic_auth (Optional[EnableBasicAuth], default: None ) –

    Enables basic authorization for the branch.

  • enable_performance_mode (Optional[EnablePerformanceMode], default: None ) –

    Enables performance mode for the branch.

    Performance mode optimizes for faster hosting performance by keeping content cached at the edge for a longer interval. When performance mode is enabled, hosting configuration or code changes can take up to 10 minutes to roll out.

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

    The tag for the branch.

  • build_spec (Optional[BuildSpec], default: None ) –

    The build specification (build spec) for the branch.

  • ttl (Optional[TTL], default: None ) –

    The content Time To Live (TTL) for the website in seconds.

  • display_name (Optional[DisplayName], default: None ) –

    The display name for a branch. This is used as the default domain prefix.

  • enable_pull_request_preview (Optional[EnablePullRequestPreview], default: None ) –

    Enables pull request previews for this branch.

  • pull_request_environment_name (Optional[PullRequestEnvironmentName], default: None ) –

    The Amplify environment name for the pull request.

  • backend_environment_arn (Optional[BackendEnvironmentArn], default: None ) –

    The Amazon Resource Name (ARN) for a backend environment that is part of a Gen 1 Amplify app.

    This field is available to Amplify Gen 1 apps only where the backend is created using Amplify Studio or the Amplify command line interface (CLI).

  • backend (Optional[Backend], default: None ) –

    The backend for a Branch of an Amplify app. Use for a backend created from an CloudFormation stack.

    This field is available to Amplify Gen 2 apps only. When you deploy an application with Amplify Gen 2, you provision the app's backend infrastructure using Typescript code.

  • compute_role_arn (Optional[ComputeRoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM role to assign to a branch of an SSR app. The SSR Compute role allows the Amplify Hosting compute service to securely access specific Amazon Web Services resources based on the role's permissions. For more information about the SSR Compute role, see Adding an SSR Compute role in the Amplify User Guide.

Raises:

Source code in docs_src/capo_amplify/_services/async_amplify.py
async def create_branch(
    self,
    app_id: "capo_amplify.types.app_id.AppId",
    branch_name: "capo_amplify.types.branch_name.BranchName",
    *,
    config_overrides: Optional[AsyncAmplifyClientConfig] = None,
    description: Optional["capo_amplify.types.description.Description"] = None,
    stage: Optional["capo_amplify.types.stage.Stage"] = None,
    framework: Optional["capo_amplify.types.framework.Framework"] = None,
    enable_notification: Optional[
        "capo_amplify.types.enable_notification.EnableNotification"
    ] = None,
    enable_auto_build: Optional[
        "capo_amplify.types.enable_auto_build.EnableAutoBuild"
    ] = None,
    enable_skew_protection: Optional[
        "capo_amplify.types.enable_skew_protection.EnableSkewProtection"
    ] = None,
    environment_variables: Optional[
        "capo_amplify.types.environment_variables.EnvironmentVariables"
    ] = None,
    basic_auth_credentials: Optional[
        "capo_amplify.types.basic_auth_credentials.BasicAuthCredentials"
    ] = None,
    enable_basic_auth: Optional[
        "capo_amplify.types.enable_basic_auth.EnableBasicAuth"
    ] = None,
    enable_performance_mode: Optional[
        "capo_amplify.types.enable_performance_mode.EnablePerformanceMode"
    ] = None,
    tags: Optional["capo_amplify.types.tag_map.TagMap"] = None,
    build_spec: Optional["capo_amplify.types.build_spec.BuildSpec"] = None,
    ttl: Optional["capo_amplify.types.ttl.TTL"] = None,
    display_name: Optional["capo_amplify.types.display_name.DisplayName"] = None,
    enable_pull_request_preview: Optional[
        "capo_amplify.types.enable_pull_request_preview.EnablePullRequestPreview"
    ] = None,
    pull_request_environment_name: Optional[
        "capo_amplify.types.pull_request_environment_name.PullRequestEnvironmentName"
    ] = None,
    backend_environment_arn: Optional[
        "capo_amplify.types.backend_environment_arn.BackendEnvironmentArn"
    ] = None,
    backend: Optional["capo_amplify.types.backend.Backend"] = None,
    compute_role_arn: Optional[
        "capo_amplify.types.compute_role_arn.ComputeRoleArn"
    ] = None,
) -> "capo_amplify.types.create_branch_result.CreateBranchResult":
    """<p> Creates a new branch for an Amplify app. </p>

    Args:
        app_id: <p> The unique ID for an Amplify app. </p>
        branch_name: <p>The name for the branch. </p>
        description: <p>The description for the branch. </p>
        stage: <p>Describes the current stage for the branch. </p>
        framework: <p> The framework for the branch. </p>
        enable_notification: <p> Enables notifications for the branch. </p>
        enable_auto_build: <p> Enables auto building for the branch. </p>
        enable_skew_protection: <p>Specifies whether the skew protection feature is enabled for the branch.</p> <p>Deployment skew protection is available to Amplify applications to eliminate version skew issues between client and servers in web applications. When you apply skew protection to a branch, you can ensure that your clients always interact with the correct version of server-side assets, regardless of when a deployment occurs. For more information about skew protection, see <a href="https://docs.aws.amazon.com/amplify/latest/userguide/skew-protection.html">Skew protection for Amplify deployments</a> in the <i>Amplify User Guide</i>.</p>
        environment_variables: <p> The environment variables for the branch. </p>
        basic_auth_credentials: <p> The basic authorization credentials for the branch. You must base64-encode the authorization credentials and provide them in the format <code>user:password</code>.</p>
        enable_basic_auth: <p> Enables basic authorization for the branch. </p>
        enable_performance_mode: <p>Enables performance mode for the branch.</p> <p>Performance mode optimizes for faster hosting performance by keeping content cached at the edge for a longer interval. When performance mode is enabled, hosting configuration or code changes can take up to 10 minutes to roll out. </p>
        tags: <p> The tag for the branch. </p>
        build_spec: <p> The build specification (build spec) for the branch. </p>
        ttl: <p> The content Time To Live (TTL) for the website in seconds. </p>
        display_name: <p> The display name for a branch. This is used as the default domain prefix. </p>
        enable_pull_request_preview: <p> Enables pull request previews for this branch. </p>
        pull_request_environment_name: <p> The Amplify environment name for the pull request. </p>
        backend_environment_arn: <p>The Amazon Resource Name (ARN) for a backend environment that is part of a Gen 1 Amplify app. </p> <p>This field is available to Amplify Gen 1 apps only where the backend is created using Amplify Studio or the Amplify command line interface (CLI).</p>
        backend: <p>The backend for a <code>Branch</code> of an Amplify app. Use for a backend created from an CloudFormation stack.</p> <p>This field is available to Amplify Gen 2 apps only. When you deploy an application with Amplify Gen 2, you provision the app's backend infrastructure using Typescript code.</p>
        compute_role_arn: <p>The Amazon Resource Name (ARN) of the IAM role to assign to a branch of an SSR app. The SSR Compute role allows the Amplify Hosting compute service to securely access specific Amazon Web Services resources based on the role's permissions. For more information about the SSR Compute role, see <a href="https://docs.aws.amazon.com/amplify/latest/userguide/amplify-SSR-compute-role.html">Adding an SSR Compute role</a> in the <i>Amplify User Guide</i>.</p>

    Raises:
        capo_amplify.errors.bad_request_exception.BadRequestException: <p>A request contains unexpected data. </p>
        capo_amplify.errors.dependent_service_failure_exception.DependentServiceFailureException: <p>An operation failed because a dependent service threw an exception. </p>
        capo_amplify.errors.internal_failure_exception.InternalFailureException: <p>The service failed to perform an operation due to an internal issue. </p>
        capo_amplify.errors.limit_exceeded_exception.LimitExceededException: <p>A resource could not be created because service quotas were exceeded. </p>
        capo_amplify.errors.not_found_exception.NotFoundException: <p>An entity was not found during an operation. </p>
        capo_amplify.errors.unauthorized_exception.UnauthorizedException: <p>An operation failed due to a lack of access. </p>
        capo_amplify.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_amplify.types.create_branch_request.CreateBranchRequest]",
    ) -> AsyncOperationResponse[
        "capo_amplify.types.create_branch_result.CreateBranchResult"
    ]:
        import capo_amplify._operations.amplify.create_branch

        (
            output,
            http_response,
        ) = await capo_amplify._operations.amplify.create_branch.async_create_branch(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_amplify.types.create_branch_request.CreateBranchRequest",
    ) -> dict[str, Any]:
        import capo_amplify.types.create_branch_request

        return capo_amplify.types.create_branch_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_amplify.types.create_branch_result.CreateBranchResult",
    ) -> dict[str, Any]:
        import capo_amplify.types.create_branch_result

        return capo_amplify.types.create_branch_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateBranch", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_amplify.types.create_branch_request.CreateBranchRequest = {
        "app_id": app_id,
        "branch_name": branch_name,
    }
    if description is not None:
        input_["description"] = description
    if stage is not None:
        input_["stage"] = stage
    if framework is not None:
        input_["framework"] = framework
    if enable_notification is not None:
        input_["enable_notification"] = enable_notification
    if enable_auto_build is not None:
        input_["enable_auto_build"] = enable_auto_build
    if enable_skew_protection is not None:
        input_["enable_skew_protection"] = enable_skew_protection
    if environment_variables is not None:
        input_["environment_variables"] = environment_variables
    if basic_auth_credentials is not None:
        input_["basic_auth_credentials"] = basic_auth_credentials
    if enable_basic_auth is not None:
        input_["enable_basic_auth"] = enable_basic_auth
    if enable_performance_mode is not None:
        input_["enable_performance_mode"] = enable_performance_mode
    if tags is not None:
        input_["tags"] = tags
    if build_spec is not None:
        input_["build_spec"] = build_spec
    if ttl is not None:
        input_["ttl"] = ttl
    if display_name is not None:
        input_["display_name"] = display_name
    if enable_pull_request_preview is not None:
        input_["enable_pull_request_preview"] = enable_pull_request_preview
    if pull_request_environment_name is not None:
        input_["pull_request_environment_name"] = pull_request_environment_name
    if backend_environment_arn is not None:
        input_["backend_environment_arn"] = backend_environment_arn
    if backend is not None:
        input_["backend"] = backend
    if compute_role_arn is not None:
        input_["compute_role_arn"] = compute_role_arn

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