https://pulumi.com logo
Title
a

acceptable-army-69872

11/14/2019, 7:23 PM
Trying to upload docker image to a repo...
// import { Repository, RepositoryImage } from "@pulumi/awsx/ecr";

export function createImage() : RepositoryImage {
  const repository = new Repository("myrepo");
  const repImage = repository.buildAndPushImage("./Application");

  return repImage
}
and I get this error on the return line
error TS2739: Type 'OutputInstance<string> & LiftedObject<String, number | "length">' is missing the following properties from type 'RepositoryImage': repository, imageValue, image, environment
. If I change
createImage() : RepositoryImage
to any I get a string error...whats going on here?
b

breezy-hamburger-69619

11/14/2019, 7:55 PM
Hi Patrick, hereโ€™s a complete example that should help you get up and running. Let us know if you continue to have any issues. https://www.pulumi.com/docs/guides/crosswalk/kubernetes/apps/#build-and-deploy-a-container
a

acceptable-army-69872

11/14/2019, 8:03 PM
That example doesn't have the types for buildAndPush, and assumes whatever is consuming the image will magically know what to do with it. My use case involves
aws.ecs.TaskDefinition
which expects you to put a fully formed json blob in it (https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/ecs/taskDefinition.ts#L288) so understanding wtf is coming back from buildAndPushImage is required to construct that blob (i think).
b

breezy-hamburger-69619

11/14/2019, 8:04 PM
cc @white-balloon-205 @lemon-spoon-91807
l

lemon-spoon-91807

11/14/2019, 8:06 PM
not in front of a computer
but buildAndPushImage shuld return an Output<string>
so this line is effectively:
const repImage: Output<string> = repository.buildAndPushImage("./Application");
so TS is complaining that you're assigning an Output<string> to a
RepositoryImage
from cursory glance, feels like your code should be:
export function createImage() : Output<string> {
(working from phone fyi. can't validate fully here)
a

acceptable-army-69872

11/14/2019, 8:10 PM
hrmm... so like, I will go down that path, but I read
export function buildAndPushImage(
    name: string, pathOrBuild: pulumi.Input<string | docker.DockerBuild>, args?: RepositoryArgs, opts?: pulumi.ComponentResourceOptions) {

    const repo = new Repository(name, args, opts);
    const image = repo.buildAndPushImage(pathOrBuild);
    return new RepositoryImage(repo, image);
}
and assumed RepositoryImage was coming back.
l

lemon-spoon-91807

11/14/2019, 8:10 PM
that's not the buildAndPushImage you're callin though ๐Ÿ™‚
you have... one sec... copy/paste on phoen is awful
repository.buildAndPushImage
not: awsx.ecr.buildAndPushImage. One is an instance method on the Repository class. The other is a helper function at the module level.
the module helper basically does all the steps. makes the repo, builds hte image, and returns the RepoImage containing both.
a

acceptable-army-69872

11/14/2019, 8:11 PM
oh son of a bitch...
l

lemon-spoon-91807

11/14/2019, 8:11 PM
๐Ÿ˜•
๐Ÿ˜ž
a

acceptable-army-69872

11/14/2019, 8:12 PM
no, that's my fault, i was just reading the whole thing wrong.
l

lemon-spoon-91807

11/14/2019, 8:12 PM
easy mistake to make. we did name the exact same thnig...
a

acceptable-army-69872

11/14/2019, 8:12 PM
Any cursing is at myself.