Is there a way to have a shell_command that can te...
# general
p
Is there a way to have a shell_command that can tell whether it is being invoked as a dependency of a publish or package goal? I'm working on making a macro that creates AWS ECR via shell_command as suggested here: https://pantsbuild.slack.com/archives/C046T6T9U/p1660713334302559
c
that information is not exposed to the command, but it is available in rule code, so a plugin is able to know this, and as such, it is possible to add this to the
shell_command
target as env var or something like that. It would imply though that the command will have to re-run for each goal as the cache key would then depend on the goal being run.
p
Hmm, so the issue I was trying to resolve was that I want to be able to build images without needing to be logged into AWS. I did a hack that just adds "; exit 0" to the end so that it always succeeds, but it sounds like that would run into the same issue. Is there a way to specify that I never want to cache a target?
Though I guess I don't want the never cache behaviour to imply that things that depend on it always need to be rebuilt? (though given docker has it's own cache, that's probably fine)
c
I don’t think we have this per target (you can always ask pants to run without cache
--no-cache
), but for targets that support using env vars, I can think of work arounds to make them uncachable by providing the current time as the env var value for example..
f
This is essentially just a one-off command, right? Why not just make the repository manually the first time or using the terraform `aws_ecr_repository` resource?
p
not a docker expert, but I think I want a repository per docker image
(as opposed to a registry, which contains respositories, which I want just 1 of)
f
not a docker expert, but I think I want a repository per docker image
I believe that is correct. The ECR terminology is confusing for no apparent reason.
And
aws_ecr_repository
manages repositories. I've used it successfully at a prior job to manage an ECR repository per image in the company's ECR registry.
From a security perspective, I prefer to separate the permission to create a new ECR repository from the permission to push to one.