Integration actions for AWS ElasticLoadBalancingV2
Project description
Actions for AWS Elastic Load Balancing V2
---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:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
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, Construct, Stack
import ...lib as actionsStack):
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=AuthFlow(
user_password=True,
refresh_token=True
),
o_auth=OAuthSettings(
flows=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=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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for aws-cdk.aws-elasticloadbalancingv2-actions-1.47.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53d4e3794f542cd2c8a4429f144e53a4019a7cde881ee1e8422d8bbb4de12fe9 |
|
MD5 | c4bf5ef1b4a231900f144f6415152fa5 |
|
BLAKE2b-256 | 8c6d4e29235a428224fdabf341b8a12215dfa5b1957f9ce31b106505815e34e7 |
Close
Hashes for aws_cdk.aws_elasticloadbalancingv2_actions-1.47.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cf804a251d7d120991b2bb9e89e47358c68b7ea5f761d0de36316a633557f82 |
|
MD5 | 15839e039b8b4c0e5b15fded96a5b994 |
|
BLAKE2b-256 | 46960b8b76d07047979b3609774f82ac9bea93fd098fec3e36ebd487191a9c36 |