Instance
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
The add on configuration for the instance. Detailed below.
The Availability Zone in which to create your instance (see list below)
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
The IP address type of the Lightsail Instance. Valid Values: dualstack
| ipv4
.
(Deprecated) The first IPv6 address of the Lightsail instance. Use ipv6_addresses
attribute instead.
List of IPv6 addresses for the Lightsail instance.
A Boolean value indicating whether this instance has a static IP assigned to it.
The name of your key pair. Created in the Lightsail console (cannot use aws.ec2.KeyPair
at this time)
The private IP address of the instance.
The public IP address of the instance.