Reputation: 732
I am trying to programatically(Python) create a virtual machine with a static IP address that I have. My code is based on https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/compute/api/create_instance.py
I am specifically looking at line 74 to 79. Is there a way to attach my static IP address like by referencing, say, the name of the static IP address or something? Now I am just literally hardcoding my static IP address into accessConfigs on line 77. I feel like there should be a better/proper way to do it.
Again, I am not trying to create a VM with a default IP and replace it with a static IP. I am trying to create a VM with a static IP address.
Thank you!
Upvotes: 1
Views: 656
Reputation: 75810
You have to pass the IP into the natIP
field. You can:
Upvotes: 3