Instance class

Manages a Lightsail Instance. Use this resource to create easy virtual private servers with custom software already setup.

> 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

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.lightsail.Instance("example", {
    name: "example",
    availabilityZone: "us-east-1b",
    blueprintId: "amazon_linux_2",
    bundleId: "nano_3_0",
    keyPairName: "some_key_name",
    tags: {
        foo: "bar",
    },
});
import pulumi
import pulumi_aws as aws

example = aws.lightsail.Instance("example",
    name="example",
    availability_zone="us-east-1b",
    blueprint_id="amazon_linux_2",
    bundle_id="nano_3_0",
    key_pair_name="some_key_name",
    tags={
        "foo": "bar",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.LightSail.Instance("example", new()
    {
        Name = "example",
        AvailabilityZone = "us-east-1b",
        BlueprintId = "amazon_linux_2",
        BundleId = "nano_3_0",
        KeyPairName = "some_key_name",
        Tags =
        {
            { "foo", "bar" },
        },
    });

});
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.NewInstance(ctx, "example", &lightsail.InstanceArgs{
			Name:             pulumi.String("example"),
			AvailabilityZone: pulumi.String("us-east-1b"),
			BlueprintId:      pulumi.String("amazon_linux_2"),
			BundleId:         pulumi.String("nano_3_0"),
			KeyPairName:      pulumi.String("some_key_name"),
			Tags: pulumi.StringMap{
				"foo": pulumi.String("bar"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_lightsail_instance" "example" {
  name              = "example"
  availability_zone = "us-east-1b"
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_3_0"
  key_pair_name     = "some_key_name"
  tags = {
    "foo" = "bar"
  }
}
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.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 Instance("example", InstanceArgs.builder()
            .name("example")
            .availabilityZone("us-east-1b")
            .blueprintId("amazon_linux_2")
            .bundleId("nano_3_0")
            .keyPairName("some_key_name")
            .tags(Map.of("foo", "bar"))
            .build());

    }
}
resources:
  example:
    type: aws:lightsail:Instance
    properties:
      name: example
      availabilityZone: us-east-1b
      blueprintId: amazon_linux_2
      bundleId: nano_3_0
      keyPairName: some_key_name
      tags:
        foo: bar

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.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.lightsail.Instance("example", {
    name: "example",
    availabilityZone: "us-east-1b",
    blueprintId: "amazon_linux_2",
    bundleId: "nano_3_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",
});
import pulumi
import pulumi_aws as aws

example = aws.lightsail.Instance("example",
    name="example",
    availability_zone="us-east-1b",
    blueprint_id="amazon_linux_2",
    bundle_id="nano_3_0",
    user_data="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")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.LightSail.Instance("example", new()
    {
        Name = "example",
        AvailabilityZone = "us-east-1b",
        BlueprintId = "amazon_linux_2",
        BundleId = "nano_3_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",
    });

});
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.NewInstance(ctx, "example", &lightsail.InstanceArgs{
			Name:             pulumi.String("example"),
			AvailabilityZone: pulumi.String("us-east-1b"),
			BlueprintId:      pulumi.String("amazon_linux_2"),
			BundleId:         pulumi.String("nano_3_0"),
			UserData:         pulumi.String("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"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_lightsail_instance" "example" {
  name              = "example"
  availability_zone = "us-east-1b"
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_3_0"
  user_data         = "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"
}
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.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 Instance("example", InstanceArgs.builder()
            .name("example")
            .availabilityZone("us-east-1b")
            .blueprintId("amazon_linux_2")
            .bundleId("nano_3_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());

    }
}
resources:
  example:
    type: aws:lightsail:Instance
    properties:
      name: example
      availabilityZone: us-east-1b
      blueprintId: amazon_linux_2
      bundleId: nano_3_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

Enable Auto Snapshots

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.lightsail.Instance("example", {
    addOn: {
        type: "AutoSnapshot",
        snapshotTime: "06:00",
        status: "Enabled",
    },
    name: "example",
    availabilityZone: "us-east-1b",
    blueprintId: "amazon_linux_2",
    bundleId: "nano_3_0",
    tags: {
        foo: "bar",
    },
});
import pulumi
import pulumi_aws as aws

example = aws.lightsail.Instance("example",
    add_on={
        "type": "AutoSnapshot",
        "snapshot_time": "06:00",
        "status": "Enabled",
    },
    name="example",
    availability_zone="us-east-1b",
    blueprint_id="amazon_linux_2",
    bundle_id="nano_3_0",
    tags={
        "foo": "bar",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.LightSail.Instance("example", new()
    {
        AddOn = new Aws.LightSail.Inputs.InstanceAddOnArgs
        {
            Type = "AutoSnapshot",
            SnapshotTime = "06:00",
            Status = "Enabled",
        },
        Name = "example",
        AvailabilityZone = "us-east-1b",
        BlueprintId = "amazon_linux_2",
        BundleId = "nano_3_0",
        Tags =
        {
            { "foo", "bar" },
        },
    });

});
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.NewInstance(ctx, "example", &lightsail.InstanceArgs{
			AddOn: &lightsail.InstanceAddOnArgs{
				Type:         pulumi.String("AutoSnapshot"),
				SnapshotTime: pulumi.String("06:00"),
				Status:       pulumi.String("Enabled"),
			},
			Name:             pulumi.String("example"),
			AvailabilityZone: pulumi.String("us-east-1b"),
			BlueprintId:      pulumi.String("amazon_linux_2"),
			BundleId:         pulumi.String("nano_3_0"),
			Tags: pulumi.StringMap{
				"foo": pulumi.String("bar"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_lightsail_instance" "example" {
  add_on = {
    type          = "AutoSnapshot"
    snapshot_time = "06:00"
    status        = "Enabled"
  }
  name              = "example"
  availability_zone = "us-east-1b"
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_3_0"
  tags = {
    "foo" = "bar"
  }
}
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.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 Instance("example", InstanceArgs.builder()
            .addOn(InstanceAddOnArgs.builder()
                .type("AutoSnapshot")
                .snapshotTime("06:00")
                .status("Enabled")
                .build())
            .name("example")
            .availabilityZone("us-east-1b")
            .blueprintId("amazon_linux_2")
            .bundleId("nano_3_0")
            .tags(Map.of("foo", "bar"))
            .build());

    }
}
resources:
  example:
    type: aws:lightsail:Instance
    properties:
      addOn:
        type: AutoSnapshot
        snapshotTime: 06:00
        status: Enabled
      name: example
      availabilityZone: us-east-1b
      blueprintId: amazon_linux_2
      bundleId: nano_3_0
      tags:
        foo: bar

Import

Using pulumi import, import Lightsail Instances using their name. For example:

$ pulumi import aws:lightsail/instance:Instance example 'example'

Constructors

Instance(String name, {InstanceArgs? args, CustomResourceOptions? options})
Creates a new Instance. name The Pulumi resource name. args Arguments used to configure this Instance. The set of arguments for Instance. options Resource options controlling this resource's behavior.
Instance.reference(String urn)
Creates a typed reference to an existing Instance resource.

Properties

addOn ↔ Output<InstanceAddOn?>
Add-on configuration for the instance. See below.
latefinal
arn ↔ Output<String>
ARN of the Lightsail instance (matches id).
latefinal
availabilityZone ↔ Output<String>
Availability Zone in which to create your instance. A list of available zones can be obtained using the AWS CLI command: aws lightsail get-regions --include-availability-zones.
latefinal
blueprintId ↔ Output<String>
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.
latefinal
bundleId ↔ Output<String>
Bundle of specification information. A list of available bundle IDs can be obtained using the AWS CLI command: aws lightsail get-bundles.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
cpuCount ↔ Output<int>
Number of vCPUs the instance has.
latefinal
createdAt ↔ Output<String>
Timestamp when the instance was created.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
ipAddressType ↔ Output<String?>
IP address type of the Lightsail Instance. Valid values: dualstack, ipv4, ipv6. Default: dualstack.
latefinal
ipv6Addresses ↔ Output<List<String>>
List of IPv6 addresses for the Lightsail instance.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
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
isStaticIp ↔ Output<bool>
Whether this instance has a static IP assigned to it.
latefinal
keyPairName ↔ Output<String?>
Name of your key pair. Created in the Lightsail console (cannot use aws.ec2.KeyPair at this time).
latefinal
name ↔ Output<String>
Name of the Lightsail Instance. Names must be unique within each AWS Region in your Lightsail account.
latefinal
privateIpAddress ↔ Output<String>
Private IP address of the instance.
latefinal
publicIpAddress ↔ Output<String>
Public IP address of the instance.
latefinal
ramSize ↔ Output<double>
Amount of RAM in GB on the instance (e.g., 1.0).
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
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tags ↔ Output<Map<String, String>?>
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 defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
userData ↔ Output<String?>
Single lined launch script as a string to configure server with additional user data.
latefinal
username ↔ Output<String>
User name for connecting to the instance (e.g., ec2-user).
latefinal

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, {InstanceState? state, CustomResourceOptions? options}) → Instance
Gets an existing Instance resource's state with the given name and id.