ContainerService class
Manages a Lightsail container service. Use this resource to create and manage a scalable compute and networking platform for deploying, running, and managing containerized applications in Lightsail.
> Note: For more information about the AWS Regions in which you can create Amazon Lightsail container services, see "Regions and Availability Zones in Amazon Lightsail".
> NOTE: You must create and validate an SSL/TLS certificate before you can use publicDomainNames with your container service. For more information, see Enabling and managing custom domains for your Amazon Lightsail container services.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.lightsail.ContainerService("example", {
name: "container-service-1",
power: "nano",
scale: 1,
isDisabled: false,
tags: {
foo1: "bar1",
foo2: "",
},
});
import pulumi
import pulumi_aws as aws
example = aws.lightsail.ContainerService("example",
name="container-service-1",
power="nano",
scale=1,
is_disabled=False,
tags={
"foo1": "bar1",
"foo2": "",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.LightSail.ContainerService("example", new()
{
Name = "container-service-1",
Power = "nano",
Scale = 1,
IsDisabled = false,
Tags =
{
{ "foo1", "bar1" },
{ "foo2", "" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lightsail"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := lightsail.NewContainerService(ctx, "example", &lightsail.ContainerServiceArgs{
Name: pulumi.String("container-service-1"),
Power: pulumi.String("nano"),
Scale: pulumi.Int(1),
IsDisabled: pulumi.Bool(false),
Tags: pulumi.StringMap{
"foo1": pulumi.String("bar1"),
"foo2": pulumi.String(""),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_lightsail_containerservice" "example" {
name = "container-service-1"
power = "nano"
scale = 1
is_disabled = false
tags = {
"foo1" = "bar1"
"foo2" = ""
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.ContainerService;
import com.pulumi.aws.lightsail.ContainerServiceArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ContainerService("example", ContainerServiceArgs.builder()
.name("container-service-1")
.power("nano")
.scale(1)
.isDisabled(false)
.tags(Map.ofEntries(
Map.entry("foo1", "bar1"),
Map.entry("foo2", "")
))
.build());
}
}
resources:
example:
type: aws:lightsail:ContainerService
properties:
name: container-service-1
power: nano
scale: 1
isDisabled: false
tags:
foo1: bar1
foo2: ""
Public Domain Names
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.lightsail.ContainerService("example", {publicDomainNames: {
certificates: [{
certificateName: "example-certificate",
domainNames: ["www.example.com"],
}],
}});
import pulumi
import pulumi_aws as aws
example = aws.lightsail.ContainerService("example", public_domain_names={
"certificates": [{
"certificate_name": "example-certificate",
"domain_names": ["www.example.com"],
}],
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.LightSail.ContainerService("example", new()
{
PublicDomainNames = new Aws.LightSail.Inputs.ContainerServicePublicDomainNamesArgs
{
Certificates = new[]
{
new Aws.LightSail.Inputs.ContainerServicePublicDomainNamesCertificateArgs
{
CertificateName = "example-certificate",
DomainNames = new[]
{
"www.example.com",
},
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lightsail"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := lightsail.NewContainerService(ctx, "example", &lightsail.ContainerServiceArgs{
PublicDomainNames: &lightsail.ContainerServicePublicDomainNamesArgs{
Certificates: lightsail.ContainerServicePublicDomainNamesCertificateArray{
&lightsail.ContainerServicePublicDomainNamesCertificateArgs{
CertificateName: pulumi.String("example-certificate"),
DomainNames: pulumi.StringArray{
pulumi.String("www.example.com"),
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_lightsail_containerservice" "example" {
public_domain_names = {
certificates = [{
"certificateName" = "example-certificate"
"domainNames" = ["www.example.com"]
}]
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.ContainerService;
import com.pulumi.aws.lightsail.ContainerServiceArgs;
import com.pulumi.aws.lightsail.inputs.ContainerServicePublicDomainNamesArgs;
import com.pulumi.aws.lightsail.inputs.ContainerServicePublicDomainNamesCertificateArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ContainerService("example", ContainerServiceArgs.builder()
.publicDomainNames(ContainerServicePublicDomainNamesArgs.builder()
.certificates(ContainerServicePublicDomainNamesCertificateArgs.builder()
.certificateName("example-certificate")
.domainNames("www.example.com")
.build())
.build())
.build());
}
}
resources:
example:
type: aws:lightsail:ContainerService
properties:
publicDomainNames:
certificates:
- certificateName: example-certificate
domainNames:
- www.example.com
Private Registry Access
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const exampleContainerService = new aws.lightsail.ContainerService("example", {privateRegistryAccess: {
ecrImagePullerRole: {
isActive: true,
},
}});
const example = aws.iam.getPolicyDocumentOutput({
statements: [{
principals: [{
type: "AWS",
identifiers: [exampleContainerService.privateRegistryAccess.apply(privateRegistryAccess => privateRegistryAccess.ecrImagePullerRole?.principalArn)],
}],
effect: "Allow",
actions: [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
],
}],
});
const exampleRepositoryPolicy = new aws.ecr.RepositoryPolicy("example", {
repository: exampleAwsEcrRepository.name,
policy: example.json,
});
import pulumi
import pulumi_aws as aws
example_container_service = aws.lightsail.ContainerService("example", private_registry_access={
"ecr_image_puller_role": {
"is_active": True,
},
})
example = aws.iam.get_policy_document_output(statements=[{
"principals": [{
"type": "AWS",
"identifiers": [example_container_service.private_registry_access.ecr_image_puller_role.principal_arn],
}],
"effect": "Allow",
"actions": [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
],
}])
example_repository_policy = aws.ecr.RepositoryPolicy("example",
repository=example_aws_ecr_repository["name"],
policy=example.json)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var exampleContainerService = new Aws.LightSail.ContainerService("example", new()
{
PrivateRegistryAccess = new Aws.LightSail.Inputs.ContainerServicePrivateRegistryAccessArgs
{
EcrImagePullerRole = new Aws.LightSail.Inputs.ContainerServicePrivateRegistryAccessEcrImagePullerRoleArgs
{
IsActive = true,
},
},
});
var example = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "AWS",
Identifiers = new[]
{
exampleContainerService.PrivateRegistryAccess.EcrImagePullerRole?.PrincipalArn,
},
},
},
Effect = "Allow",
Actions = new[]
{
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
},
},
},
});
var exampleRepositoryPolicy = new Aws.Ecr.RepositoryPolicy("example", new()
{
Repository = exampleAwsEcrRepository.Name,
Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ecr"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lightsail"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleContainerService, err := lightsail.NewContainerService(ctx, "example", &lightsail.ContainerServiceArgs{
PrivateRegistryAccess: &lightsail.ContainerServicePrivateRegistryAccessArgs{
EcrImagePullerRole: &lightsail.ContainerServicePrivateRegistryAccessEcrImagePullerRoleArgs{
IsActive: pulumi.Bool(true),
},
},
})
if err != nil {
return err
}
example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("AWS"),
Identifiers: pulumi.StringArray{
exampleContainerService.PrivateRegistryAccess.ApplyT(func(privateRegistryAccess lightsail.ContainerServicePrivateRegistryAccess) (*string, error) {
return privateRegistryAccess.EcrImagePullerRole.PrincipalArn, nil
}).(pulumi.StringPtrOutput),
},
},
},
Effect: pulumi.String("Allow"),
Actions: pulumi.StringArray{
pulumi.String("ecr:BatchGetImage"),
pulumi.String("ecr:GetDownloadUrlForLayer"),
},
},
},
}, nil)
_, err = ecr.NewRepositoryPolicy(ctx, "example", &ecr.RepositoryPolicyArgs{
Repository: pulumi.Any(exampleAwsEcrRepository.Name),
Policy: example.Json(),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_iam_getpolicydocument" "example" {
statements {
principals {
type = "AWS"
identifiers = [aws_lightsail_containerservice.example.private_registry_access.ecr_image_puller_role.principal_arn]
}
effect = "Allow"
actions = ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"]
}
}
resource "aws_lightsail_containerservice" "example" {
private_registry_access = {
ecr_image_puller_role = {
is_active = true
}
}
}
resource "aws_ecr_repositorypolicy" "example" {
repository = exampleAwsEcrRepository.name
policy = data.aws_iam_getpolicydocument.example.json
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.ContainerService;
import com.pulumi.aws.lightsail.ContainerServiceArgs;
import com.pulumi.aws.lightsail.inputs.ContainerServicePrivateRegistryAccessArgs;
import com.pulumi.aws.lightsail.inputs.ContainerServicePrivateRegistryAccessEcrImagePullerRoleArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.ecr.RepositoryPolicy;
import com.pulumi.aws.ecr.RepositoryPolicyArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleContainerService = new ContainerService("exampleContainerService", ContainerServiceArgs.builder()
.privateRegistryAccess(ContainerServicePrivateRegistryAccessArgs.builder()
.ecrImagePullerRole(ContainerServicePrivateRegistryAccessEcrImagePullerRoleArgs.builder()
.isActive(true)
.build())
.build())
.build());
final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("AWS")
.identifiers(exampleContainerService.privateRegistryAccess().applyValue(_privateRegistryAccess -> _privateRegistryAccess.ecrImagePullerRole().principalArn()))
.build())
.effect("Allow")
.actions(
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer")
.build())
.build());
var exampleRepositoryPolicy = new RepositoryPolicy("exampleRepositoryPolicy", RepositoryPolicyArgs.builder()
.repository(exampleAwsEcrRepository.name())
.policy(example.applyValue(_example -> _example.json()))
.build());
}
}
resources:
exampleContainerService:
type: aws:lightsail:ContainerService
name: example
properties:
privateRegistryAccess:
ecrImagePullerRole:
isActive: true
exampleRepositoryPolicy:
type: aws:ecr:RepositoryPolicy
name: example
properties:
repository: ${exampleAwsEcrRepository.name}
policy: ${example.json}
variables:
example:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- type: AWS
identifiers:
- ${exampleContainerService.privateRegistryAccess.ecrImagePullerRole.principalArn}
effect: Allow
actions:
- ecr:BatchGetImage
- ecr:GetDownloadUrlForLayer
Import
Using pulumi import, import Lightsail Container Service using the name. For example:
$ pulumi import aws:lightsail/containerService:ContainerService example container-service-1
Constructors
- ContainerService(String name, {ContainerServiceArgs? args, CustomResourceOptions? options})
-
Creates a new ContainerService.
nameThe Pulumi resource name.argsArguments used to configure this ContainerService. The set of arguments for ContainerService.optionsResource options controlling this resource's behavior. - ContainerService.reference(String urn)
- Creates a typed reference to an existing ContainerService resource.
Properties
-
arn
↔ Output<
String> -
ARN of the container service.
latefinal
-
availabilityZone
↔ Output<
String> -
Availability Zone. Follows the format us-east-2a (case-sensitive).
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
createdAt
↔ Output<
String> -
Date and time when the container service was created.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
-
isDisabled
↔ Output<
bool?> -
Whether to disable the container service. Defaults to
false.latefinal - isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
Name of the container service. Names must be of length 1 to 63, and be unique within each AWS Region in your Lightsail account.
latefinal
-
power
↔ Output<
String> -
Power specification for the container service. The power specifies the amount of memory, the number of vCPUs, and the monthly price of each node of the container service. Possible values:
nano,micro,small,medium,large,xlarge.latefinal -
powerId
↔ Output<
String> -
Power ID of the container service.
latefinal
-
principalArn
↔ Output<
String> -
Principal ARN of the container service. The principal ARN can be used to create a trust relationship between your standard AWS account and your Lightsail container service.
latefinal
-
privateDomainName
↔ Output<
String> -
Private domain name of the container service. The private domain name is accessible only by other resources within the default VPC of your Lightsail account.
latefinal
-
privateRegistryAccess
↔ Output<
ContainerServicePrivateRegistryAccess> -
Configuration for the container service to access private container image repositories, such as Amazon Elastic Container Registry (Amazon ECR) private repositories. See below.
latefinal
-
publicDomainNames
↔ Output<
ContainerServicePublicDomainNames?> -
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. See below.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
resourceType
↔ Output<
String> -
Lightsail resource type of the container service (i.e., ContainerService).
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scale
↔ Output<
int> -
Scale specification for the container service. The scale specifies the allocated compute nodes of the container service.
latefinal
-
state
↔ Output<
String> -
Current state of the container service.
latefinal
-
Map of tags to assign to the resource. To create a key-only tag, use an empty string as the value. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
Map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
url
↔ Output<
String> -
Publicly accessible URL of the container service. If no public endpoint is specified in the currentDeployment, this URL returns a 404 response.
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {ContainerServiceState? state, CustomResourceOptions? options}) → ContainerService -
Gets an existing ContainerService resource's state with the given
nameandid.