I'm using AWS CDK to create an Elastic Beanstalk Environment with a Network Load Balancer.
The Elastic Beanstalk application and the Load Balancer are both in a private Subnet in a VPC. I want to use an API Gateway with a VPC Link that uses the Network Load Balancer.
In my CDK application I'm creating a elasticbeanstalk.CfnEnvironment. For my ApiGateway I've got a VPC Link like this:
const env: elasticbeanstalk.CfnEnvironment = this.createElasticBeanstalkEnvironment();
const loadBalancer = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this.stack, `DjangoNetworkLoadBalancer`, {
loadBalancerArn: env.loadBalancerArn (not available!)
})
const link = new apigateway.VpcLink(this.stack, `DjangoLoadBalancerLink`, {
targets: [loadBalancer],
});
...
private createElasticBeanstalkEnvironment() {
const env = new elasticbeanstalk.CfnEnvironment(this.stack, 'DjangoBeanstalkEnv', {
applicationName: 'TestApp',
environmentName: 'TestAppDev',
solutionStackName: '64bit Amazon Linux 2 v3.0.1 running Python 3.7'
});
env.optionSettings = [
{
namespace: 'aws:elasticbeanstalk:environment',
optionName: 'LoadBalancerType',
value: 'network'
},
{
namespace: 'aws:elbv2:listener:443',
optionName: 'ListenerEnabled',
value: 'true'
},
{
namespace: 'aws:elbv2:listener:default',
optionName: 'ListenerEnabled',
value: 'false'
}
]
return env;
}
Unfortunately I cannot use the env.loadBalancerArn statement.
Is there any possibility how I can retrieve the load balancer arn of the Environment?