How to dynamically update management IP on DigitalOcean
Mar 24, 2022 Cloud, Design, Cloud-dev-machine, Digital-Ocean, pythonSteps:
-
Generate a token for API access: Navigate through
API
->Tokens/Keys
, click the buttonGenerate New Token
Give it a name and write permission.
The key will only show once after confirming the key details, so make a good copy for it
-
Find firewall for management, or create one if there isn’t one Use the API to list all policies and look for a policy named
mgmt
in the response that should be similar to the following: -
If there’s one, update the policy Use update_firewall to update the policy we found, in which the new policy should be closed to this:
-
If there isn’t one, create a new policy with create_policy. Its parameters should be the same as in step 3.
-
Retrive the firewall policy again to confirm the detail.