Resource: aws_lightsail_container_service

An Amazon Lightsail container service is a highly scalable compute and networking resource on which you can deploy, run, and manage containers. For more information, see Container services in Amazon Lightsail.

Example Usage

Basic Usage

resource "aws_lightsail_container_service" "my_container_service" {
  name        = "container-service-1"
  power       = "nano"
  scale       = 1
  is_disabled = false

  tags = {
    foo1 = "bar1"
    foo2 = ""
  }
}

Public Domain Names

resource "aws_lightsail_container_service" "my_container_service" {
  # ... other configuration ...

  public_domain_names {
    certificate {
      certificate_name = "example-certificate"
      domain_names = [
        "www.example.com",
        # maybe another domain name
      ]
    }

    # certificate {
    # maybe another certificate
    # }
  }
}

Private Registry Access

resource "aws_lightsail_container_service" "default" {
  # ... other configuration ...

  private_registry_access {
    ecr_image_puller_role {
      is_active = true
    }
  }
}

data "aws_iam_policy_document" "default" {
  statement {
    effect = "Allow"

    principals {
      type        = "AWS"
      identifiers = [aws_lightsail_container_service.default.private_registry_access[0].ecr_image_puller_role[0].principal_arn]
    }

    actions = [
      "ecr:BatchGetImage",
      "ecr:GetDownloadUrlForLayer",
    ]
  }
}

resource "aws_ecr_repository_policy" "default" {
  repository = aws_ecr_repository.default.name
  policy     = data.aws_iam_policy_document.default.json
}

Argument Reference

This argument supports the following arguments:

Private Registry Access

The private_registry_access block supports the following arguments:

ECR Image Puller Role

The ecr_image_puller_role blocks supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import Lightsail Container Service using the name. For example:

import {
  to = aws_lightsail_container_service.my_container_service
  id = "container-service-1"
}

Using terraform import, import Lightsail Container Service using the name. For example:

% terraform import aws_lightsail_container_service.my_container_service container-service-1