Repository: pulumi/pulumi-awsx (ts)

Issue:
ecs task definition port mappings not applying all options
### What happened?

ecs task definitions are not applying most of the port mapping options, such as `name`, `appProtocol`, `containerPortRange`, and [some others](https://github.com/pulumi/pulumi-awsx/blob/master/awsx/schema-types.ts#L951).

### Example

setting port mappings like so on either an EC2 or Fargate task definition will result in an unnamed port definition being created, despite `name` being passed

```typescript
portMappings: [
  {
    name: 'my-port-name',
    containerPort: 80,
  },
],
```

this causes issues with service connect which **needs** port mappings to be named. this makes service connect unusable with pulumi.

### Output of `pulumi about`

CLI
Version      3.94.2
Go Version   go1.21.3
Go Compiler  gc

Host
OS       darwin
Version  14.0
Arch     arm64

### Additional context

_No response_

### Contributing

seems like these lines here are the culprits: https://github.com/pulumi/pulumi-awsx/blob/9f5b18b7be1b11f99d7d0dc4d1438bfd996bf996/awsx/ecs/containers.ts#L99C1-L108C2

Pull request:
Fix getMappingInputs removing valid arguments
Fixes #1168

Patch:
diff --git a/awsx/ecs/containers.ts b/awsx/ecs/containers.ts
index 7cdb3680..e4ac350a 100644
--- a/awsx/ecs/containers.ts
+++ b/awsx/ecs/containers.ts
@@ -97,10 +97,11 @@ function computeContainerDefinition(
 }
 
 export function getMappingInputs(
-  mappingInput: { containerPort?: number; hostPort?: number; protocol?: string },
+  mappingInput: schema.TaskDefinitionPortMappingInputs,
   tgPort: number | undefined,
 ): schema.TaskDefinitionPortMappingInputs {
   return {
+    ...mappingInput,
     containerPort: mappingInput.containerPort ?? mappingInput.hostPort ?? tgPort,
     hostPort: mappingInput.hostPort ?? tgPort ?? mappingInput.containerPort,
     protocol: mappingInput.protocol,


Test patch:
diff --git a/awsx/ecs/container.test.ts b/awsx/ecs/container.test.ts
index 74767e76..e044d1d4 100644
--- a/awsx/ecs/container.test.ts
+++ b/awsx/ecs/container.test.ts
@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 import * as pulumi from "@pulumi/pulumi";
+import * as aws from "@pulumi/aws";
 
 import { normalizeTaskDefinitionContainers, getMappingInputs } from "./containers";
 
@@ -32,6 +33,33 @@ describe("port mappings", () => {
       expect(inputs).toMatchObject({ containerPort: containerOut, hostPort: hostOut });
     },
   );
+
+  it("returns all valid arguments", () => {
+    const targetGroup = new aws.lb.TargetGroup("test-tg");
+
+    const inputs = getMappingInputs(
+      {
+        appProtocol: "grpc",
+        containerPort: 1,
+        containerPortRange: "1-65535",
+        hostPort: 2,
+        name: "test-mapping-1-2",
+        protocol: "tcp",
+        targetGroup,
+      },
+      undefined,
+    );
+
+    expect(inputs).toMatchObject({
+      appProtocol: "grpc",
+      containerPort: 1,
+      containerPortRange: "1-65535",
+      hostPort: 2,
+      name: "test-mapping-1-2",
+      protocol: "tcp",
+      targetGroup,
+    });
+  });
 });
 
 function promiseOf<T>(output: pulumi.Output<T>): Promise<T> {