https://pulumi.com logo
#python
Title
# python
m

modern-animal-54928

05/02/2021, 4:13 AM
Hello everybody. I am fairly new to Pulumi and like many before I have some issues with Output... I understand the need to have something that will be replaced by the real value at runtime but I am facing some issue in my code to.... I have tried many stuffs using apply but I thing I am just using them badly.... Here is a snippet of what I am trying to acheive (in GCP)
Copy code
userProject = organizations.Project("Foo",                                      
                                     billing_account="XXXXXXX",                    
                                     folder_id="YYYYYYY",                          
                                     project_id="Foo",                             
                                     auto_create_network="false")                  
projects.Service(userProject.project_id,                                           
                   disable_dependent_services=True,                                
                   project=userProject.project_id                                  
                   service=i"<http://cloudapis.googleapis.com|cloudapis.googleapis.com>")
As you can see I am trying to get te project_id of the project that I have just created... Can you explain me how acheive that ? My code is a bit more complicated with some concatenations between Outputs and str but I think I am clearly missing the point how to extract the value from Output Thanks
r

red-match-15116

05/02/2021, 4:24 AM
The snippet that you’ve shown here should work as written. What about it doesn’t work?
My code is a bit more complicated with some concatenations between Outputs and str
I imagine this is the part that’s actually going wrong, so we’ll need an actual example of what you’re doing and the error you’re getting.
s

stale-hamburger-8953

05/02/2021, 4:43 AM
wouldn't this fail with sth like "project id not a string, it is an Output object"
r

red-match-15116

05/02/2021, 4:52 AM
wouldn’t this fail with sth like “project id not a string, it is an Output object”
Yeah that’s fair, You can’t use an Output as the
resource_name
for another resource. But you can use it for every other argument in a resource. Specifically:
Copy code
projects.Service(userProject.project_id,           <-- this will not work                                   
                 disable_dependent_services=True,                                
                 project=userProject.project_id,   <-- this works fine                               
                 service="<http://cloudapis.googleapis.com|cloudapis.googleapis.com>")
👍 2
m

modern-animal-54928

05/02/2021, 11:54 AM
So that is exactly the error that I am facing...
Copy code
TypeError: Expected resource name to be a string
I am not sure what can I do here... Do you have some tips to share ?
r

red-match-15116

05/02/2021, 5:15 PM
I would suggest that you give your
Service
a different name. Is that not an option?
m

modern-animal-54928

05/02/2021, 5:39 PM
It is... This is what I was envisaging 🙂
partypus 8bit 1
Thanks at least for pointing that I cannot use it in the name property
👍 1
👍🏽 1
2 Views