Trying to upload docker image to a repo... ```// ...
# typescript
Trying to upload docker image to a repo...
Copy code
// 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?
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.
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
which expects you to put a fully formed json blob in it ( so understanding wtf is coming back from buildAndPushImage is required to construct that blob (i think).
cc @white-balloon-205 @lemon-spoon-91807
not in front of a computer
but buildAndPushImage shuld return an Output<string>
so this line is effectively:
Copy code
const repImage: Output<string> = repository.buildAndPushImage("./Application");
so TS is complaining that you're assigning an Output<string> to a
from cursory glance, feels like your code should be:
Copy code
export function createImage() : Output<string> {
(working from phone fyi. can't validate fully here)
hrmm... so like, I will go down that path, but I read
Copy code
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.
that's not the buildAndPushImage you're callin though ๐Ÿ™‚
you have... one sec... copy/paste on phoen is awful
Copy code
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.
oh son of a bitch...
no, that's my fault, i was just reading the whole thing wrong.
easy mistake to make. we did name the exact same thnig...
Any cursing is at myself.