https://pulumi.com logo
#getting-started
Title
# getting-started
e

echoing-kite-20563

09/12/2023, 3:04 PM
Hello, I would like to add a reserved public IP to an already created instance in Oracle Cloud, but I don't know how to obtain the OCID of the private IP. Any ideas?
b

billowy-army-68599

09/12/2023, 3:07 PM
e

echoing-kite-20563

09/12/2023, 6:27 PM
I am trying with the following function but it gives me this error.
def get_private_ip (private_ip,subnet_id): try: private_ips_by_ip_address = oci.core.get_private_ips(ip_address=private_ip,subnet_id=subnet_id) except Exception as error: print("Get Private IP OCID " + str(error))
Get Private IP OCID get can only be used with classes decorated with @input_type or @output_type
"What are @input_type or @output_type?" 😅
b

billowy-army-68599

09/12/2023, 6:35 PM
they are Pulumi constructs for a resource that has returned from an API
you can’t really
try/catch
with Pulumi, that’s an imperative operation
what are the values of
private_ip
and
subnet_id
set to?
Copy code
def get_private_ip (private_ip: str ,subnet_id: str):
   return oci.core.get_private_ips(ip_address=private_ip,subnet_id=subnet_id)
This should work
(untested)