Skip to main content

Actions for AWS Elastic Load Balancing V2

---

End-of-Support

AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.

For more information on how to migrate, see the Migrating to AWS CDK v2 guide.


This package contains integration actions for ELBv2. See the README of the @aws-cdk/aws-elasticloadbalancingv2 library.

Cognito

ELB allows for requests to be authenticated against a Cognito user pool using the AuthenticateCognitoAction. For details on the setup's requirements, read Prepare to use Amazon Cognito. Here's an example:

import aws_cdk.aws_cognito as cognito
import aws_cdk.aws_ec2 as ec2
import aws_cdk.aws_elasticloadbalancingv2 as elbv2
from aws_cdk.core import App, CfnOutput, Stack
from constructs import Construct
import aws_cdk.aws_elasticloadbalancingv2_actions as actions

Stack): lb = elbv2.ApplicationLoadBalancer(self, "LB",
    vpc=vpc,
    internet_facing=True
)

user_pool = cognito.UserPool(self, "UserPool")
user_pool_client = cognito.UserPoolClient(self, "Client",
    user_pool=user_pool,

    # Required minimal configuration for use with an ELB
    generate_secret=True,
    auth_flows=cognito.AuthFlow(
        user_password=True
    ),
    o_auth=cognito.OAuthSettings(
        flows=cognito.OAuthFlows(
            authorization_code_grant=True
        ),
        scopes=[cognito.OAuthScope.EMAIL],
        callback_urls=[f"https://{lb.loadBalancerDnsName}/oauth2/idpresponse"
        ]
    )
)
cfn_client = user_pool_client.node.default_child
cfn_client.add_property_override("RefreshTokenValidity", 1)
cfn_client.add_property_override("SupportedIdentityProviders", ["COGNITO"])

user_pool_domain = cognito.UserPoolDomain(self, "Domain",
    user_pool=user_pool,
    cognito_domain=cognito.CognitoDomainOptions(
        domain_prefix="test-cdk-prefix"
    )
)

lb.add_listener("Listener",
    port=443,
    certificates=[certificate],
    default_action=actions.AuthenticateCognitoAction(
        user_pool=user_pool,
        user_pool_client=user_pool_client,
        user_pool_domain=user_pool_domain,
        next=elbv2.ListenerAction.fixed_response(200,
            content_type="text/plain",
            message_body="Authenticated"
        )
    )
)

CfnOutput(self, "DNS",
    value=lb.load_balancer_dns_name
)

app = App()
CognitoStack(app, "integ-cognito")
app.synth()

NOTE: this example seems incomplete, I was not able to get the redirect back to the Load Balancer after authentication working. Would love some pointers on what a full working setup actually looks like!

Release files for aws-cdk.aws-elasticloadbalancingv2-actions 1.204.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-cdk.aws-elasticloadbalancingv2-actions 1.204.0
File Size Uploaded
aws-cdk.aws-elasticloadbalancingv2-actions-1.204.0.tar.gz 32.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-cdk.aws-elasticloadbalancingv2-actions 1.204.0
File Interpreter ABI Platform
aws_cdk.aws_elasticloadbalancingv2_actions-1.204.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.6 kB

Release files / aws-cdk.aws-elasticloadbalancingv2-actions-1.204.0.tar.gz

Download URL aws-cdk.aws-elasticloadbalancingv2-actions-1.204.0.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
739c013f36eb41ff8caaa2e5eb3b299176f596506b6ae2f35efc8dff4c070012
BLAKE2b-256 checksum
How to use checksums
36955295589f0e6c16b558f628a3527066d4b5658dd8cccc49c81d4f8e95e040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / aws_cdk.aws_elasticloadbalancingv2_actions-1.204.0-py3-none-any.whl

Download URL aws_cdk.aws_elasticloadbalancingv2_actions-1.204.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a531bce3324f8380140c760dddab501a87dc5cb4f932799ece4120e997814cfc
BLAKE2b-256 checksum
How to use checksums
a1614fb6143d23dcf9976925292303ebdbb686b600c4ba14daf0313069a486b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.204.0 This release

2 release files

1.99.0

2 release files

1.98.0

2 release files

1.95.1

2 release files

1.95.0

2 release files

1.94.1

2 release files

1.94.0

2 release files

1.93.0

2 release files

1.91.0

2 release files

1.90.1

2 release files

1.90.0

2 release files

1.87.1

2 release files

1.87.0

2 release files

1.86.0

2 release files

1.85.0

2 release files

1.84.0

2 release files

1.81.0

2 release files

1.80.0

2 release files

1.79.0

2 release files

1.78.0

2 release files

1.75.0

2 release files

1.74.0

2 release files

1.73.0

2 release files

1.71.0

2 release files

1.70.0

2 release files

1.69.0

2 release files

1.68.0

2 release files

1.64.1

2 release files

1.64.0

2 release files

1.63.0

2 release files

1.61.1

2 release files

1.61.0

2 release files

1.60.0

2 release files

1.59.0

2 release files

1.58.0

2 release files

1.55.0

2 release files

1.54.0

2 release files

1.53.0

2 release files

1.52.0

2 release files

1.47.1

2 release files

1.47.0

2 release files

1.46.0

2 release files

1.42.0

2 release files

1.41.0

2 release files

1.40.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page