Skip to content

create_container_service

create_container_service(
    service_name: ContainerServiceName,
    power: ContainerServicePowerName,
    scale: ContainerServiceScale,
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    tags: Optional[TagList] = None,
    public_domain_names: Optional[ContainerServicePublicDomains] = None,
    deployment: Optional[ContainerServiceDeploymentRequest] = None,
    private_registry_access: Optional[PrivateRegistryAccessRequest] = None,
) -> CreateContainerServiceResult

Creates an Amazon Lightsail container service.

A Lightsail container service is a compute resource to which you can deploy containers. For more information, see Container services in Amazon Lightsail in the Lightsail Dev Guide.

Parameters:

  • service_name (ContainerServiceName) –

    The name for the container service.

    The name that you specify for your container service will make up part of its default domain. The default domain of a container service is typically https://...cs.amazonlightsail.com. If the name of your container service is container-service-1, and it's located in the US East (Ohio) Amazon Web Services Region (us-east-2), then the domain for your container service will be like the following example: https://container-service-1.ur4EXAMPLE2uq.us-east-2.cs.amazonlightsail.com

    The following are the requirements for container service names:

    • Must be unique within each Amazon Web Services Region in your Lightsail account.

    • Must contain 1 to 63 characters.

    • Must contain only alphanumeric characters and hyphens.

    • A hyphen (-) can separate words but cannot be at the start or end of the name.

  • power (ContainerServicePowerName) –

    The power specification for the container service.

    The power specifies the amount of memory, vCPUs, and base monthly cost of each node of the container service. The power and scale of a container service makes up its configured capacity. To determine the monthly price of your container service, multiply the base price of the power with the scale (the number of nodes) of the service.

    Use the GetContainerServicePowers action to get a list of power options that you can specify using this parameter, and their base monthly cost.

  • scale (ContainerServiceScale) –

    The scale specification for the container service.

    The scale specifies the allocated compute nodes of the container service. The power and scale of a container service makes up its configured capacity. To determine the monthly price of your container service, multiply the base price of the power with the scale (the number of nodes) of the service.

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

    The tag keys and optional values to add to the container service during create.

    Use the TagResource action to tag a resource after it's created.

    For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide.

  • public_domain_names (Optional[ContainerServicePublicDomains], default: None ) –

    The public domain names to use with the container service, such as example.com and www.example.com.

    You can specify up to four public domain names for a container service. The domain names that you specify are used when you create a deployment with a container configured as the public endpoint of your container service.

    If you don't specify public domain names, then you can use the default domain of the container service.

    You must create and validate an SSL/TLS certificate before you can use public domain names with your container service. Use the CreateCertificate action to create a certificate for the public domain names you want to use with your container service.

    You can specify public domain names using a string to array map as shown in the example later on this page.

  • deployment (Optional[ContainerServiceDeploymentRequest], default: None ) –

    An object that describes a deployment for the container service.

    A deployment specifies the containers that will be launched on the container service and their settings, such as the ports to open, the environment variables to apply, and the launch command to run. It also specifies the container that will serve as the public endpoint of the deployment and its settings, such as the HTTP or HTTPS port to use, and the health check configuration.

  • private_registry_access (Optional[PrivateRegistryAccessRequest], default: None ) –

    An object to describe the configuration for the container service to access private container image repositories, such as Amazon Elastic Container Registry (Amazon ECR) private repositories.

    For more information, see Configuring access to an Amazon ECR private repository for an Amazon Lightsail container service in the Amazon Lightsail Developer Guide.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

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

