1. Packages
  2. AWS
  3. API Docs
  4. elb
  5. LoadBalancerCookieStickinessPolicy
AWS v6.78.0 published on Thursday, Apr 24, 2025 by Pulumi

aws.elb.LoadBalancerCookieStickinessPolicy

Explore with Pulumi AI

Provides a load balancer cookie stickiness policy, which allows an ELB to control the sticky session lifetime of the browser.

Example Usage

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

const lb = new aws.elb.LoadBalancer("lb", {
    name: "test-lb",
    availabilityZones: ["us-east-1a"],
    listeners: [{
        instancePort: 8000,
        instanceProtocol: "http",
        lbPort: 80,
        lbProtocol: "http",
    }],
});
const foo = new aws.elb.LoadBalancerCookieStickinessPolicy("foo", {
    name: "foo-policy",
    loadBalancer: lb.id,
    lbPort: 80,
    cookieExpirationPeriod: 600,
});
Copy
import pulumi
import pulumi_aws as aws

lb = aws.elb.LoadBalancer("lb",
    name="test-lb",
    availability_zones=["us-east-1a"],
    listeners=[{
        "instance_port": 8000,
        "instance_protocol": "http",
        "lb_port": 80,
        "lb_protocol": "http",
    }])
foo = aws.elb.LoadBalancerCookieStickinessPolicy("foo",
    name="foo-policy",
    load_balancer=lb.id,
    lb_port=80,
    cookie_expiration_period=600)
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		lb, err := elb.NewLoadBalancer(ctx, "lb", &elb.LoadBalancerArgs{
			Name: pulumi.String("test-lb"),
			AvailabilityZones: pulumi.StringArray{
				pulumi.String("us-east-1a"),
			},
			Listeners: elb.LoadBalancerListenerArray{
				&elb.LoadBalancerListenerArgs{
					InstancePort:     pulumi.Int(8000),
					InstanceProtocol: pulumi.String("http"),
					LbPort:           pulumi.Int(80),
					LbProtocol:       pulumi.String("http"),
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = elb.NewLoadBalancerCookieStickinessPolicy(ctx, "foo", &elb.LoadBalancerCookieStickinessPolicyArgs{
			Name:                   pulumi.String("foo-policy"),
			LoadBalancer:           lb.ID(),
			LbPort:                 pulumi.Int(80),
			CookieExpirationPeriod: pulumi.Int(600),
		})
		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 lb = new Aws.Elb.LoadBalancer("lb", new()
    {
        Name = "test-lb",
        AvailabilityZones = new[]
        {
            "us-east-1a",
        },
        Listeners = new[]
        {
            new Aws.Elb.Inputs.LoadBalancerListenerArgs
            {
                InstancePort = 8000,
                InstanceProtocol = "http",
                LbPort = 80,
                LbProtocol = "http",
            },
        },
    });

    var foo = new Aws.Elb.LoadBalancerCookieStickinessPolicy("foo", new()
    {
        Name = "foo-policy",
        LoadBalancer = lb.Id,
        LbPort = 80,
        CookieExpirationPeriod = 600,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elb.LoadBalancer;
import com.pulumi.aws.elb.LoadBalancerArgs;
import com.pulumi.aws.elb.inputs.LoadBalancerListenerArgs;
import com.pulumi.aws.elb.LoadBalancerCookieStickinessPolicy;
import com.pulumi.aws.elb.LoadBalancerCookieStickinessPolicyArgs;
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 lb = new LoadBalancer("lb", LoadBalancerArgs.builder()
            .name("test-lb")
            .availabilityZones("us-east-1a")
            .listeners(LoadBalancerListenerArgs.builder()
                .instancePort(8000)
                .instanceProtocol("http")
                .lbPort(80)
                .lbProtocol("http")
                .build())
            .build());

        var foo = new LoadBalancerCookieStickinessPolicy("foo", LoadBalancerCookieStickinessPolicyArgs.builder()
            .name("foo-policy")
            .loadBalancer(lb.id())
            .lbPort(80)
            .cookieExpirationPeriod(600)
            .build());

    }
}
Copy
resources:
  lb:
    type: aws:elb:LoadBalancer
    properties:
      name: test-lb
      availabilityZones:
        - us-east-1a
      listeners:
        - instancePort: 8000
          instanceProtocol: http
          lbPort: 80
          lbProtocol: http
  foo:
    type: aws:elb:LoadBalancerCookieStickinessPolicy
    properties:
      name: foo-policy
      loadBalancer: ${lb.id}
      lbPort: 80
      cookieExpirationPeriod: 600
Copy

Create LoadBalancerCookieStickinessPolicy Resource

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

Constructor syntax

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

@overload
def LoadBalancerCookieStickinessPolicy(resource_name: str,
                                       opts: Optional[ResourceOptions] = None,
                                       lb_port: Optional[int] = None,
                                       load_balancer: Optional[str] = None,
                                       cookie_expiration_period: Optional[int] = None,
                                       name: Optional[str] = None)
func NewLoadBalancerCookieStickinessPolicy(ctx *Context, name string, args LoadBalancerCookieStickinessPolicyArgs, opts ...ResourceOption) (*LoadBalancerCookieStickinessPolicy, error)
public LoadBalancerCookieStickinessPolicy(string name, LoadBalancerCookieStickinessPolicyArgs args, CustomResourceOptions? opts = null)
public LoadBalancerCookieStickinessPolicy(String name, LoadBalancerCookieStickinessPolicyArgs args)
public LoadBalancerCookieStickinessPolicy(String name, LoadBalancerCookieStickinessPolicyArgs args, CustomResourceOptions options)
type: aws:elb:LoadBalancerCookieStickinessPolicy
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. LoadBalancerCookieStickinessPolicyArgs
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. LoadBalancerCookieStickinessPolicyArgs
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. LoadBalancerCookieStickinessPolicyArgs
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. LoadBalancerCookieStickinessPolicyArgs
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. LoadBalancerCookieStickinessPolicyArgs
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 loadBalancerCookieStickinessPolicyResource = new Aws.Elb.LoadBalancerCookieStickinessPolicy("loadBalancerCookieStickinessPolicyResource", new()
{
    LbPort = 0,
    LoadBalancer = "string",
    CookieExpirationPeriod = 0,
    Name = "string",
});
Copy
example, err := elb.NewLoadBalancerCookieStickinessPolicy(ctx, "loadBalancerCookieStickinessPolicyResource", &elb.LoadBalancerCookieStickinessPolicyArgs{
	LbPort:                 pulumi.Int(0),
	LoadBalancer:           pulumi.String("string"),
	CookieExpirationPeriod: pulumi.Int(0),
	Name:                   pulumi.String("string"),
})
Copy
var loadBalancerCookieStickinessPolicyResource = new LoadBalancerCookieStickinessPolicy("loadBalancerCookieStickinessPolicyResource", LoadBalancerCookieStickinessPolicyArgs.builder()
    .lbPort(0)
    .loadBalancer("string")
    .cookieExpirationPeriod(0)
    .name("string")
    .build());
Copy
load_balancer_cookie_stickiness_policy_resource = aws.elb.LoadBalancerCookieStickinessPolicy("loadBalancerCookieStickinessPolicyResource",
    lb_port=0,
    load_balancer="string",
    cookie_expiration_period=0,
    name="string")
Copy
const loadBalancerCookieStickinessPolicyResource = new aws.elb.LoadBalancerCookieStickinessPolicy("loadBalancerCookieStickinessPolicyResource", {
    lbPort: 0,
    loadBalancer: "string",
    cookieExpirationPeriod: 0,
    name: "string",
});
Copy
type: aws:elb:LoadBalancerCookieStickinessPolicy
properties:
    cookieExpirationPeriod: 0
    lbPort: 0
    loadBalancer: string
    name: string
Copy

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

LbPort
This property is required.
Changes to this property will trigger replacement.
int
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
LoadBalancer
This property is required.
Changes to this property will trigger replacement.
string
The load balancer to which the policy should be attached.
CookieExpirationPeriod Changes to this property will trigger replacement. int
The time period after which the session cookie should be considered stale, expressed in seconds.
Name Changes to this property will trigger replacement. string
The name of the stickiness policy.
LbPort
This property is required.
Changes to this property will trigger replacement.
int
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
LoadBalancer
This property is required.
Changes to this property will trigger replacement.
string
The load balancer to which the policy should be attached.
CookieExpirationPeriod Changes to this property will trigger replacement. int
The time period after which the session cookie should be considered stale, expressed in seconds.
Name Changes to this property will trigger replacement. string
The name of the stickiness policy.
lbPort
This property is required.
Changes to this property will trigger replacement.
Integer
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
loadBalancer
This property is required.
Changes to this property will trigger replacement.
String
The load balancer to which the policy should be attached.
cookieExpirationPeriod Changes to this property will trigger replacement. Integer
The time period after which the session cookie should be considered stale, expressed in seconds.
name Changes to this property will trigger replacement. String
The name of the stickiness policy.
lbPort
This property is required.
Changes to this property will trigger replacement.
number
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
loadBalancer
This property is required.
Changes to this property will trigger replacement.
string
The load balancer to which the policy should be attached.
cookieExpirationPeriod Changes to this property will trigger replacement. number
The time period after which the session cookie should be considered stale, expressed in seconds.
name Changes to this property will trigger replacement. string
The name of the stickiness policy.
lb_port
This property is required.
Changes to this property will trigger replacement.
int
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
load_balancer
This property is required.
Changes to this property will trigger replacement.
str
The load balancer to which the policy should be attached.
cookie_expiration_period Changes to this property will trigger replacement. int
The time period after which the session cookie should be considered stale, expressed in seconds.
name Changes to this property will trigger replacement. str
The name of the stickiness policy.
lbPort
This property is required.
Changes to this property will trigger replacement.
Number
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
loadBalancer
This property is required.
Changes to this property will trigger replacement.
String
The load balancer to which the policy should be attached.
cookieExpirationPeriod Changes to this property will trigger replacement. Number
The time period after which the session cookie should be considered stale, expressed in seconds.
name Changes to this property will trigger replacement. String
The name of the stickiness policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the LoadBalancerCookieStickinessPolicy 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 LoadBalancerCookieStickinessPolicy Resource

Get an existing LoadBalancerCookieStickinessPolicy 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?: LoadBalancerCookieStickinessPolicyState, opts?: CustomResourceOptions): LoadBalancerCookieStickinessPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cookie_expiration_period: Optional[int] = None,
        lb_port: Optional[int] = None,
        load_balancer: Optional[str] = None,
        name: Optional[str] = None) -> LoadBalancerCookieStickinessPolicy
func GetLoadBalancerCookieStickinessPolicy(ctx *Context, name string, id IDInput, state *LoadBalancerCookieStickinessPolicyState, opts ...ResourceOption) (*LoadBalancerCookieStickinessPolicy, error)
public static LoadBalancerCookieStickinessPolicy Get(string name, Input<string> id, LoadBalancerCookieStickinessPolicyState? state, CustomResourceOptions? opts = null)
public static LoadBalancerCookieStickinessPolicy get(String name, Output<String> id, LoadBalancerCookieStickinessPolicyState state, CustomResourceOptions options)
resources:  _:    type: aws:elb:LoadBalancerCookieStickinessPolicy    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:
CookieExpirationPeriod Changes to this property will trigger replacement. int
The time period after which the session cookie should be considered stale, expressed in seconds.
LbPort Changes to this property will trigger replacement. int
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
LoadBalancer Changes to this property will trigger replacement. string
The load balancer to which the policy should be attached.
Name Changes to this property will trigger replacement. string
The name of the stickiness policy.
CookieExpirationPeriod Changes to this property will trigger replacement. int
The time period after which the session cookie should be considered stale, expressed in seconds.
LbPort Changes to this property will trigger replacement. int
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
LoadBalancer Changes to this property will trigger replacement. string
The load balancer to which the policy should be attached.
Name Changes to this property will trigger replacement. string
The name of the stickiness policy.
cookieExpirationPeriod Changes to this property will trigger replacement. Integer
The time period after which the session cookie should be considered stale, expressed in seconds.
lbPort Changes to this property will trigger replacement. Integer
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
loadBalancer Changes to this property will trigger replacement. String
The load balancer to which the policy should be attached.
name Changes to this property will trigger replacement. String
The name of the stickiness policy.
cookieExpirationPeriod Changes to this property will trigger replacement. number
The time period after which the session cookie should be considered stale, expressed in seconds.
lbPort Changes to this property will trigger replacement. number
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
loadBalancer Changes to this property will trigger replacement. string
The load balancer to which the policy should be attached.
name Changes to this property will trigger replacement. string
The name of the stickiness policy.
cookie_expiration_period Changes to this property will trigger replacement. int
The time period after which the session cookie should be considered stale, expressed in seconds.
lb_port Changes to this property will trigger replacement. int
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
load_balancer Changes to this property will trigger replacement. str
The load balancer to which the policy should be attached.
name Changes to this property will trigger replacement. str
The name of the stickiness policy.
cookieExpirationPeriod Changes to this property will trigger replacement. Number
The time period after which the session cookie should be considered stale, expressed in seconds.
lbPort Changes to this property will trigger replacement. Number
The load balancer port to which the policy should be applied. This must be an active listener on the load balancer.
loadBalancer Changes to this property will trigger replacement. String
The load balancer to which the policy should be attached.
name Changes to this property will trigger replacement. String
The name of the stickiness policy.

Package Details

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