0.1.0 • Published 2 years ago
@stackspot/cdk-load-balancer v0.1.0
Load Balancer
Component to create an Application Load Balancer.
How to use
Below are all languages supported by the AWS CDK.
C
Install the dependency:
dotnet add package StackSpot.Cdk.LoadBalancer
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Constructs;
using StackSpot.Cdk.LoadBalancer;
namespace MyStack
{
public class MyStack : Stack
{
internal MyStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
Vpc vpc = new Vpc(this, "MyVpc");
LoadBalancer loadBalancer = new LoadBalancer(this, "MyLoadBalancer", new LoadBalancerProps {
LoadBalancerName = "MyLoabBalancer",
Subnets = new SubnetSelection {
SubnetType = SubnetType.PUBLIC
},
Vpc = vpc
});
}
}
}
F
Not yet supported.
Go
Not yet supported.
Java
Not yet supported.
JavaScript
Install the dependency:
npm install --save @stackspot/cdk-load-balancer
Import the construct into your project, for example:
const { Stack } = require('aws-cdk-lib');
const { SubnetType, Vpc } = require('aws-cdk-lib/aws-ec2');
const { LoadBalancer } = require('@stackspot/cdk-load-balancer');
class MyStack extends Stack {
constructor(scope, id, props) {
super(scope, id, props);
const vpc = new Vpc(this, 'MyVpc');
const loadBalancer = new LoadBalancerEnvComponent(this, 'MyALB', {
loadBalancerName: 'MyLoadBalancer',
subnets: vpc.selectSubnets({ subnetType: SubnetType.PUBLIC }),
vpc,
});
}
}
module.exports = { MyStack };
Python
Not yet supported.
TypeScript
Install the dependency:
npm install --save @stackspot/cdk-load-balancer
Import the construct into your project, for example:
import { Stack, StackProps } from 'aws-cdk-lib';
import { SubnetType, Vpc } from 'aws-cdk-lib/aws-ec2';
import { Construct } from 'constructs';
import { LoadBalancer } from '@stackspot/cdk-load-balancer';
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = new Vpc(this, 'MyVpc');
const loadBalancer = new LoadBalancer(this, 'MyLoadBalancer', {
loadBalancerName: 'MyLoadBalancer',
subnets: vpc.selectSubnets({ subnetType: SubnetType.PUBLIC }),
vpc,
});
}
}
Construct Props
Name | Type | Description |
---|---|---|
ingressIpv4Source? | string[] | Sources that will have access to Load Balancer. Default: []. |
internetFacing? | boolean | Whether this is an internet-facing Load Balancer. Default: false. |
loadBalancerName | string | The name of the Load Balancer. |
subnets | SubnetSelection | The subnets of the Load Balancer. |
vpc | IVpc | The VPC of the Load Balancer. |
Properties
Name | Type | Description |
---|---|---|
applicationLoadBalancer | ApplicationLoadBalancer | The Load Balancer to create. |
securityGroup | SecurityGroup | The security group of the load balancer. |
IAM Least privilege
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:CreateSecurityGroup",
"ec2:DeleteSecurityGroup",
"ec2:DescribeSecurityGroups",
"ec2:RevokeSecurityGroupEgress",
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:Describe*",
"elasticloadbalancing:ModifyLoadBalancerAttributes",
"ssm:GetParameters"
],
"Resource": "*"
}
]
}
Development
Prerequisites
- EditorConfig (Optional)
- Git
- Node.js 17
Setup
cd load-balancer-jsii-component
npm install
0.1.0
2 years ago