From d716d3fb72ee6ae96e4fd01362ae9bdc0e1cb755 Mon Sep 17 00:00:00 2001 From: Victor Duarte Date: Fri, 11 Oct 2024 20:21:18 +0200 Subject: [PATCH] Add portMapping support for enhanced container port configuration --- platform/src/components/aws/cluster.ts | 44 ++++++++++++++++++++++++-- platform/src/components/aws/service.ts | 2 +- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/platform/src/components/aws/cluster.ts b/platform/src/components/aws/cluster.ts index bb0d25851..4cdbcdb0c 100644 --- a/platform/src/components/aws/cluster.ts +++ b/platform/src/components/aws/cluster.ts @@ -958,6 +958,46 @@ export interface ClusterServiceArgs { */ retention?: Input; }>; + /** + * Port mappings allow containers to access ports on the host container instance to send or + * receive traffic. Port mappings are specified as part of the container definition. + */ + portMappings?: Input<{ + /** + * The application protocol that's used for the port mapping. + * This parameter only applies to Service Connect. + * Valid Values: `http | http2 | grpc` + */ + appProtocol?: Input<"http" | "http2" | "grpc">; + /** + * The port number on the container that's bound to the user-specified or automatically assigned host port. + */ + containerPort: Input; + /** + * The port number range on the container that's bound to the dynamically mapped host port range. + */ + containerPortRange?: Input; + /** + * The port number on the container instance to reserve for your container. + * If you omit this field, the host port is automatically assigned. + */ + hostPort?: Input; + /** + * The host port range. + * This is set automatically when using a container port range. + */ + hostPortRange?: Input; + /** + * The protocol used for the port mapping. Valid values are `tcp` and `udp`. + * The default is `tcp`. + */ + protocol?: Input<"tcp" | "udp">; + /** + * The name that's used for the port mapping. + * This parameter only applies to Service Connect. + */ + name?: Input; + }>; /** * Configure how this container works in `sst dev`. Same as the top-level * [`dev`](#dev). @@ -1138,7 +1178,7 @@ export class Cluster extends Component { constructor( name: string, args: ClusterArgs, - opts?: ComponentResourceOptions, + opts?: ComponentResourceOptions ) { const _version = 2; super(__pulumiType, name, args, opts, { @@ -1168,7 +1208,7 @@ export class Cluster extends Component { function createCluster() { return new ecs.Cluster( - ...transform(args.transform?.cluster, `${name}Cluster`, {}, { parent }), + ...transform(args.transform?.cluster, `${name}Cluster`, {}, { parent }) ); } } diff --git a/platform/src/components/aws/service.ts b/platform/src/components/aws/service.ts index ea7ff48fb..547717820 100644 --- a/platform/src/components/aws/service.ts +++ b/platform/src/components/aws/service.ts @@ -619,7 +619,7 @@ export class Service extends Component implements Link.Linkable { command: container.command, entrypoint: container.entrypoint, pseudoTerminal: true, - portMappings: [{ containerPortRange: "1-65535" }], + portMappings: container.portMappings || [{ containerPortRange: "1-65535" }], logConfiguration: { logDriver: "awslogs", options: {