https://pulumi.com logo
Title
r

rhythmic-vegetable-87369

01/17/2020, 2:47 PM
I would like to use the name or id of the pull request as a suffix while naming my resources during deployment. What would be the best way to achieve this?
p

powerful-football-81694

01/17/2020, 6:08 PM
@rhythmic-vegetable-87369 assuming you are using Azure Pipelines, you can map pipeline variables into environment variables using the
env
property on the step in your pipeline YAML.
I’m not sure exactly what you mean by “name or id of the pull request” and I don’t think there’s a pipeline variable that represents that. You can check the variable references here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables
But you could for example use the
Build.SourceVersion
variable which represents the Git commit ID.
So you could do something like this in your YAML:
- task: Pulumi@1
    inputs:
      ...
    env:
      COMMIT_ID: $(Build.SourceVersion)
And then in your Pulumi program, just read the environment variable
COMMIT_ID
and concatenate that to your resource names.
✔️ 1
t

tall-librarian-49374

01/17/2020, 9:26 PM
It may be helpful to describe your details in https://github.com/pulumi/pulumi/issues/1518