Skip to content

feat: add containerPort to FargateService - #63

Merged
tractorcow merged 2 commits into
masterfrom
feat/fargate-container-port
Oct 15, 2026
Merged

tractorcow merged 2 commits into
masterfrom
feat/fargate-container-port

Conversation

@min-yeko

Copy link
Copy Markdown
Contributor

Summary

  • Add optional containerPort to FargateService (default 80) for ALB target group and ECS task port mapping.
  • Include the configured port in the nested stack security group alongside 80 and 443.

Test plan

  • Default (no containerPort): unchanged behavior on port 80
  • Custom port: ALB targets healthy and app reachable
  • npm run build / dist in sync

@min-yeko
min-yeko requested a review from tractorcow October 11, 2026 22:58
Comment thread dist/fargate.js Outdated
const groupStack = new security_group_1.SecurityGroup(this, stack.getResourceID('SecurityGroup'), { vpc: cluster.vpc });
const groupStack = new security_group_1.SecurityGroup(this, stack.getResourceID('SecurityGroup'), {
vpc: cluster.vpc,
incomingPorts: [...new Set([80, 443, containerPort])],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containerPort should not be included here; This is the security group open to the whole internet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Task group allows public 80/443, same as before. CDK opens containerPort
// from the load balancer security group when the service is attached.
let securityGroup = defaultSecurityGroup
if (!securityGroup) {
  const groupStack = new SecurityGroup(
    this,
    stack.getResourceID('SecurityGroup'),
    { vpc: cluster.vpc },
  )
  securityGroup = groupStack.securityGroup
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. containerPort is no longer added to public SG ingress.

@tractorcow tractorcow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as commented

@tractorcow
tractorcow merged commit 4617216 into master Oct 15, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@tractorcow
tractorcow deleted the feat/fargate-container-port branch October 28, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants