https://pulumi.com logo
#general
Title
# general
e

eager-cartoon-54068

04/09/2020, 11:04 PM
I’m using Pulumi with AWS and pulumi usually adds a suffix to resources it deploys, but in the case of
aws.batch.ComputeEnvironment
, I have to specify
computeEnvironmentName
and that exact name is used to deploy the resource. If I make any changes to the CE, I have to go in and change the name to avoid a conflict. Is there a way to get the suffix that Pulumi normally adds to resources so I don’t have to change the name every time I want to update an AWS Batch Compute Environment?
g

gentle-diamond-70147

04/09/2020, 11:08 PM
You can use the Random package to get a stable random string that you could use as a suffix. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/random/#RandomString
e

eager-cartoon-54068

04/09/2020, 11:46 PM
thanks! I’ll try this out in the morning.
Whenever I declare
Copy code
const id = new random.RandomId("id", {byteLength: 8});
I always get
Copy code
error: Duplicate resource URN 'urn:pulumi:dev::folding-foundation::random:index/randomId:RandomId::id'; try giving it a unique name
if I rename it and try to deploy, I get the same error. I haven’t tried using the generated id in any of the resources yet.
it doesn’t seem to matter what the name is, and I’m only making this one call to the
random
package.
for instance
Copy code
const idasdf = new random.RandomId("id-asdf", {byteLength: 8});

    error: Duplicate resource URN 'urn:pulumi:dev::folding-foundation::random:index/randomId:RandomId::id-asdf'; try giving it a unique name
I figured it out. I forgot that I’m using multiple providers so the id was being used multiple times.
👍 1
doh! I hadn’t noticed
computeEnvironmentNamePrefix
. It’s unfortunate that you can’t set the length of the id to generate, but this does what I need.
g

gentle-diamond-70147

04/10/2020, 8:55 PM
You can set the length of
RandomString
, but
computeEnvironmentNamePrefix
is likely easier in the long run.
e

eager-cartoon-54068

04/10/2020, 8:56 PM
yep. Agreed
8 Views