Source code in docs_src/capo_lightsail/_services/lightsail.py
def create_container_service(
    self,
    service_name: "capo_lightsail.types.container_service_name.ContainerServiceName",
    power: "capo_lightsail.types.container_service_power_name.ContainerServicePowerName",
    scale: "capo_lightsail.types.container_service_scale.ContainerServiceScale",
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    tags: Optional["capo_lightsail.types.tag_list.TagList"] = None,
    public_domain_names: Optional[
        "capo_lightsail.types.container_service_public_domains.ContainerServicePublicDomains"
    ] = None,
    deployment: Optional[
        "capo_lightsail.types.container_service_deployment_request.ContainerServiceDeploymentRequest"
    ] = None,
    private_registry_access: Optional[
        "capo_lightsail.types.private_registry_access_request.PrivateRegistryAccessRequest"
    ] = None,
) -> "capo_lightsail.types.create_container_service_result.CreateContainerServiceResult":
    """<p>Creates an Amazon Lightsail container service.</p> <p>A Lightsail container service is a compute resource to which you can deploy containers. For more information, see <a href="https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-container-services">Container services in Amazon Lightsail</a> in the <i>Lightsail Dev Guide</i>.</p>

    Args:
        service_name: <p>The name for the container service.</p> <p>The name that you specify for your container service will make up part of its default domain. The default domain of a container service is typically <code>https://<ServiceName>.<RandomGUID>.<AWSRegion>.cs.amazonlightsail.com</code>. If the name of your container service is <code>container-service-1</code>, and it's located in the US East (Ohio) Amazon Web Services Region (<code>us-east-2</code>), then the domain for your container service will be like the following example: <code>https://container-service-1.ur4EXAMPLE2uq.us-east-2.cs.amazonlightsail.com</code> </p> <p>The following are the requirements for container service names:</p> <ul> <li> <p>Must be unique within each Amazon Web Services Region in your Lightsail account.</p> </li> <li> <p>Must contain 1 to 63 characters.</p> </li> <li> <p>Must contain only alphanumeric characters and hyphens.</p> </li> <li> <p>A hyphen (-) can separate words but cannot be at the start or end of the name.</p> </li> </ul>
        power: <p>The power specification for the container service.</p> <p>The power specifies the amount of memory, vCPUs, and base monthly cost of each node of the container service. The <code>power</code> and <code>scale</code> of a container service makes up its configured capacity. To determine the monthly price of your container service, multiply the base price of the <code>power</code> with the <code>scale</code> (the number of nodes) of the service.</p> <p>Use the <code>GetContainerServicePowers</code> action to get a list of power options that you can specify using this parameter, and their base monthly cost.</p>
        scale: <p>The scale specification for the container service.</p> <p>The scale specifies the allocated compute nodes of the container service. The <code>power</code> and <code>scale</code> of a container service makes up its configured capacity. To determine the monthly price of your container service, multiply the base price of the <code>power</code> with the <code>scale</code> (the number of nodes) of the service.</p>
        tags: <p>The tag keys and optional values to add to the container service during create.</p> <p>Use the <code>TagResource</code> action to tag a resource after it's created.</p> <p>For more information about tags in Lightsail, see the <a href="https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-tags">Amazon Lightsail Developer Guide</a>.</p>
        public_domain_names: <p>The public domain names to use with the container service, such as <code>example.com</code> and <code>www.example.com</code>.</p> <p>You can specify up to four public domain names for a container service. The domain names that you specify are used when you create a deployment with a container configured as the public endpoint of your container service.</p> <p>If you don't specify public domain names, then you can use the default domain of the container service.</p> <important> <p>You must create and validate an SSL/TLS certificate before you can use public domain names with your container service. Use the <code>CreateCertificate</code> action to create a certificate for the public domain names you want to use with your container service.</p> </important> <p>You can specify public domain names using a string to array map as shown in the example later on this page.</p>
        deployment: <p>An object that describes a deployment for the container service.</p> <p>A deployment specifies the containers that will be launched on the container service and their settings, such as the ports to open, the environment variables to apply, and the launch command to run. It also specifies the container that will serve as the public endpoint of the deployment and its settings, such as the HTTP or HTTPS port to use, and the health check configuration.</p>
        private_registry_access: <p>An object to describe the configuration for the container service to access private container image repositories, such as Amazon Elastic Container Registry (Amazon ECR) private repositories.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-container-service-ecr-private-repo-access">Configuring access to an Amazon ECR private repository for an Amazon Lightsail container service</a> in the <i>Amazon Lightsail Developer Guide</i>.</p>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lightsail.types.create_container_service_request.CreateContainerServiceRequest]",
    ) -> OperationResponse[
        "capo_lightsail.types.create_container_service_result.CreateContainerServiceResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.create_container_service

        output, http_response = (
            capo_lightsail._operations.lightsail_20161128.create_container_service.create_container_service(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateContainerService")
    )
    input_: capo_lightsail.types.create_container_service_request.CreateContainerServiceRequest = {
        "service_name": service_name,
        "power": power,
        "scale": scale,
    }
    if tags is not None:
        input_["tags"] = tags
    if public_domain_names is not None:
        input_["public_domain_names"] = public_domain_names
    if deployment is not None:
        input_["deployment"] = deployment
    if private_registry_access is not None:
        input_["private_registry_access"] = private_registry_access

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