Instance

class Instance : KotlinCustomResource

Provides a Lightsail Instance. Amazon Lightsail is a service to provide easy virtual private servers with custom software already setup. See What is Amazon Lightsail? for more information.

Note: Lightsail is currently only supported in a limited number of AWS Regions, please see "Regions and Availability Zones in Amazon Lightsail" for more details

Example Usage

Basic Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import java.util.List;
import java.util.ArrayList;
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 gitlabTest = new Instance("gitlabTest", InstanceArgs.builder()
.availabilityZone("us-east-1b")
.blueprintId("amazon_linux_2")
.bundleId("nano_1_0")
.keyPairName("some_key_name")
.tags(Map.of("foo", "bar"))
.build());
}
}

Example With User Data

Lightsail user data is handled differently than ec2 user data. Lightsail user data only accepts a single lined string. The below example shows installing apache and creating the index page.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import java.util.List;
import java.util.ArrayList;
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 custom = new Instance("custom", InstanceArgs.builder()
.availabilityZone("us-east-1b")
.blueprintId("amazon_linux_2")
.bundleId("nano_1_0")
.userData("sudo yum install -y httpd && sudo systemctl start httpd && sudo systemctl enable httpd && echo '<h1>Deployed via Pulumi</h1>' | sudo tee /var/www/html/index.html")
.build());
}
}

Enable Auto Snapshots

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import com.pulumi.aws.lightsail.inputs.InstanceAddOnArgs;
import java.util.List;
import java.util.ArrayList;
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 test = new Instance("test", InstanceArgs.builder()
.addOn(InstanceAddOnArgs.builder()
.snapshotTime("06:00")
.status("Enabled")
.type("AutoSnapshot")
.build())
.availabilityZone("us-east-1b")
.blueprintId("amazon_linux_2")
.bundleId("nano_1_0")
.tags(Map.of("foo", "bar"))
.build());
}
}

Availability Zones

Lightsail currently supports the following Availability Zones (e.g., us-east-1a):

  • ap-northeast-1{a,c,d}

  • ap-northeast-2{a,c}

  • ap-south-1{a,b}

  • ap-southeast-1{a,b,c}

  • ap-southeast-2{a,b,c}

  • ca-central-1{a,b}

  • eu-central-1{a,b,c}

  • eu-west-1{a,b,c}

  • eu-west-2{a,b,c}

  • eu-west-3{a,b,c}

  • us-east-1{a,b,c,d,e,f}

  • us-east-2{a,b,c}

  • us-west-2{a,b,c}

Bundles

Lightsail currently supports the following Bundle IDs (e.g., an instance in ap-northeast-1 would use small_2_0):

Prefix

A Bundle ID starts with one of the below size prefixes:

  • nano_

  • micro_

  • small_

  • medium_

  • large_

  • xlarge_

  • 2xlarge_

Suffix

A Bundle ID ends with one of the following suffixes depending on Availability Zone:

  • ap-northeast-1: 2_0

  • ap-northeast-2: 2_0

  • ap-south-1: 2_1

  • ap-southeast-1: 2_0

  • ap-southeast-2: 2_2

  • ca-central-1: 2_0

  • eu-central-1: 2_0

  • eu-west-1: 2_0

  • eu-west-2: 2_0

  • eu-west-3: 2_0

  • us-east-1: 2_0

  • us-east-2: 2_0

  • us-west-2: 2_0

Import

Lightsail Instances can be imported using their name, e.g.,

$ pulumi import aws:lightsail/instance:Instance gitlab_test 'custom_gitlab'

Properties

Link copied to clipboard
val addOn: Output<InstanceAddOn>?

The add on configuration for the instance. Detailed below.

Link copied to clipboard
val arn: Output<String>

The ARN of the Lightsail instance (matches id).

Link copied to clipboard

The Availability Zone in which to create your instance (see list below)

Link copied to clipboard
val blueprintId: Output<String>

The ID for a virtual private server image. A list of available blueprint IDs can be obtained using the AWS CLI command: aws lightsail get-blueprints

Link copied to clipboard
val bundleId: Output<String>

The bundle of specification information (see list below)

Link copied to clipboard
val cpuCount: Output<Int>

The number of vCPUs the instance has.

Link copied to clipboard
val createdAt: Output<String>

The timestamp when the instance was created.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val ipAddressType: Output<String>?

The IP address type of the Lightsail Instance. Valid Values: dualstack | ipv4.

Link copied to clipboard
val ipv6Address: Output<String>

(Deprecated) The first IPv6 address of the Lightsail instance. Use ipv6_addresses attribute instead.

Link copied to clipboard
val ipv6Addresses: Output<List<String>>

List of IPv6 addresses for the Lightsail instance.

Link copied to clipboard
val isStaticIp: Output<Boolean>

A Boolean value indicating whether this instance has a static IP assigned to it.

Link copied to clipboard
val keyPairName: Output<String>?

The name of your key pair. Created in the Lightsail console (cannot use aws.ec2.KeyPair at this time)

Link copied to clipboard
val name: Output<String>

The name of the Lightsail Instance. Names be unique within each AWS Region in your Lightsail account.

Link copied to clipboard

The private IP address of the instance.

Link copied to clipboard
val publicIpAddress: Output<String>

The public IP address of the instance.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val ramSize: Output<Double>

The amount of RAM in GB on the instance (e.g., 1.0).

Link copied to clipboard
val tags: Output<Map<String, String>>?

A 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 default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val tagsAll: Output<Map<String, String>>

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val userData: Output<String>?

Single lined launch script as a string to configure server with additional user data

Link copied to clipboard
val username: Output<String>

The user name for connecting to the instance (e.g., ec2-user).