better-rainbow-14549
02/19/2020, 1:42 PMlimited-rainbow-51650
02/19/2020, 1:46 PMif
-statement with pulumi.isDryRun
to check if you are in preview mode. Within the if block, check your tag values and throw ResourceError
when not OK.
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/runtime/#isDryRun
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#ResourceErrorbetter-rainbow-14549
02/19/2020, 1:50 PMlimited-rainbow-51650
02/19/2020, 1:51 PMbetter-rainbow-14549
02/19/2020, 1:51 PMlimited-rainbow-51650
02/19/2020, 1:52 PMgentle-diamond-70147
02/19/2020, 3:55 PM.getImage
will fail if it cannot find the image. You could potentially use that. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/aws/ecr/#getImagebetter-rainbow-14549
02/19/2020, 3:55 PMexport const verifyImageExistsInRegistry = (imageVersion: pulumi.Input<string>) =>
pulumi.output(imageVersion).apply(async image => {
try {
await docker.getRegistryImage({ name: image });
}
catch (e) {
new pulumi.ResourceError(`${image} metadata could not be loaded`, undefined);
};
});
gentle-diamond-70147
02/19/2020, 3:58 PMbetter-rainbow-14549
02/19/2020, 3:59 PMgentle-diamond-70147
02/19/2020, 4:00 PMbetter-rainbow-14549
02/19/2020, 4:00 PMicy-london-58403
02/19/2020, 8:24 PMpulumi.log.error("error message")
pulumi.log
stuff a lot. There is .error
, .warn
, .info
, .debug
. For example, the debug
is really useful. They don't show unless you run pulumi up
with the -d
flag. Then you get all your debug outputs. Its super helpful when developing because you can get outputs that you don't normally want.
I just put the pulumi.log.error("test")
at the very first line of something I'm working on now and it errored the moment it hit it and didn't go any further and it took me right to the screenshot I posted. Should work perfect for what you need.