I'm struggling with handing outputs, I have `const...
# general
I'm struggling with handing outputs, I have
const proj = new gitlab.Project(...)
and I want to get
to use in a string literal (typescript). The documentation seems to be indicating that I can do this: `console.log(proj.id.apply(v =>
));` however it doesn't like it
Outputs work like promises. So the following code:
Output<string>.apply(v => "${v}");
would return
The same way that:
Promise<string>.then(v => $"{v}");
If you need to interpolate it into a string literal, then your literal needs to be part of the promise:
var result = proj.id.apply(id => "My project ID is ${id}");
and your
has been interpolated and can be passed to an
Ah, I want to be able to use the string as part of the name of a future task
Copy code
new gitlab.BranchProtection(`BranchProtection(${proj.id}:${project.defaultBranch})`, {...})
and the names don't take
you cannot do that
nor should you
How should I name these then? I have ~ 50 git repos being configured with pulumi, for each of those there may be ~2/3 branches that need configuring, the project ID and branch name was a way to give these a unique identifier
well you know what the branch is and you have a name that you already provided to
, so why not
Project names aren't guaranteed to be unique, a project ID is
Actually, I do have a unique name for it since i use a name for
new gitlab.Project()
a pulumi name must be unique for a given stack, so how could the name you provided to
new gitlab.Project(name, ...)
not be unique?
Hmm, okay i'll do that, thanks
yea, that's what I was getting at
Is there a way to make it only run the
or to at least run them first?
Currently its failing a lot of the create steps
so by default for a
action pulumi does
create new, delete old
but for some types of resources that have unique constraints that default behavior doesn't work so you set
deleteBeforeReplace: true
in the resource options which makes a
action do
delete current, create new
There are scenarios where it may be dangerous to set that so the default is what it is for a reason. But for instance like a pulumi controlled DNS record or something needs to be deleted first before the new one can be created since there can only be 1 with a certain value
You might need to do a
first though since you are actually changing the pulumi names of theses resources so pulumi no longer sees them as the same entity and thus is doing the create and destroy separately
Or if you can't do a full destroy because you don't want to destroy other resources, you would comment out the resources whose names you are changing and then run a
pulumi up
so that it deletes them first since they are no longer declared - then uncomment them with the new names
Or alternatively, you could use pulumi aliases and make the old name an alias and it wouldn't need to recreate them at all
I ended up going with commenting out. But aliases are a good one to know, do they accept Input<String> as a value, otherwise i'd have the same problem correct?
I believe they do but I don't think that would do anything for you
it's just a pulumi name, so the only reason you would use them is if the old pulumi name needed to be changed - so it doesn't really make sense to make aliases pre-emptively IMO they would have no function