pulumi-awsx icon indicating copy to clipboard operation
pulumi-awsx copied to clipboard

Feedback on ecs.Image APIs

Open joeduffy opened this issue 6 years ago • 0 comments
trafficstars

I am using the ecs.Image APIs to build/publish a private Docker image that is then used from my Kubernetes application. There are a few bits of API feedback as a result (full program below):

  • Should this be in the ecs module? I'd have expected maybe ecr instead?

  • The choice of image as the name of the method, on the type Image, is unfortunate, as the most likely naming ends up with things like image.image(...).

  • Related to that, needing to call two things, instead of just one fromPath-like API, is odd.

  • Why do I need to specify two names for my image, the first when I call fromPath, and the second when I call image on the result?

  • Why is parent required when calling the image function? As you can see below, there actually isn't a natural parent for my particular example, since building is the first thing we do.

Full sample program:

import * as ecs from "@pulumi/awsx";
import * as kx from "@pulumi/kubernetesx";

const img = ecs.Image.fromPath("app", "./app");
const pb = new kx.PodBuilder({
    containers: [{
        image: img.image("app-img", undefined as any),
        ports: { http: 80 },
    }],
});

const dep = new kx.Deployment("nginx", {
    spec: pb.asDeploymentSpec({ replicas: 3 }),
});

const svc = dep.createService({
    type: kx.types.ServiceType.LoadBalancer,
});

export const url = svc.status.loadBalancer.ingress[0].hostname;

I wish I could simply write this as follows:

import * as ecr from "@pulumi/awsx/ecr";
import * as kx from "@pulumi/kubernetesx";

const pb = new kx.PodBuilder({
    containers: [{
        image: new ecr.Image("app", "./app").url,
        ports: { http: 80 },
    }],
});

const dep = new kx.Deployment("nginx", {
    spec: pb.asDeploymentSpec({ replicas: 3 }),
});

const svc = dep.createService({
    type: kx.types.ServiceType.LoadBalancer,
});

export const url = svc.status.loadBalancer.ingress[0].hostname;

joeduffy avatar Nov 20 '19 16:11 joeduffy