diff --git a/dist/fargate.d.ts b/dist/fargate.d.ts index 55fe0b6..cf26bd9 100644 --- a/dist/fargate.d.ts +++ b/dist/fargate.d.ts @@ -28,6 +28,8 @@ export type EnvFactory = (stack: StackConfig, defaults: Record) interface FargateServiceProps extends cdk.NestedStackProps { subDomainIncludingDot?: string; healthCheckPath?: string; + /** Container port the task listens on (ALB target group + task port mapping). Default 80. */ + containerPort?: number; stack: StackConfig; cluster: ecs.ICluster; certificate: acm.ICertificate; diff --git a/dist/fargate.js b/dist/fargate.js index 695a918..bab28dd 100644 --- a/dist/fargate.js +++ b/dist/fargate.js @@ -58,7 +58,7 @@ const DEFAULT_IMAGE = 'nginxdemos/hello:latest'; class FargateService extends cdk.NestedStack { constructor(scope, id, props) { super(scope, id, props); - const { healthCheckPath = '/health-check', imageVersion = 'latest', subDomainIncludingDot = '', stack, cluster, certificate, zone, repository, taskConfiguration, securityGroup: defaultSecurityGroup, } = props; + const { healthCheckPath = '/health-check', containerPort = 80, imageVersion = 'latest', subDomainIncludingDot = '', stack, cluster, certificate, zone, repository, taskConfiguration, securityGroup: defaultSecurityGroup, } = props; // Compile secrets into list of mapped ecs.Secrets const secrets = {}; const secretValues = taskConfiguration.secrets; @@ -95,6 +95,7 @@ class FargateService extends cdk.NestedStack { desiredCount, taskImageOptions: { image, + containerPort, environment: taskConfiguration?.environment || {}, secrets, }, diff --git a/src/fargate.ts b/src/fargate.ts index 71c83d8..b5092d4 100644 --- a/src/fargate.ts +++ b/src/fargate.ts @@ -43,6 +43,8 @@ export type EnvFactory = ( interface FargateServiceProps extends cdk.NestedStackProps { subDomainIncludingDot?: string healthCheckPath?: string + /** Container port the task listens on (ALB target group + task port mapping). Default 80. */ + containerPort?: number stack: StackConfig cluster: ecs.ICluster certificate: acm.ICertificate @@ -71,6 +73,7 @@ export class FargateService extends cdk.NestedStack { const { healthCheckPath = '/health-check', + containerPort = 80, imageVersion = 'latest', subDomainIncludingDot = '', stack, @@ -134,6 +137,7 @@ export class FargateService extends cdk.NestedStack { desiredCount, taskImageOptions: { image, + containerPort, environment: taskConfiguration?.environment || {}, secrets, },