Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add portMapping support for enhanced container port configuration #1250

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions platform/src/components/aws/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,46 @@ export interface ClusterServiceArgs {
*/
retention?: Input<keyof typeof RETENTION>;
}>;
/**
* 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<number>;
/**
* The port number range on the container that's bound to the dynamically mapped host port range.
*/
containerPortRange?: Input<string>;
/**
* 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<number>;
/**
* The host port range.
* This is set automatically when using a container port range.
*/
hostPortRange?: Input<string>;
/**
* 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<string>;
}>;
/**
* Configure how this container works in `sst dev`. Same as the top-level
* [`dev`](#dev).
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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 })
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down