From bf0cb59ef7d64dca3a6067be8fd87f38057856df Mon Sep 17 00:00:00 2001 From: "min.y" Date: Wed, 21 Oct 2026 09:43:12 +1300 Subject: [PATCH] feat: add containerPort to FargateService --- .github/workflows/run_tests.yml | 2 ++ dist/fargate.d.ts | 2 ++ dist/fargate.js | 27 +++++++++++++++++++-------- src/fargate.ts | 4 ++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 7fa972a..7fee68c 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -44,6 +44,8 @@ jobs: shell: bash lock-diff: name: Lock diff + # package-diff posts PR comments via github.event.pull_request.comments_url (missing on push). + if: github.event_name == 'pull_request' runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dist/fargate.d.ts b/dist/fargate.d.ts index 8942391..f74fbb5 100644 --- a/dist/fargate.d.ts +++ b/dist/fargate.d.ts @@ -27,6 +27,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; /** * Set to "default" to run a default image instead of * using the provided repository diff --git a/dist/fargate.js b/dist/fargate.js index 2d3371b..2ad5ced 100644 --- a/dist/fargate.js +++ b/dist/fargate.js @@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", { value: true }); exports.FargateService = void 0; const cdk = __importStar(require("aws-cdk-lib")); @@ -43,7 +53,7 @@ const DEFAULT_VERSION = 'default'; class FargateService extends cdk.NestedStack { constructor(scope, id, props) { super(scope, id, props); - const { healthCheckPath = '/health-check', imageVersion = DEFAULT_VERSION, subDomainIncludingDot = '', stack, cluster, certificate, zone, repository, taskConfiguration, } = props; + const { healthCheckPath = '/health-check', containerPort = 80, imageVersion = DEFAULT_VERSION, subDomainIncludingDot = '', stack, cluster, certificate, zone, repository, taskConfiguration, } = props; // Compile secrets into list of mapped ecs.Secrets const secrets = {}; const secretValues = taskConfiguration.secrets; @@ -73,6 +83,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 32dc592..894278a 100644 --- a/src/fargate.ts +++ b/src/fargate.ts @@ -44,6 +44,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 /** * Set to "default" to run a default image instead of * using the provided repository @@ -69,6 +71,7 @@ export class FargateService extends cdk.NestedStack { const { healthCheckPath = '/health-check', + containerPort = 80, imageVersion = DEFAULT_VERSION, subDomainIncludingDot = '', stack, @@ -119,6 +122,7 @@ export class FargateService extends cdk.NestedStack { desiredCount, taskImageOptions: { image, + containerPort, environment: taskConfiguration?.environment || {}, secrets, },