Skip to content

Commit

Permalink
Remove Digital Ocean references (#2838)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelovilla authored Nov 19, 2024
2 parents f448892 + 5e15126 commit b442200
Show file tree
Hide file tree
Showing 44 changed files with 37 additions and 825 deletions.
2 changes: 0 additions & 2 deletions src/_nebari/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


# DOCS
DO_ENV_DOCS = "https://www.nebari.dev/docs/how-tos/nebari-do"
AZURE_ENV_DOCS = "https://www.nebari.dev/docs/how-tos/nebari-azure"
AWS_ENV_DOCS = "https://www.nebari.dev/docs/how-tos/nebari-aws"
GCP_ENV_DOCS = "https://www.nebari.dev/docs/how-tos/nebari-gcp"
Expand All @@ -34,4 +33,3 @@
AWS_DEFAULT_REGION = "us-east-1"
AZURE_DEFAULT_REGION = "Central US"
GCP_DEFAULT_REGION = "us-central1"
DO_DEFAULT_REGION = "nyc3"
36 changes: 3 additions & 33 deletions src/_nebari/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@
from _nebari import constants
from _nebari.provider import git
from _nebari.provider.cicd import github
from _nebari.provider.cloud import (
amazon_web_services,
azure_cloud,
digital_ocean,
google_cloud,
)
from _nebari.provider.cloud import amazon_web_services, azure_cloud, google_cloud
from _nebari.provider.oauth.auth0 import create_client
from _nebari.stages.bootstrap import CiEnum
from _nebari.stages.infrastructure import (
DEFAULT_AWS_NODE_GROUPS,
DEFAULT_AZURE_NODE_GROUPS,
DEFAULT_DO_NODE_GROUPS,
DEFAULT_GCP_NODE_GROUPS,
node_groups_to_dict,
)
Expand Down Expand Up @@ -117,22 +111,7 @@ def render_config(
),
}

if cloud_provider == ProviderEnum.do:
do_region = region or constants.DO_DEFAULT_REGION
do_kubernetes_versions = kubernetes_version or get_latest_kubernetes_version(
digital_ocean.kubernetes_versions()
)
config["digital_ocean"] = {
"kubernetes_version": do_kubernetes_versions,
"region": do_region,
"node_groups": node_groups_to_dict(DEFAULT_DO_NODE_GROUPS),
}

config["theme"]["jupyterhub"][
"hub_subtitle"
] = f"{WELCOME_HEADER_TEXT} on Digital Ocean"

