Skip to content

Resource: awsLightsailContainerServiceDeploymentVersion

Provides a resource to manage a deployment version for your Amazon Lightsail container service.

\~> NOTE: The Amazon Lightsail container service must be enabled to create a deployment.

\~> NOTE: This resource allows you to manage an Amazon Lightsail container service deployment version but Terraform cannot destroy it. Removing this resource from your configuration will remove it from your statefile and Terraform management.

Example Usage

Basic Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lightsailContainerServiceDeploymentVersion.LightsailContainerServiceDeploymentVersion(
  this,
  "example",
  {
    container: [
      {
        command: [],
        containerName: "hello-world",
        environment: [
          {
            myEnvironmentVariable: "my_value",
          },
        ],
        image: "amazon/amazon-lightsail:hello-world",
        ports: [
          {
            80: "HTTP",
          },
        ],
      },
    ],
    publicEndpoint: {
      containerName: "hello-world",
      containerPort: 80,
      healthCheck: {
        healthyThreshold: 2,
        intervalSeconds: 5,
        path: "/",
        successCodes: "200-499",
        timeoutSeconds: 2,
        unhealthyThreshold: 2,
      },
    },
    serviceName: "${aws_lightsail_container_service.example.name}",
  }
);

Argument Reference

The following arguments are supported:

  • serviceName - (Required) The name for the container service.
  • container - (Required) A set of configuration blocks that describe the settings of the containers that will be launched on the container service. Maximum of 53. Detailed below.
  • publicEndpoint - (Optional) A configuration block that describes the settings of the public endpoint for the container service. Detailed below.

container

The container configuration block supports the following arguments:

  • containerName - (Required) The name for the container.
  • image - (Required) The name of the image used for the container. Container images sourced from your Lightsail container service, that are registered and stored on your service, start with a colon (:). For example, :containerService1Mystaticwebsite1. Container images sourced from a public registry like Docker Hub don't start with a colon. For example, nginx:latest or nginx.
  • command - (Optional) The launch command for the container. A list of string.
  • environment - (Optional) A key-value map of the environment variables of the container.
  • ports - (Optional) A key-value map of the open firewall ports of the container. Valid values: http, https, tcp, udp.

publicEndpoint

The publicEndpoint configuration block supports the following arguments:

  • containerName - (Required) The name of the container for the endpoint.
  • containerPort - (Required) The port of the container to which traffic is forwarded to.
  • healthCheck - (Required) A configuration block that describes the health check configuration of the container. Detailed below.

healthCheck

The healthCheck configuration block supports the following arguments:

  • healthyThreshold - (Optional) The number of consecutive health checks successes required before moving the container to the Healthy state. Defaults to 2.
  • unhealthyThreshold - (Optional) The number of consecutive health checks failures required before moving the container to the Unhealthy state. Defaults to 2.
  • timeoutSeconds - (Optional) The amount of time, in seconds, during which no response means a failed health check. You can specify between 2 and 60 seconds. Defaults to 2.
  • intervalSeconds - (Optional) The approximate interval, in seconds, between health checks of an individual container. You can specify between 5 and 300 seconds. Defaults to 5.
  • path - (Optional) The path on the container on which to perform the health check. Defaults to "/".
  • successCodes - (Optional) The HTTP codes to use when checking for a successful response from a container. You can specify values between 200 and 499. Defaults to "200-499".

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The serviceName and version separation by a slash (/).
  • createdAt - The timestamp when the deployment was created.
  • state - The current state of the container service.
  • version - The version number of the deployment.

Timeouts

Configuration options:

  • create - (Default 30M)

Import

Lightsail Container Service Deployment Version can be imported using the serviceName and version separated by a slash (/), e.g.,

$ terraform import aws_lightsail_container_service_deployment_version.example container-service-1/1