1. Packages
  2. AWS
  3. API Docs
  4. lightsail
  5. StaticIpAttachment
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.lightsail.StaticIpAttachment

Explore with Pulumi AI

Provides a static IP address attachment - relationship between a Lightsail static IP & Lightsail instance.

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

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

const testStaticIp = new aws.lightsail.StaticIp("test", {name: "example"});
const testInstance = new aws.lightsail.Instance("test", {
    name: "example",
    availabilityZone: "us-east-1b",
    blueprintId: "string",
    bundleId: "string",
    keyPairName: "some_key_name",
});
const test = new aws.lightsail.StaticIpAttachment("test", {
    staticIpName: testStaticIp.id,
    instanceName: testInstance.id,
});
Copy
import pulumi
import pulumi_aws as aws

test_static_ip = aws.lightsail.StaticIp("test", name="example")
test_instance = aws.lightsail.Instance("test",
    name="example",
    availability_zone="us-east-1b",
    blueprint_id="string",
    bundle_id="string",
    key_pair_name="some_key_name")
test = aws.lightsail.StaticIpAttachment("test",
    static_ip_name=test_static_ip.id,
    instance_name=test_instance.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		testStaticIp, err := lightsail.NewStaticIp(ctx, "test", &lightsail.StaticIpArgs{
			Name: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		testInstance, err := lightsail.NewInstance(ctx, "test", &lightsail.InstanceArgs{
			Name:             pulumi.String("example"),
			AvailabilityZone: pulumi.String("us-east-1b"),
			BlueprintId:      pulumi.String("string"),
			BundleId:         pulumi.String("string"),
			KeyPairName:      pulumi.String("some_key_name"),
		})
		if err != nil {
			return err
		}
		_, err = lightsail.NewStaticIpAttachment(ctx, "test", &lightsail.StaticIpAttachmentArgs{
			StaticIpName: testStaticIp.ID(),
			InstanceName: testInstance.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var testStaticIp = new Aws.LightSail.StaticIp("test", new()
    {
        Name = "example",
    });

    var testInstance = new Aws.LightSail.Instance("test", new()
    {
        Name = "example",
        AvailabilityZone = "us-east-1b",
        BlueprintId = "string",
        BundleId = "string",
        KeyPairName = "some_key_name",
    });

    var test = new Aws.LightSail.StaticIpAttachment("test", new()
    {
        StaticIpName = testStaticIp.Id,
        InstanceName = testInstance.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.StaticIp;
import com.pulumi.aws.lightsail.StaticIpArgs;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import com.pulumi.aws.lightsail.StaticIpAttachment;
import com.pulumi.aws.lightsail.StaticIpAttachmentArgs;
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 testStaticIp = new StaticIp("testStaticIp", StaticIpArgs.builder()
            .name("example")
            .build());

        var testInstance = new Instance("testInstance", InstanceArgs.builder()
            .name("example")
            .availabilityZone("us-east-1b")
            .blueprintId("string")
            .bundleId("string")
            .keyPairName("some_key_name")
            .build());

        var test = new StaticIpAttachment("test", StaticIpAttachmentArgs.builder()
            .staticIpName(testStaticIp.id())
            .instanceName(testInstance.id())
            .build());

    }
}
Copy
resources:
  test:
    type: aws:lightsail:StaticIpAttachment
    properties:
      staticIpName: ${testStaticIp.id}
      instanceName: ${testInstance.id}
  testStaticIp:
    type: aws:lightsail:StaticIp
    name: test
    properties:
      name: example
  testInstance:
    type: aws:lightsail:Instance
    name: test
    properties:
      name: example
      availabilityZone: us-east-1b
      blueprintId: string
      bundleId: string
      keyPairName: some_key_name
Copy

Create StaticIpAttachment Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new StaticIpAttachment(name: string, args: StaticIpAttachmentArgs, opts?: CustomResourceOptions);
@overload
def StaticIpAttachment(resource_name: str,
                       args: StaticIpAttachmentArgs,
                       opts: Optional[ResourceOptions] = None)

@overload
def StaticIpAttachment(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       instance_name: Optional[str] = None,
                       static_ip_name: Optional[str] = None)
func NewStaticIpAttachment(ctx *Context, name string, args StaticIpAttachmentArgs, opts ...ResourceOption) (*StaticIpAttachment, error)
public StaticIpAttachment(string name, StaticIpAttachmentArgs args, CustomResourceOptions? opts = null)
public StaticIpAttachment(String name, StaticIpAttachmentArgs args)
public StaticIpAttachment(String name, StaticIpAttachmentArgs args, CustomResourceOptions options)
type: aws:lightsail:StaticIpAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. StaticIpAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. StaticIpAttachmentArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. StaticIpAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. StaticIpAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. StaticIpAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var staticIpAttachmentResource = new Aws.LightSail.StaticIpAttachment("staticIpAttachmentResource", new()
{
    InstanceName = "string",
    StaticIpName = "string",
});
Copy
example, err := lightsail.NewStaticIpAttachment(ctx, "staticIpAttachmentResource", &lightsail.StaticIpAttachmentArgs{
	InstanceName: pulumi.String("string"),
	StaticIpName: pulumi.String("string"),
})
Copy
var staticIpAttachmentResource = new StaticIpAttachment("staticIpAttachmentResource", StaticIpAttachmentArgs.builder()
    .instanceName("string")
    .staticIpName("string")
    .build());
Copy
static_ip_attachment_resource = aws.lightsail.StaticIpAttachment("staticIpAttachmentResource",
    instance_name="string",
    static_ip_name="string")
Copy
const staticIpAttachmentResource = new aws.lightsail.StaticIpAttachment("staticIpAttachmentResource", {
    instanceName: "string",
    staticIpName: "string",
});
Copy
type: aws:lightsail:StaticIpAttachment
properties:
    instanceName: string
    staticIpName: string
Copy

StaticIpAttachment Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The StaticIpAttachment resource accepts the following input properties:

InstanceName
This property is required.
Changes to this property will trigger replacement.
string
The name of the Lightsail instance to attach the IP to
StaticIpName
This property is required.
Changes to this property will trigger replacement.
string
The name of the allocated static IP
InstanceName
This property is required.
Changes to this property will trigger replacement.
string
The name of the Lightsail instance to attach the IP to
StaticIpName
This property is required.
Changes to this property will trigger replacement.
string
The name of the allocated static IP
instanceName
This property is required.
Changes to this property will trigger replacement.
String
The name of the Lightsail instance to attach the IP to
staticIpName
This property is required.
Changes to this property will trigger replacement.
String
The name of the allocated static IP
instanceName
This property is required.
Changes to this property will trigger replacement.
string
The name of the Lightsail instance to attach the IP to
staticIpName
This property is required.
Changes to this property will trigger replacement.
string
The name of the allocated static IP
instance_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the Lightsail instance to attach the IP to
static_ip_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the allocated static IP
instanceName
This property is required.
Changes to this property will trigger replacement.
String
The name of the Lightsail instance to attach the IP to
staticIpName
This property is required.
Changes to this property will trigger replacement.
String
The name of the allocated static IP

Outputs

All input properties are implicitly available as output properties. Additionally, the StaticIpAttachment resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
IpAddress string
The allocated static IP address
Id string
The provider-assigned unique ID for this managed resource.
IpAddress string
The allocated static IP address
id String
The provider-assigned unique ID for this managed resource.
ipAddress String
The allocated static IP address
id string
The provider-assigned unique ID for this managed resource.
ipAddress string
The allocated static IP address
id str
The provider-assigned unique ID for this managed resource.
ip_address str
The allocated static IP address
id String
The provider-assigned unique ID for this managed resource.
ipAddress String
The allocated static IP address

Look up Existing StaticIpAttachment Resource

Get an existing StaticIpAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: StaticIpAttachmentState, opts?: CustomResourceOptions): StaticIpAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        instance_name: Optional[str] = None,
        ip_address: Optional[str] = None,
        static_ip_name: Optional[str] = None) -> StaticIpAttachment
func GetStaticIpAttachment(ctx *Context, name string, id IDInput, state *StaticIpAttachmentState, opts ...ResourceOption) (*StaticIpAttachment, error)
public static StaticIpAttachment Get(string name, Input<string> id, StaticIpAttachmentState? state, CustomResourceOptions? opts = null)
public static StaticIpAttachment get(String name, Output<String> id, StaticIpAttachmentState state, CustomResourceOptions options)
resources:  _:    type: aws:lightsail:StaticIpAttachment    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
InstanceName Changes to this property will trigger replacement. string
The name of the Lightsail instance to attach the IP to
IpAddress string
The allocated static IP address
StaticIpName Changes to this property will trigger replacement. string
The name of the allocated static IP
InstanceName Changes to this property will trigger replacement. string
The name of the Lightsail instance to attach the IP to
IpAddress string
The allocated static IP address
StaticIpName Changes to this property will trigger replacement. string
The name of the allocated static IP
instanceName Changes to this property will trigger replacement. String
The name of the Lightsail instance to attach the IP to
ipAddress String
The allocated static IP address
staticIpName Changes to this property will trigger replacement. String
The name of the allocated static IP
instanceName Changes to this property will trigger replacement. string
The name of the Lightsail instance to attach the IP to
ipAddress string
The allocated static IP address
staticIpName Changes to this property will trigger replacement. string
The name of the allocated static IP
instance_name Changes to this property will trigger replacement. str
The name of the Lightsail instance to attach the IP to
ip_address str
The allocated static IP address
static_ip_name Changes to this property will trigger replacement. str
The name of the allocated static IP
instanceName Changes to this property will trigger replacement. String
The name of the Lightsail instance to attach the IP to
ipAddress String
The allocated static IP address
staticIpName Changes to this property will trigger replacement. String
The name of the allocated static IP

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.