elif cloud_provider == ProviderEnum.gcp:
if cloud_provider == ProviderEnum.gcp:
gcp_region = region or constants.GCP_DEFAULT_REGION
gcp_kubernetes_version = kubernetes_version or get_latest_kubernetes_version(
google_cloud.kubernetes_versions(gcp_region)
Expand Down Expand Up @@ -245,16 +224,7 @@ def github_auto_provision(config: pydantic.BaseModel, owner: str, repo: str):

try:
# Secrets
if config.provider == ProviderEnum.do:
for name in {
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"SPACES_ACCESS_KEY_ID",
"SPACES_SECRET_ACCESS_KEY",
"DIGITALOCEAN_TOKEN",
}:
github.update_secret(owner, repo, name, os.environ[name])
elif config.provider == ProviderEnum.aws:
if config.provider == ProviderEnum.aws:
for name in {
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
Expand Down
6 changes: 0 additions & 6 deletions src/_nebari/provider/cicd/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ def gha_env_vars(config: schema.Main):
env_vars["ARM_CLIENT_SECRET"] = "${{ secrets.ARM_CLIENT_SECRET }}"
env_vars["ARM_SUBSCRIPTION_ID"] = "${{ secrets.ARM_SUBSCRIPTION_ID }}"
env_vars["ARM_TENANT_ID"] = "${{ secrets.ARM_TENANT_ID }}"
elif config.provider == schema.ProviderEnum.do:
env_vars["AWS_ACCESS_KEY_ID"] = "${{ secrets.AWS_ACCESS_KEY_ID }}"
env_vars["AWS_SECRET_ACCESS_KEY"] = "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
env_vars["SPACES_ACCESS_KEY_ID"] = "${{ secrets.SPACES_ACCESS_KEY_ID }}"
env_vars["SPACES_SECRET_ACCESS_KEY"] = "${{ secrets.SPACES_SECRET_ACCESS_KEY }}"
env_vars["DIGITALOCEAN_TOKEN"] = "${{ secrets.DIGITALOCEAN_TOKEN }}"
elif config.provider == schema.ProviderEnum.gcp:
env_vars["GOOGLE_CREDENTIALS"] = "${{ secrets.GOOGLE_CREDENTIALS }}"
env_vars["PROJECT_ID"] = "${{ secrets.PROJECT_ID }}"
Expand Down
46 changes: 16 additions & 30 deletions src/_nebari/provider/cloud/amazon_web_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,19 @@ def check_credentials() -> None:

@functools.lru_cache()
def aws_session(
region: Optional[str] = None, digitalocean_region: Optional[str] = None
region: Optional[str] = None,
) -> boto3.Session:
"""Create a boto3 session."""
if digitalocean_region:
aws_access_key_id = os.environ["SPACES_ACCESS_KEY_ID"]
aws_secret_access_key = os.environ["SPACES_SECRET_ACCESS_KEY"]
region = digitalocean_region
aws_session_token = None
else:
check_credentials()
aws_access_key_id = os.environ["AWS_ACCESS_KEY_ID"]
aws_secret_access_key = os.environ["AWS_SECRET_ACCESS_KEY"]
aws_session_token = os.environ.get("AWS_SESSION_TOKEN")

if not region:
raise ValueError(
"Please specify `region` in the nebari-config.yaml or if initializing the nebari-config, set the region via the "
"`--region` flag or via the AWS_DEFAULT_REGION environment variable.\n"
)
check_credentials()
aws_access_key_id = os.environ["AWS_ACCESS_KEY_ID"]
aws_secret_access_key = os.environ["AWS_SECRET_ACCESS_KEY"]
aws_session_token = os.environ.get("AWS_SESSION_TOKEN")

if not region:
raise ValueError(
"Please specify `region` in the nebari-config.yaml or if initializing the nebari-config, set the region via the "
"`--region` flag or via the AWS_DEFAULT_REGION environment variable.\n"
)

return boto3.Session(
region_name=region,
Expand Down Expand Up @@ -712,21 +706,17 @@ def aws_delete_s3_objects(
bucket_name: str,
endpoint: Optional[str] = None,
region: Optional[str] = None,
digitalocean_region: Optional[str] = None,
):
"""
Delete all objects in the S3 bucket.
NOTE: This method is shared with Digital Ocean as their "Spaces" is S3 compatible and uses the same API.
Parameters:
bucket_name (str): S3 bucket name
endpoint (str): S3 endpoint URL (required for Digital Ocean spaces)
endpoint (str): S3 endpoint URL
region (str): AWS region
digitalocean_region (str): Digital Ocean region
"""
session = aws_session(region=region, digitalocean_region=digitalocean_region)
session = aws_session(region=region)
s3 = session.client("s3", endpoint_url=endpoint)

try:
Expand Down Expand Up @@ -779,22 +769,18 @@ def aws_delete_s3_bucket(
bucket_name: str,
endpoint: Optional[str] = None,
region: Optional[str] = None,
digitalocean_region: Optional[str] = None,
):
"""
Delete S3 bucket.
NOTE: This method is shared with Digital Ocean as their "Spaces" is S3 compatible and uses the same API.
Parameters:
bucket_name (str): S3 bucket name
endpoint (str): S3 endpoint URL (required for Digital Ocean spaces)
endpoint (str): S3 endpoint URL
region (str): AWS region
digitalocean_region (str): Digital Ocean region
"""
aws_delete_s3_objects(bucket_name, endpoint, region, digitalocean_region)
aws_delete_s3_objects(bucket_name, endpoint, region)

session = aws_session(region=region, digitalocean_region=digitalocean_region)
session = aws_session(region=region)
s3 = session.client("s3", endpoint_url=endpoint)

try:
Expand Down
131 changes: 0 additions & 131 deletions src/_nebari/provider/cloud/digital_ocean.py

This file was deleted.

Loading

0 comments on commit b442200

Please sign in to comment.