droplets: Allow specifying the region for the droplet.

This commit is contained in:
Alex Vandiver 2022-04-27 18:33:57 -07:00 committed by Tim Abbott
parent b18b9d25e1
commit 738d21f24b
2 changed files with 10 additions and 2 deletions

View File

@ -139,6 +139,7 @@ so they are notified.
closing the connection and shutting the host down.
1. Go to the Snapshots tab on the image, and "Take a Snapshot".
1. Wait for several minutes for it to complete.
1. "Add to region" the snapshot into `NYC3`, `SFO3`, `BLR1`, and `FRA1`.
1. `curl -u <API_KEY>: https://api.digitalocean.com/v2/snapshots | jq .`
1. Replace `template_id` in `create.py` in this directory with the
appropriate `id`.

View File

@ -33,6 +33,7 @@ parser.add_argument("--tags", nargs="+", default=[])
parser.add_argument("-f", "--recreate", action="store_true")
parser.add_argument("-s", "--subdomain")
parser.add_argument("-p", "--production", action="store_true")
parser.add_argument("-r", "--region", choices=("nyc3", "sfo3", "blr1", "fra1"), default="nyc3")
def get_config() -> configparser.ConfigParser:
@ -175,12 +176,17 @@ service ssh restart
def create_droplet(
my_token: str, template_id: str, name: str, tags: List[str], user_data: str
my_token: str,
template_id: str,
name: str,
tags: List[str],
user_data: str,
region: str = "nyc3",
) -> str:
droplet = digitalocean.Droplet(
token=my_token,
name=name,
region="nyc3",
region=region,
image=template_id,
size_slug="s-1vcpu-2gb",
user_data=user_data,
@ -347,6 +353,7 @@ if __name__ == "__main__":
name=droplet_domain_name,
tags=args.tags + ["dev"],
user_data=user_data,
region=args.region,
)
create_dns_record(my_token=api_token, record_name=subdomain, ip_address=ip_address)