Skip to content

Commit

Permalink
Remove certificate from Network Load Balanced Service
Browse files Browse the repository at this point in the history
  • Loading branch information
piradeepk committed Aug 20, 2019
1 parent a6efed8 commit 04f2e61
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ICertificate } from '@aws-cdk/aws-certificatemanager';
import { IVpc } from '@aws-cdk/aws-ec2';
import { AwsLogDriver, BaseService, Cluster, ContainerImage, ICluster, LogDriver, Secret } from '@aws-cdk/aws-ecs';
import { NetworkListener, NetworkLoadBalancer, NetworkTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2';
Expand Down Expand Up @@ -60,14 +59,6 @@ export interface NetworkLoadBalancedServiceBaseProps {
*/
readonly desiredCount?: number;

/**
* Certificate Manager certificate to associate with the load balancer.
* Setting this option will set the load balancer port to 443.
*
* @default - No certificate associated with the load balancer.
*/
readonly certificate?: ICertificate;

/**
* The environment variables to pass to the container.
*
Expand Down Expand Up @@ -208,10 +199,6 @@ export abstract class NetworkLoadBalancedServiceBase extends cdk.Construct {
port: 80
};

if (props.certificate !== undefined) {
throw new Error("Cannot add certificate to an NLB");
}

this.listener = this.loadBalancer.addListener('PublicListener', { port: 80 });
this.targetGroup = this.listener.addTargets('ECS', targetProps);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect, haveResourceLike, SynthUtils } from '@aws-cdk/assert';
import { Certificate } from '@aws-cdk/aws-certificatemanager';
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
import iam = require('@aws-cdk/aws-iam');
Expand All @@ -8,27 +7,6 @@ import { Test } from 'nodeunit';
import ecsPatterns = require('../../lib');

export = {
'certificate requires an application load balancer'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });

// WHEN
const cert = new Certificate(stack, 'Cert', { domainName: '*.example.com' });
const toThrow = () => {
new ecsPatterns.NetworkLoadBalancedFargateService(stack, 'Service', {
cluster,
certificate: cert,
image: ecs.ContainerImage.fromRegistry("/aws/aws-example-app")
});
};

// THEN
test.throws(() => toThrow(), /Cannot add certificate to an NLB/);
test.done();
},

'setting loadBalancerType to Network creates an NLB'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 04f2e61

Please sign in to comment.