https://pulumi.com logo
Title
m

many-knife-65312

03/03/2023, 11:42 PM
i'm trying to use the
.get()
function to check for existing gcp resources, but i'm struggling with the unique provider ID, does anyone have docs or tips for using
.get()
?
d

dry-keyboard-94795

03/04/2023, 1:50 AM
couple of options here: • pulumi-gcp is based on Terraform's google-beta provider, so you can refer to their docs for what
id
probably is • If you have a resource of the same type already, you can look at its state TargetHttpProxy is a good example: - pulumi docs - TF docs
Glad that Terraform finally fixed this. It used to be an absolute pain to work out IDs before. Hopefully Pulumi can find a way to import their docs for the ID attribute
s

stocky-restaurant-98004

03/06/2023, 6:34 PM
The ID is always the same as the ID for
import
. (We need to make this more obvious.)
And this holds true for every provider, not just Google. It's because behind the scenes,
import
and
get
use the same RPC call.
m

many-knife-65312

03/06/2023, 7:13 PM
thanks for the help @dry-keyboard-94795 and @stocky-restaurant-98004 I think I got this figured out, and these docs/notes are helpful
I'm stuck on this again for the
IAMBinding
resource. @stocky-restaurant-98004 when you say it's the same as the ID for
import
which import do you mean?
like this?
terraform import google_storage_bucket.sample sample-project/my-bucket
i figured this out through trial and error 😂
for an iambinding you need the
name
of the resource and the unique provider ID is the
project NAME
and
role
i was trying to use
project NUMBER
because that's what pulumi stores in the resources
s

stocky-restaurant-98004

03/08/2023, 3:46 PM
I believe I'm hitting the same problem if it makes you feel any better: https://github.com/pulumi/pulumi-gcp/issues/1019
The problem is that the Google TF provider puts all 3 IAM resources in a single docs page, which makes conversion to the Pulumi registry tricky. (No other provider I know of does this.)
Here's a page that renders correctly: https://www.pulumi.com/registry/packages/aws/api-docs/ec2/vpc/#import In the import command, you can see:
VPCs can be imported using the vpc id, e.g.,
pulumi import aws:ec2/vpc:Vpc test_vpc vpc-a01106c2
That VPC id is the same value that should be passed to
.get()
if you want to grab it in a Pulumi program rather than import it because behind the scenes, they both make the same API call.
We really need to add to the docs for
get()
something like "see the Import section for details on how to formulate the ID parameter"
I logged an issue here a while ago, but I'll ping the team about it now and see if we can make this a little better: https://github.com/pulumi/pulumi-terraform-bridge/issues/609
m

many-knife-65312

03/10/2023, 6:07 PM
this is awesome, thanks for the follow up @stocky-restaurant-98004
s

stocky-restaurant-98004

03/10/2023, 6:47 PM
@many-knife-65312 Please upvote here since the one I linked ended up being a duplicate: https://github.com/pulumi/pulumi/issues/11737