Skip to content
GitHubXDiscord

Container

The Container resource lets you manage AWS Lightsail Containers for deploying and scaling containerized applications easily.

Create a basic Lightsail Container with required properties and a common optional property.

import AWS from "alchemy/aws/control";
const basicContainer = await AWS.Lightsail.Container("myBasicContainer", {
ServiceName: "myService",
Scale: 2,
Power: "nano",
PublicDomainNames: [{
name: "myapp.example.com"
}]
});

Configure a container with private registry access and deployment specifications.

const advancedContainer = await AWS.Lightsail.Container("myAdvancedContainer", {
ServiceName: "myAdvancedService",
Scale: 3,
Power: "micro",
PrivateRegistryAccess: {
Credentials: {
Username: alchemy.secret(process.env.REGISTRY_USERNAME!),
Password: alchemy.secret(process.env.REGISTRY_PASSWORD!)
},
RegistryUrl: "https://my-private-registry.com"
},
ContainerServiceDeployment: {
Containers: [{
Image: "myapp/image:latest",
Command: ["npm", "start"],
Environment: {
NODE_ENV: "production"
}
}]
}
});

Create a container with tags for better resource management and identification.

const taggedContainer = await AWS.Lightsail.Container("myTaggedContainer", {
ServiceName: "myTaggedService",
Scale: 1,
Power: "small",
Tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Project", Value: "WebApp" }
]
});

Demonstrate how to create a disabled container that can be enabled later.

const disabledContainer = await AWS.Lightsail.Container("myDisabledContainer", {
ServiceName: "myDisabledService",
Scale: 1,
Power: "small",
IsDisabled: true
});