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

aws.lightsail.LbHttpsRedirectionPolicy

Explore with Pulumi AI

Configures Https Redirection for a Lightsail Load Balancer. A valid Certificate must be attached to the load balancer in order to enable https redirection.

Example Usage

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

const test = new aws.lightsail.Lb("test", {
    name: "test-load-balancer",
    healthCheckPath: "/",
    instancePort: 80,
    tags: {
        foo: "bar",
    },
});
const testLbCertificate = new aws.lightsail.LbCertificate("test", {
    name: "test-load-balancer-certificate",
    lbName: test.id,
    domainName: "test.com",
});
const testLbCertificateAttachment = new aws.lightsail.LbCertificateAttachment("test", {
    lbName: test.name,
    certificateName: testLbCertificate.name,
});
const testLbHttpsRedirectionPolicy = new aws.lightsail.LbHttpsRedirectionPolicy("test", {
    lbName: test.name,
    enabled: true,
});
Copy
import pulumi
import pulumi_aws as aws

test = aws.lightsail.Lb("test",
    name="test-load-balancer",
    health_check_path="/",
    instance_port=80,
    tags={
        "foo": "bar",
    })
test_lb_certificate = aws.lightsail.LbCertificate("test",
    name="test-load-balancer-certificate",
    lb_name=test.id,
    domain_name="test.com")
test_lb_certificate_attachment = aws.lightsail.LbCertificateAttachment("test",
    lb_name=test.name,
    certificate_name=test_lb_certificate.name)
test_lb_https_redirection_policy = aws.lightsail.LbHttpsRedirectionPolicy("test",
    lb_name=test.name,
    enabled=True)
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 {
		test, err := lightsail.NewLb(ctx, "test", &lightsail.LbArgs{
			Name:            pulumi.String("test-load-balancer"),
			HealthCheckPath: pulumi.String("/"),
			InstancePort:    pulumi.Int(80),
			Tags: pulumi.StringMap{
				"foo": pulumi.String("bar"),
			},
		})
		if err != nil {
			return err
		}
		testLbCertificate, err := lightsail.NewLbCertificate(ctx, "test", &lightsail.LbCertificateArgs{
			Name:       pulumi.String("test-load-balancer-certificate"),
			LbName:     test.ID(),
			DomainName: pulumi.String("test.com"),
		})
		if err != nil {
			return err
		}
		_, err = lightsail.NewLbCertificateAttachment(ctx, "test", &lightsail.LbCertificateAttachmentArgs{
			LbName:          test.Name,
			CertificateName: testLbCertificate.Name,
		})
		if err != nil {
			return err
		}
		_, err = lightsail.NewLbHttpsRedirectionPolicy(ctx, "test", &lightsail.LbHttpsRedirectionPolicyArgs{
			LbName:  test.Name,
			Enabled: pulumi.Bool(true),
		})
		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 test = new Aws.LightSail.Lb("test", new()
    {
        Name = "test-load-balancer",
        HealthCheckPath = "/",
        InstancePort = 80,
        Tags = 
        {
            { "foo", "bar" },
        },
    });

    var testLbCertificate = new Aws.LightSail.LbCertificate("test", new()
    {
        Name = "test-load-balancer-certificate",
        LbName = test.Id,
        DomainName = "test.com",
    });

    var testLbCertificateAttachment = new Aws.LightSail.LbCertificateAttachment("test", new()
    {
        LbName = test.Name,
        CertificateName = testLbCertificate.Name,
    });

    var testLbHttpsRedirectionPolicy = new Aws.LightSail.LbHttpsRedirectionPolicy("test", new()
    {
        LbName = test.Name,
        Enabled = true,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.Lb;
import com.pulumi.aws.lightsail.LbArgs;
import com.pulumi.aws.lightsail.LbCertificate;
import com.pulumi.aws.lightsail.LbCertificateArgs;
import com.pulumi.aws.lightsail.LbCertificateAttachment;
import com.pulumi.aws.lightsail.LbCertificateAttachmentArgs;
import com.pulumi.aws.lightsail.LbHttpsRedirectionPolicy;
import com.pulumi.aws.lightsail.LbHttpsRedirectionPolicyArgs;
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 Lb("test", LbArgs.builder()
            .name("test-load-balancer")
            .healthCheckPath("/")
            .instancePort(80)
            .tags(Map.of("foo", "bar"))
            .build());

        var testLbCertificate = new LbCertificate("testLbCertificate", LbCertificateArgs.builder()
            .name("test-load-balancer-certificate")
            .lbName(test.id())
            .domainName("test.com")
            .build());

        var testLbCertificateAttachment = new LbCertificateAttachment("testLbCertificateAttachment", LbCertificateAttachmentArgs.builder()
            .lbName(test.name())
            .certificateName(testLbCertificate.name())
            .build());

        var testLbHttpsRedirectionPolicy = new LbHttpsRedirectionPolicy("testLbHttpsRedirectionPolicy", LbHttpsRedirectionPolicyArgs.builder()
            .lbName(test.name())
            .enabled(true)
            .build());

    }
}
Copy
resources:
  test:
    type: aws:lightsail:Lb
    properties:
      name: test-load-balancer
      healthCheckPath: /
      instancePort: '80'
      tags:
        foo: bar
  testLbCertificate:
    type: aws:lightsail:LbCertificate
    name: test
    properties:
      name: test-load-balancer-certificate
      lbName: ${test.id}
      domainName: test.com
  testLbCertificateAttachment:
    type: aws:lightsail:LbCertificateAttachment
    name: test
    properties:
      lbName: ${test.name}
      certificateName: ${testLbCertificate.name}
  testLbHttpsRedirectionPolicy:
    type: aws:lightsail:LbHttpsRedirectionPolicy
    name: test
    properties:
      lbName: ${test.name}
      enabled: true
Copy

Create LbHttpsRedirectionPolicy Resource

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

Constructor syntax

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

@overload
def LbHttpsRedirectionPolicy(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             enabled: Optional[bool] = None,
                             lb_name: Optional[str] = None)
func NewLbHttpsRedirectionPolicy(ctx *Context, name string, args LbHttpsRedirectionPolicyArgs, opts ...ResourceOption) (*LbHttpsRedirectionPolicy, error)
public LbHttpsRedirectionPolicy(string name, LbHttpsRedirectionPolicyArgs args, CustomResourceOptions? opts = null)
public LbHttpsRedirectionPolicy(String name, LbHttpsRedirectionPolicyArgs args)
public LbHttpsRedirectionPolicy(String name, LbHttpsRedirectionPolicyArgs args, CustomResourceOptions options)
type: aws:lightsail:LbHttpsRedirectionPolicy
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. LbHttpsRedirectionPolicyArgs
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. LbHttpsRedirectionPolicyArgs
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. LbHttpsRedirectionPolicyArgs
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. LbHttpsRedirectionPolicyArgs
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. LbHttpsRedirectionPolicyArgs
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 lbHttpsRedirectionPolicyResource = new Aws.LightSail.LbHttpsRedirectionPolicy("lbHttpsRedirectionPolicyResource", new()
{
    Enabled = false,
    LbName = "string",
});
Copy
example, err := lightsail.NewLbHttpsRedirectionPolicy(ctx, "lbHttpsRedirectionPolicyResource", &lightsail.LbHttpsRedirectionPolicyArgs{
	Enabled: pulumi.Bool(false),
	LbName:  pulumi.String("string"),
})
Copy
var lbHttpsRedirectionPolicyResource = new LbHttpsRedirectionPolicy("lbHttpsRedirectionPolicyResource", LbHttpsRedirectionPolicyArgs.builder()
    .enabled(false)
    .lbName("string")
    .build());
Copy
lb_https_redirection_policy_resource = aws.lightsail.LbHttpsRedirectionPolicy("lbHttpsRedirectionPolicyResource",
    enabled=False,
    lb_name="string")
Copy
const lbHttpsRedirectionPolicyResource = new aws.lightsail.LbHttpsRedirectionPolicy("lbHttpsRedirectionPolicyResource", {
    enabled: false,
    lbName: "string",
});
Copy
type: aws:lightsail:LbHttpsRedirectionPolicy
properties:
    enabled: false
    lbName: string
Copy

LbHttpsRedirectionPolicy 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 LbHttpsRedirectionPolicy resource accepts the following input properties:

Enabled This property is required. bool
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
LbName
This property is required.
Changes to this property will trigger replacement.
string
The name of the load balancer to which you want to enable http to https redirection.
Enabled This property is required. bool
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
LbName
This property is required.
Changes to this property will trigger replacement.
string
The name of the load balancer to which you want to enable http to https redirection.
enabled This property is required. Boolean
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lbName
This property is required.
Changes to this property will trigger replacement.
String
The name of the load balancer to which you want to enable http to https redirection.
enabled This property is required. boolean
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lbName
This property is required.
Changes to this property will trigger replacement.
string
The name of the load balancer to which you want to enable http to https redirection.
enabled This property is required. bool
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lb_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the load balancer to which you want to enable http to https redirection.
enabled This property is required. Boolean
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lbName
This property is required.
Changes to this property will trigger replacement.
String
The name of the load balancer to which you want to enable http to https redirection.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing LbHttpsRedirectionPolicy Resource

Get an existing LbHttpsRedirectionPolicy 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?: LbHttpsRedirectionPolicyState, opts?: CustomResourceOptions): LbHttpsRedirectionPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        enabled: Optional[bool] = None,
        lb_name: Optional[str] = None) -> LbHttpsRedirectionPolicy
