Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Pass hostPort explicitly in container definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Hoban committed Apr 24, 2018
1 parent 8bc3c65 commit a51fa95
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions aws/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ function computeContainerDefinitions(
const imageOptions = computeImage(imageName, container, ports, repository);
const portMappings = (container.ports || []).map(p => ({
containerPort: p.targetPort || p.port,
// From https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html:
// > For task definitions that use the awsvpc network mode, you should only specify the containerPort.
// > The hostPort can be left blank or it must be the same value as the containerPort.
// However, if left blank, it will be automatically populated by AWS, potentially leading to dirty
// diffs even when no changes have been made. So we populate it with the same value as `containerPort`.
// See https://github.com/terraform-providers/terraform-provider-aws/issues/3401.
hostPort: p.targetPort || p.port,
}));

// tslint:disable-next-line:max-line-length
Expand Down

0 comments on commit a51fa95

Please sign in to comment.