Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-elasticloadbalancingv2): support for ALB/NLB #750

Merged
merged 12 commits into from
Sep 26, 2018
25 changes: 23 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#!/bin/bash
set -euo pipefail

bail="--no-bail"
while [[ "${1:-}" != "" ]]; do
case $1 in
-h|--help)
echo "Usage: build.sh [--bail|-b] [--force|-f]"
exit 1
;;
-b|--bail)
bail="--bail"
;;
-f|--force)
export CDK_BUILD="--force"
;;
*)
echo "Unrecognized parameter: $1"
exit 1
;;
esac
shift
done

if [ ! -d node_modules ]; then
/bin/bash ./install.sh
fi
Expand All @@ -24,10 +45,10 @@ trap "rm -rf $MERKLE_BUILD_CACHE" EXIT

echo "============================================================================================="
echo "building..."
time lerna run --no-bail --stream build || fail
time lerna run $bail --stream build || fail

echo "============================================================================================="
echo "testing..."
lerna run --no-bail --stream test || fail
lerna run $bail --stream test || fail

touch $BUILD_INDICATOR
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ export class AutoScalingGroup extends cdk.Construct implements elb.ILoadBalancer
private readonly autoScalingGroup: cloudformation.AutoScalingGroupResource;
private readonly securityGroup: ec2.SecurityGroupRef;
private readonly securityGroups: ec2.SecurityGroupRef[] = [];
private readonly loadBalancerNames: cdk.Token[] = [];
private readonly targetGroupArns: cdk.Token[] = [];
private readonly loadBalancerNames: string[] = [];
private readonly targetGroupArns: string[] = [];

