miniature-arm-21874
04/01/2020, 3:52 PMconst repo = new awsx.ecr.Repository('my-ecr-repository');
const image = aws.ecr.getImage({
repositoryName: repo.repository.name.apply((name) => name),
imageTag: 'latest',
});
I get Type 'Output<string>' is not assignable to type 'string'. [Error/2322]
for repositoryNamewhite-balloon-205
apply
is called - the getImage
call doesn't accept `Output`s as inputs currently.
const repo = new awsx.ecr.Repository('my-ecr-repository');
const image = repo.repository.name.apply(name => aws.ecr.getImage({
repositoryName: name,
imageTag: 'latest',
}));
miniature-arm-21874
04/01/2020, 7:03 PMrepo/service:latest
but when i first spin up the stack there isn't a latest image because it's not been pushed to the repo yet (obviously). I want to basically try to get the latest image and if it doesn't exist, build a function there and then and tag it as latest to use in the initial deploy. is that something which is possible/sensible?const repo = new awsx.ecr.Repository('example-ecr-repository');
let image;
try {
image = repo.repository.name.apply((name) => {
return aws.ecr.getImage({
repositoryName: name,
imageTag: 'latest',
});
});
} catch (e) {
image = 'caught';
}
console.log('------------------');
console.log(image);
I have a couple of questions-
1. i thought apply was supposed to wait for the output... in this example on first creation of the stack the repo doesn't exist yet so i get a RepositoryNotFoundException 'example-ecr-repository-8e2cb70' does not exist in the registry with id '4744319xxxxx'
but it's got the name and continuing before the repo exists. is it possible to wait for the creation? ecr.getImage
doesn't appear to support dependsOn
2. the try catch is totally ignored so how can i achieve this? I need to make an image if the latest
one doesn't exist yetconst image = pulumi
.all([repo.repository.repositoryUrl, repo.repository.name])
.apply(async ([url, name]) => {
try {
await aws.ecr.getImage(
{
repositoryName: name,
imageTag: 'latest',
},
{ async: true }
);
return `${url}:latest`;
} catch (e) {
return 'nginx:latest';
}
});
this solves question 2, but also accidentally solves question 1 because the catch now catches the RepositoryNotFoundException. not sure why it's not waiting for it's creation first before calling apply(fn)