Hi I am working on AWS CDK to create load balancer. I am familiar with cloud formation. During creation of Load Balancer I want to give subnets as below.
LB:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Tags:
-
Key: "Name"
Value: !Ref "AWS::StackName"
Subnets:
-
Fn::ImportValue: "infra-vpc-base::SubnetIdPrivateAz1"
-
Fn::ImportValue: "infra-vpc-base::SubnetIdPrivateAz2"
I tried to create LB in cdk as below.
lb = elbv2.ApplicationLoadBalancer(
self, "LB",
load_balancer_name="Load Balancer CDK",
vpc = vpc,
internet_facing= False,
security_group= mws_vpc_sg_alb,
vpc_subnets= ???
)
In the above code vpc_subnets I want to give two subnets. In the above code vpc_subnets is of type typing.optional[aws_cdk.aws_ec2.SubnetSelection]= none.
Can someone help me to get subnet selection in AWS CDK?