Skip to content

create_service

create_service(
    service_name: ServiceName,
    source_configuration: SourceConfiguration,
    *,
    config_overrides: Optional[AppRunnerClientConfig] = None,
    instance_configuration: Optional[InstanceConfiguration] = None,
    tags: Optional[TagList] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
    health_check_configuration: Optional[HealthCheckConfiguration] = None,
    auto_scaling_configuration_arn: Optional[AppRunnerResourceArn] = None,
    network_configuration: Optional[NetworkConfiguration] = None,
    observability_configuration: Optional[ServiceObservabilityConfiguration] = None,
) -> CreateServiceResponse

Create an App Runner service. After the service is created, the action also automatically starts a deployment.

This is an asynchronous operation. On a successful call, you can use the returned OperationId and the ListOperations call to track the operation's progress.

Parameters:

  • service_name (ServiceName) –

    A name for the App Runner service. It must be unique across all the running App Runner services in your Amazon Web Services account in the Amazon Web Services Region.

  • source_configuration (SourceConfiguration) –

    The source to deploy to the App Runner service. It can be a code or an image repository.

  • instance_configuration (Optional[InstanceConfiguration], default: None ) –

    The runtime configuration of instances (scaling units) of your service.

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

    An optional list of metadata items that you can associate with the App Runner service resource. A tag is a key-value pair.

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

    An optional custom encryption key that App Runner uses to encrypt the copy of your source repository that it maintains and your service logs. By default, App Runner uses an Amazon Web Services managed key.

  • health_check_configuration (Optional[HealthCheckConfiguration], default: None ) –

    The settings for the health check that App Runner performs to monitor the health of the App Runner service.

  • auto_scaling_configuration_arn (Optional[AppRunnerResourceArn], default: None ) –

    The Amazon Resource Name (ARN) of an App Runner automatic scaling configuration resource that you want to associate with your service. If not provided, App Runner associates the latest revision of a default auto scaling configuration.

    Specify an ARN with a name and a revision number to associate that revision. For example: arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/3

    Specify just the name to associate the latest revision. For example: arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability

  • network_configuration (Optional[NetworkConfiguration], default: None ) –

    Configuration settings related to network traffic of the web application that the App Runner service runs.

  • observability_configuration (Optional[ServiceObservabilityConfiguration], default: None ) –

    The observability configuration of your service.

Raises:

Source code in docs_src/capo_apprunner/_services/app_runner.py
def create_service(
    self,
    service_name: "capo_apprunner.types.service_name.ServiceName",
    source_configuration: "capo_apprunner.types.source_configuration.SourceConfiguration",
    *,
    config_overrides: Optional[AppRunnerClientConfig] = None,
    instance_configuration: Optional[
        "capo_apprunner.types.instance_configuration.InstanceConfiguration"
    ] = None,
    tags: Optional["capo_apprunner.types.tag_list.TagList"] = None,
    encryption_configuration: Optional[
        "capo_apprunner.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
    health_check_configuration: Optional[
        "capo_apprunner.types.health_check_configuration.HealthCheckConfiguration"
    ] = None,
    auto_scaling_configuration_arn: Optional[
        "capo_apprunner.types.app_runner_resource_arn.AppRunnerResourceArn"
    ] = None,
    network_configuration: Optional[
        "capo_apprunner.types.network_configuration.NetworkConfiguration"
    ] = None,
    observability_configuration: Optional[
        "capo_apprunner.types.service_observability_configuration.ServiceObservabilityConfiguration"
    ] = None,
) -> "capo_apprunner.types.create_service_response.CreateServiceResponse":
    """<p>Create an App Runner service. After the service is created, the action also automatically starts a deployment.</p> <p>This is an asynchronous operation. On a successful call, you can use the returned <code>OperationId</code> and the <a href="https://docs.aws.amazon.com/apprunner/latest/api/API_ListOperations.html">ListOperations</a> call to track the operation's progress.</p>

    Args:
        service_name: <p>A name for the App Runner service. It must be unique across all the running App Runner services in your Amazon Web Services account in the Amazon Web Services Region.</p>
        source_configuration: <p>The source to deploy to the App Runner service. It can be a code or an image repository.</p>
        instance_configuration: <p>The runtime configuration of instances (scaling units) of your service.</p>
        tags: <p>An optional list of metadata items that you can associate with the App Runner service resource. A tag is a key-value pair.</p>
        encryption_configuration: <p>An optional custom encryption key that App Runner uses to encrypt the copy of your source repository that it maintains and your service logs. By default, App Runner uses an Amazon Web Services managed key.</p>
        health_check_configuration: <p>The settings for the health check that App Runner performs to monitor the health of the App Runner service.</p>
        auto_scaling_configuration_arn: <p>The Amazon Resource Name (ARN) of an App Runner automatic scaling configuration resource that you want to associate with your service. If not provided, App Runner associates the latest revision of a default auto scaling configuration.</p> <p>Specify an ARN with a name and a revision number to associate that revision. For example: <code>arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/3</code> </p> <p>Specify just the name to associate the latest revision. For example: <code>arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability</code> </p>
        network_configuration: <p>Configuration settings related to network traffic of the web application that the App Runner service runs.</p>
        observability_configuration: <p>The observability configuration of your service.</p>

    Raises:
        capo_apprunner.errors.internal_service_error_exception.InternalServiceErrorException: <p>An unexpected service exception occurred.</p>
        capo_apprunner.errors.invalid_request_exception.InvalidRequestException: <p>One or more input parameters aren't valid. Refer to the API action's document page, correct the input parameters, and try the action again.</p>
        capo_apprunner.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>App Runner can't create this resource. You've reached your account quota for this resource type.</p> <p>For App Runner per-resource quotas, see <a href="https://docs.aws.amazon.com/general/latest/gr/apprunner.html">App Runner endpoints and quotas</a> in the <i>Amazon Web Services General Reference</i>.</p>
        capo_apprunner.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_apprunner.types.create_service_request.CreateServiceRequest]",
    ) -> OperationResponse[
        "capo_apprunner.types.create_service_response.CreateServiceResponse"
    ]:
        import capo_apprunner._operations.app_runner.create_service

        output, http_response = (
            capo_apprunner._operations.app_runner.create_service.create_service(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_apprunner.types.create_service_request.CreateServiceRequest",
    ) -> dict[str, Any]:
        import capo_apprunner.types.create_service_request

        return capo_apprunner.types.create_service_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_apprunner.types.create_service_response.CreateServiceResponse",
    ) -> dict[str, Any]:
        import capo_apprunner.types.create_service_response

        return capo_apprunner.types.create_service_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateService",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_apprunner.types.create_service_request.CreateServiceRequest = {
        "service_name": service_name,
        "source_configuration": source_configuration,
    }
    if instance_configuration is not None:
        input_["instance_configuration"] = instance_configuration
    if tags is not None:
        input_["tags"] = tags
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration
    if health_check_configuration is not None:
        input_["health_check_configuration"] = health_check_configuration
    if auto_scaling_configuration_arn is not None:
        input_["auto_scaling_configuration_arn"] = auto_scaling_configuration_arn
    if network_configuration is not None:
        input_["network_configuration"] = network_configuration
    if observability_configuration is not None:
        input_["observability_configuration"] = observability_configuration

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