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

Commit dbb960c

Browse files
author
Luke Hoban
committed
Pass hostPort explicitly in container definitions
Workaround hashicorp/terraform-provider-aws#3401.
1 parent 8bc3c65 commit dbb960c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

aws/service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,16 @@ function computeContainerDefinitions(
327327
const imageOptions = computeImage(imageName, container, ports, repository);
328328
const portMappings = (container.ports || []).map(p => ({
329329
containerPort: p.targetPort || p.port,
330+
// From https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html:
331+
// > For task definitions that use the awsvpc network mode, you should only specify the containerPort.
332+
// > The hostPort can be left blank or it must be the same value as the containerPort.
333+
//
334+
// However, if left blank, it will be automatically populated by AWS, potentially leading to dirty
335+
// diffs even when no changes have been made. Since we are currently always using `awsvpc` mode, we
336+
// go ahead and populate it with the same value as `containerPort`.
337+
//
338+
// See https://github.com/terraform-providers/terraform-provider-aws/issues/3401.
339+
hostPort: p.targetPort || p.port,
330340
}));
331341

332342
// tslint:disable-next-line:max-line-length

0 commit comments

Comments
 (0)