Hello , I’m trying to create a secret using aws s...
# aws
m
Hello , I’m trying to create a secret using aws secretsmanager , and then retrieve it using the name i created it with , but it’s throwing an error saying that it cannot find the secret i just created ,
Copy code
const awsSecret = new aws.secretsmanager.Secret("blah");
const createdSecret = aws.secretsmanager.getSecret({name:"blah"})
I also noticed that pulumi adds a short UUID to the end on the secret that’s being created (eg: blah-3hg4557) , could that be the reason by any chance ? and the names no longer match ?
m
awsSecret
essentially is the secret you just created; the lookup shouldn’t be necessary. You should be able to reference the secret’s properties (
awsSecret.name
, etc.) as resource “outputs” throughout your program: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/ The extra characters tacked onto the end are the result of “auto-naming”, a feature of Pulumi that’s discussed in more detail here: https://www.pulumi.com/docs/intro/concepts/resources/names/#autonaming
Lookup functions like
getSecret
are useful for fetching resources created by other means — e.g., manually in the AWS console, by some other IaC tool, etc. https://www.pulumi.com/docs/intro/concepts/resources/get/
m
ah , yes , thank you ! I was thinking about this all wrong 🤦 !
l
Note that if you update your secret via other means, then Pulumi won't know about it until you run
pulumi refresh
.
The values that you see in your program are from the Pulumi state, not from AWS.
pulumi refresh
is needed to get Pulumi to fetch values from AWS.
Code updated, running up again.