Skip to content

Commit

Permalink
fix(ecs-patterns): Fix issue related to protocol being passed to targ…
Browse files Browse the repository at this point in the history
…et group
  • Loading branch information
piradeepk committed Nov 13, 2019
1 parent 6fa4713 commit 5e6bfce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export interface ApplicationLoadBalancedServiceBaseProps {
/**
* Listener port of the application load balancer that will serve traffic to the service.
*
* @default 80
* @default - The default listener port is determined from the protocol (port 80 for HTTP,
* port 443 for HTTPS). A domain name and zone must be also be specified if using HTTPS.
*/
readonly listenerPort?: number;

Expand Down Expand Up @@ -286,8 +287,7 @@ export abstract class ApplicationLoadBalancedServiceBase extends cdk.Construct {
const protocol = props.protocol !== undefined ? props.protocol : (props.certificate ? ApplicationProtocol.HTTPS : ApplicationProtocol.HTTP);

const targetProps = {
port: props.listenerPort !== undefined ? props.listenerPort : 80,
protocol
port: 80
};

this.listener = this.loadBalancer.addListener('PublicListener', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export abstract class NetworkLoadBalancedServiceBase extends cdk.Construct {
const listenerPort = props.listenerPort !== undefined ? props.listenerPort : 80;

const targetProps = {
port: listenerPort
port: 80
};

this.listener = this.loadBalancer.addListener('PublicListener', { port: listenerPort });
Expand Down
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.l3s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,15 @@ export = {
}]
}));

expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
Port: 80,
Protocol: 'HTTP',
TargetType: "ip",
VpcId: {
Ref: "VPCB9E5F0B4"
}
}));

expect(stack).to(haveResource("AWS::ECS::Service", {
DesiredCount: 1,
LaunchType: "FARGATE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
"FargateNlbServiceLBPublicListenerECSGroup7501571D": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Port": 2015,
"Port": 80,
"Protocol": "TCP",
"TargetType": "ip",
"VpcId": {
Expand Down Expand Up @@ -667,7 +667,7 @@
"FargateAlbServiceLBPublicListenerECSGroupB3826700": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Port": 2015,
"Port": 80,
"Protocol": "HTTP",
"TargetType": "ip",
"VpcId": {
Expand Down

0 comments on commit 5e6bfce

Please sign in to comment.