func GetLbHttpsRedirectionPolicy(ctx *Context, name string, id IDInput, state *LbHttpsRedirectionPolicyState, opts ...ResourceOption) (*LbHttpsRedirectionPolicy, error)
public static LbHttpsRedirectionPolicy Get(string name, Input<string> id, LbHttpsRedirectionPolicyState? state, CustomResourceOptions? opts = null)
public static LbHttpsRedirectionPolicy get(String name, Output<String> id, LbHttpsRedirectionPolicyState state, CustomResourceOptions options)
resources:  _:    type: aws:lightsail:LbHttpsRedirectionPolicy    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:
Enabled bool
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
LbName Changes to this property will trigger replacement. string
The name of the load balancer to which you want to enable http to https redirection.
Enabled bool
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
LbName Changes to this property will trigger replacement. string
The name of the load balancer to which you want to enable http to https redirection.
enabled Boolean
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lbName Changes to this property will trigger replacement. String
The name of the load balancer to which you want to enable http to https redirection.
enabled boolean
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lbName Changes to this property will trigger replacement. string
The name of the load balancer to which you want to enable http to https redirection.
enabled bool
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lb_name Changes to this property will trigger replacement. str
The name of the load balancer to which you want to enable http to https redirection.
enabled Boolean
The Https Redirection state of the load balancer. true to activate http to https redirection or false to deactivate http to https redirection.
lbName Changes to this property will trigger replacement. String
The name of the load balancer to which you want to enable http to https redirection.

Import

Using pulumi import, import aws_lightsail_lb_https_redirection_policy using the lb_name attribute. For example:

$ pulumi import aws:lightsail/lbHttpsRedirectionPolicy:LbHttpsRedirectionPolicy test example-load-balancer
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

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