constructor(parent: cdk.Construct, name: string, props: AutoScalingGroupProps) {
super(parent, name);
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-autoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
"pkglint": "^0.9.2"
},
"dependencies": {
"@aws-cdk/aws-ec2": "^0.9.1",
"@aws-cdk/aws-elasticloadbalancing": "^0.9.1",
"@aws-cdk/aws-elasticloadbalancingv2": "^0.9.1",
"@aws-cdk/aws-iam": "^0.9.1",
"@aws-cdk/aws-sns": "^0.9.1",
"@aws-cdk/cdk": "^0.9.1"
"@aws-cdk/aws-ec2": "^0.9.2",
"@aws-cdk/aws-elasticloadbalancing": "^0.9.2",
"@aws-cdk/aws-elasticloadbalancingv2": "^0.9.2",
"@aws-cdk/aws-iam": "^0.9.2",
"@aws-cdk/aws-sns": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2"
},
"homepage": "https://github.com/awslabs/aws-cdk"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ApplicationListenerCertificateProps {
*
* Duplicates are not allowed.
*/
certificateArns: cdk.Arn[];
certificateArns: string[];
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cdk = require('@aws-cdk/cdk');
import { cloudformation, ListenerRuleArn } from '../elasticloadbalancingv2.generated';
import { cloudformation } from '../elasticloadbalancingv2.generated';
import { IApplicationListener } from './application-listener';
import { IApplicationTargetGroup } from './application-target-group';

Expand Down Expand Up @@ -61,7 +61,7 @@ export class ApplicationListenerRule extends cdk.Construct implements cdk.IDepen
/**
* The ARN of this rule
*/
public readonly listenerRuleArn: ListenerRuleArn;
public readonly listenerRuleArn: string;

/**
* The elements of this rule to add ordering dependencies on
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/cdk');
import { ListenerArn } from '../elasticloadbalancingv2.generated';
import { BaseListener, ListenerRefProps } from '../shared/base-listener';
import { HealthCheck } from '../shared/base-target-group';
import { ApplicationProtocol, SslPolicy } from '../shared/enums';
Expand Down Expand Up @@ -32,7 +31,7 @@ export interface BaseApplicationListenerProps {
/**
* The certificates to use on this listener
*/
certificateArns?: cdk.Arn[];
certificateArns?: string[];

/**
* The security policy that defines which ciphers and protocols are supported.
Expand Down Expand Up @@ -78,7 +77,7 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
/**
* ARNs of certificates added to this listener
*/
private readonly certificateArns: cdk.Arn[];
private readonly certificateArns: string[];

/**
* Load balancer this listener is associated with
Expand Down Expand Up @@ -119,7 +118,7 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
/**
* Add one or more certificates to this listener.
*/
public addCertificateArns(_id: string, ...arns: cdk.Arn[]): void {
public addCertificateArns(_id: string, arns: string[]): void {
this.certificateArns.push(...arns);
}

Expand Down Expand Up @@ -228,12 +227,12 @@ export interface IApplicationListener extends ec2.IConnectable {
/**
* ARN of the listener
*/
listenerArn: ListenerArn;
listenerArn: string;

/**
* Add one or more certificates to this listener.
*/
addCertificateArns(id: string, ...arns: cdk.Arn[]): void;
addCertificateArns(id: string, arns: string[]): void;

/**
* Load balance incoming requests to the given target groups.
Expand Down Expand Up @@ -271,7 +270,7 @@ class ImportedApplicationListener extends BaseImportedListener implements IAppli
/**
* Add one or more certificates to this listener.
*/
public addCertificateArns(id: string, ...arns: cdk.Arn[]): void {
public addCertificateArns(id: string, arns: string[]): void {
new ApplicationListenerCertificate(this, id, {
listener: this,
certificateArns: arns
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ec2 = require('@aws-cdk/aws-ec2');
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import { LoadBalancerArn } from '../elasticloadbalancingv2.generated';
import { BaseLoadBalancer, BaseLoadBalancerProps, LoadBalancerRefProps } from '../shared/base-load-balancer';
import { IpAddressType } from '../shared/enums';
import { BaseImportedLoadBalancer } from '../shared/imported';
Expand Down Expand Up @@ -114,7 +113,7 @@ export interface IApplicationLoadBalancer extends ec2.IConnectable {
/**
* The ARN of this load balancer
*/
readonly loadBalancerArn: LoadBalancerArn;
readonly loadBalancerArn: string;

/**
* The VPC this load balancer has been created in (if available)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export class ApplicationTargetGroup extends BaseTargetGroup {
*/
public registerConnectable(connectable: ec2.IConnectable, portRange?: ec2.IPortRange) {
if (portRange === undefined) {
if (cdk.isToken(this.defaultPort)) {
portRange = new ec2.TcpPortFromAttribute(new cdk.Token(this.defaultPort));
if (cdk.unresolved(this.defaultPort)) {
portRange = new ec2.TcpPortFromAttribute(this.defaultPort);
} else {
portRange = new ec2.TcpPort(parseInt(this.defaultPort, 10));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cdk = require('@aws-cdk/cdk');
import { ListenerArn } from '../elasticloadbalancingv2.generated';
import { BaseListener, ListenerRefProps } from '../shared/base-listener';
import { HealthCheck } from '../shared/base-target-group';
import { Protocol } from '../shared/enums';
Expand Down Expand Up @@ -58,6 +57,8 @@ export class NetworkListener extends BaseListener implements INetworkListener {
});

this.loadBalancer = props.loadBalancer;

(props.defaultTargetGroups || []).forEach(this._addDefaultTargetGroup.bind(this));
}

/**
Expand Down Expand Up @@ -107,7 +108,7 @@ export interface INetworkListener {
/**
* ARN of the listener
*/
listenerArn: ListenerArn;
listenerArn: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/cdk');
import { LoadBalancerArn } from '../elasticloadbalancingv2.generated';
import { BaseLoadBalancer, BaseLoadBalancerProps, LoadBalancerRefProps } from '../shared/base-load-balancer';
import { BaseImportedLoadBalancer } from '../shared/imported';
import { BaseNetworkListenerProps, NetworkListener } from './network-listener';
Expand Down Expand Up @@ -53,7 +52,7 @@ export interface INetworkLoadBalancer {
/**
* The ARN of this load balancer
*/
readonly loadBalancerArn: LoadBalancerArn;
readonly loadBalancerArn: string;

/**
* The VPC this load balancer has been created in (if available)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import cdk = require('@aws-cdk/cdk');
import { cloudformation, ListenerArn } from '../elasticloadbalancingv2.generated';
import { cloudformation } from '../elasticloadbalancingv2.generated';
import { ITargetGroup } from './base-target-group';

/**
* Base class for listeners
*/
export abstract class BaseListener extends cdk.Construct {
public readonly listenerArn: ListenerArn;
public readonly listenerArn: string;
private readonly defaultActions: any[] = [];

constructor(parent: cdk.Construct, id: string, additionalProps: any) {
Expand All @@ -25,7 +25,7 @@ export abstract class BaseListener extends cdk.Construct {
*/
public export(): ListenerRefProps {
return {
listenerArn: new ListenerArn(new cdk.Output(this, 'ListenerArn', { value: this.listenerArn }).makeImportValue())
listenerArn: new cdk.Output(this, 'ListenerArn', { value: this.listenerArn }).makeImportValue().toString()
};
}

Expand Down Expand Up @@ -57,5 +57,5 @@ export interface ListenerRefProps {
/**
* ARN of the listener
*/
listenerArn: ListenerArn;
listenerArn: string;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/cdk');
import { cloudformation, LoadBalancerArn, LoadBalancerCanonicalHostedZoneId, LoadBalancerDnsName,
LoadBalancerFullName, LoadBalancerName } from '../elasticloadbalancingv2.generated';
import { cloudformation } from '../elasticloadbalancingv2.generated';
import { Attributes, ifUndefined, renderAttributes } from './util';

/**
Expand Down Expand Up @@ -51,35 +50,35 @@ export abstract class BaseLoadBalancer extends cdk.Construct {
*
* @example Z2P70J7EXAMPLE
*/
public readonly canonicalHostedZoneId: LoadBalancerCanonicalHostedZoneId;
public readonly canonicalHostedZoneId: string;

/**
* The DNS name of this load balancer
*
* @example my-load-balancer-424835706.us-west-2.elb.amazonaws.com
*/
public readonly dnsName: LoadBalancerDnsName;
public readonly dnsName: string;

/**
* The full name of this load balancer
*
* @example app/my-load-balancer/50dc6c495c0c9188
*/
public readonly fullName: LoadBalancerFullName;
public readonly fullName: string;

/**
* The name of this load balancer
*
* @example my-load-balancer
*/
public readonly loadBalancerName: LoadBalancerName;
public readonly loadBalancerName: string;

/**
* The ARN of this load balancer
*
* @example arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/50dc6c495c0c9188
*/
public readonly loadBalancerArn: LoadBalancerArn;
public readonly loadBalancerArn: string;

/**
* The VPC this load balancer has been created in, if available
Expand Down Expand Up @@ -141,7 +140,7 @@ export abstract class BaseLoadBalancer extends cdk.Construct {
*/
public export(): LoadBalancerRefProps {
return {
loadBalancerArn: new LoadBalancerArn(new cdk.Output(this, 'LoadBalancerArn', { value: this.loadBalancerArn }).makeImportValue())
loadBalancerArn: new cdk.Output(this, 'LoadBalancerArn', { value: this.loadBalancerArn }).makeImportValue().toString()
};
}
}
Expand All @@ -153,5 +152,5 @@ export interface LoadBalancerRefProps {
/**
* ARN of the load balancer
*/
loadBalancerArn: LoadBalancerArn;
loadBalancerArn: string;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/cdk');
import { cloudformation, TargetGroupArn, TargetGroupFullName, TargetGroupName } from '../elasticloadbalancingv2.generated';
import { cloudformation } from '../elasticloadbalancingv2.generated';
import { Protocol, TargetType } from './enums';
import { Attributes, renderAttributes } from './util';

Expand Down Expand Up @@ -123,17 +123,17 @@ export abstract class BaseTargetGroup extends cdk.Construct implements ITargetGr
/**
* The ARN of the target group
*/
public readonly targetGroupArn: TargetGroupArn;
public readonly targetGroupArn: string;

/**
* The full name of the target group
*/
public readonly targetGroupFullName: TargetGroupFullName;
public readonly targetGroupFullName: string;

/**
* The name of the target group
*/
public readonly targetGroupName: TargetGroupName;
public readonly targetGroupName: string;

/**
* Health check for the members of this target group
Expand Down Expand Up @@ -222,7 +222,7 @@ export abstract class BaseTargetGroup extends cdk.Construct implements ITargetGr
*/
public export(): TargetGroupRefProps {
return {
targetGroupArn: new TargetGroupArn(new cdk.Output(this, 'TargetGroupArn', { value: this.targetGroupArn }).makeImportValue()),
targetGroupArn: new cdk.Output(this, 'TargetGroupArn', { value: this.targetGroupArn }).makeImportValue().toString(),
defaultPort: new cdk.Output(this, 'Port', { value: this.defaultPort }).makeImportValue().toString(),
};
}
Expand Down Expand Up @@ -261,7 +261,7 @@ export interface TargetGroupRefProps {
/**
* ARN of the target group
*/
targetGroupArn: TargetGroupArn;
targetGroupArn: string;

/**
* Port target group is listening on
Expand All @@ -276,7 +276,7 @@ export interface ITargetGroup {
/**
* ARN of the target group
*/
readonly targetGroupArn: TargetGroupArn;
readonly targetGroupArn: string;
}

/**
Expand Down
Loading