Skip to content

Commit

Permalink
Techdebt: Get regions from SSM instead of Boto3
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Jun 2, 2023
1 parent 37cb6ce commit 04accc1
Show file tree
Hide file tree
Showing 237 changed files with 3,421 additions and 271 deletions.
1 change: 1 addition & 0 deletions .github/workflows/data-update_ssm-default-parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
pip install boto3
pip install moto[all]
python scripts/ssm_get_default_params.py
black moto/*/service_info.py
- name: Create PR
uses: peter-evans/create-pull-request@v5
with:
Expand Down
3 changes: 2 additions & 1 deletion moto/acm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from moto import settings
from typing import Any, Dict, List, Iterable, Optional, Tuple, Set

from .service_info import supported_regions
from .exceptions import (
AWSValidationException,
AWSTooManyTagsException,
Expand Down Expand Up @@ -550,4 +551,4 @@ def export_certificate(
return certificate, certificate_chain, private_key


acm_backends = BackendDict(AWSCertificateManagerBackend, "ec2")
acm_backends = BackendDict(AWSCertificateManagerBackend, supported_regions=supported_regions)
33 changes: 33 additions & 0 deletions moto/acm/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-central-2",
"eu-north-1",
"eu-south-1",
"eu-south-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-central-1",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/acmpca/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""ACMPCABackend class with methods for supported APIs."""
import base64
from .exceptions import ResourceNotFoundException
from .service_info import supported_regions
from moto.core import BaseBackend, BackendDict, BaseModel
from moto.core.utils import unix_time
from moto.moto_api._internal import mock_random
Expand Down Expand Up @@ -304,4 +305,4 @@ def untag_certificate_authority(
self.tagger.untag_resource_using_tags(certificate_authority_arn, tags)


acmpca_backends = BackendDict(ACMPCABackend, "acm-pca")
acmpca_backends = BackendDict(ACMPCABackend, supported_regions)
31 changes: 31 additions & 0 deletions moto/acmpca/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ca-central-1",
"eu-central-1",
"eu-central-2",
"eu-north-1",
"eu-south-1",
"eu-south-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-central-1",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/amp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from moto.utilities.tagging_service import TaggingService
from typing import Any, Callable, Dict, List, Optional
from .exceptions import RuleGroupNamespaceNotFound, WorkspaceNotFound
from .service_info import supported_regions
from .utils import PAGINATION_MODEL


Expand Down Expand Up @@ -214,4 +215,4 @@ def update_logging_configuration(
return ws.logging_config["status"] # type: ignore[index]


amp_backends = BackendDict(PrometheusServiceBackend, "amp")
amp_backends = BackendDict(PrometheusServiceBackend, supported_regions)
16 changes: 16 additions & 0 deletions moto/amp/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
supported_regions = [
"ap-northeast-1",
"ap-northeast-2",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"eu-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/apigateway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# OpenAPI Spec Validator < 0.5.0
from openapi_spec_validator.exceptions import OpenAPIValidationError # type: ignore
from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel
from .service_info import supported_regions
from .utils import create_id, to_path
from moto.core.utils import path_url
from .exceptions import (
Expand Down Expand Up @@ -2452,4 +2453,4 @@ def delete_gateway_response(self, rest_api_id: str, response_type: str) -> None:
api.delete_gateway_response(response_type)


apigateway_backends = BackendDict(APIGatewayBackend, "apigateway")
apigateway_backends = BackendDict(APIGatewayBackend, supported_regions)
33 changes: 33 additions & 0 deletions moto/apigateway/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-central-2",
"eu-north-1",
"eu-south-1",
"eu-south-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-central-1",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/apigatewayv2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import hashlib
import string
import yaml
from .service_info import supported_regions
from typing import Any, Dict, List, Optional, Union

from moto.core import BaseBackend, BackendDict, BaseModel
Expand Down Expand Up @@ -1702,4 +1703,4 @@ def delete_api_mapping(self, api_mapping_id: str, domain_name: str) -> None:
del self.api_mappings[api_mapping_id]


apigatewayv2_backends = BackendDict(ApiGatewayV2Backend, "apigatewayv2")
apigatewayv2_backends = BackendDict(ApiGatewayV2Backend, supported_regions)
27 changes: 27 additions & 0 deletions moto/apigatewayv2/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-north-1",
"eu-south-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/applicationautoscaling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from moto.ecs import ecs_backends
from moto.moto_api._internal import mock_random
from .exceptions import AWSValidationException
from .service_info import supported_regions
from collections import OrderedDict
from enum import Enum, unique
from typing import Dict, List, Union, Optional, Tuple
Expand Down Expand Up @@ -530,4 +531,4 @@ def update(
self.end_time = end_time


applicationautoscaling_backends = BackendDict(ApplicationAutoscalingBackend, "ec2")
applicationautoscaling_backends = BackendDict(ApplicationAutoscalingBackend, supported_regions)
28 changes: 28 additions & 0 deletions moto/applicationautoscaling/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-north-1",
"eu-south-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/appsync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from moto.utilities.tagging_service import TaggingService

from .exceptions import GraphqlAPINotFound, GraphQLSchemaException, BadRequestException
from .service_info import supported_regions

# AWS custom scalars and directives
# https://github.com/dotansimha/graphql-code-generator/discussions/4311#discussioncomment-2921796
Expand Down Expand Up @@ -371,4 +372,4 @@ def get_type(self, api_id: str, type_name: str, type_format: str) -> Any:
return self.graphql_apis[api_id].get_type(type_name, type_format)


appsync_backends = BackendDict(AppSyncBackend, "appsync")
appsync_backends = BackendDict(AppSyncBackend, supported_regions)
30 changes: 30 additions & 0 deletions moto/appsync/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-central-2",
"eu-north-1",
"eu-south-1",
"eu-south-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-central-1",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/athena/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from .service_info import supported_regions
from datetime import datetime
from moto.core import BaseBackend, BackendDict, BaseModel
from moto.moto_api._internal import mock_random
Expand Down Expand Up @@ -371,4 +372,4 @@ def get_prepared_statement(
return None


athena_backends = BackendDict(AthenaBackend, "athena")
athena_backends = BackendDict(AthenaBackend, supported_regions)
28 changes: 28 additions & 0 deletions moto/athena/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-north-1",
"eu-south-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]
3 changes: 2 additions & 1 deletion moto/autoscaling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
InvalidInstanceError,
ValidationError,
)
from .service_info import supported_regions

# http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/AS_Concepts.html#Cooldown
DEFAULT_COOLDOWN = 300
Expand Down Expand Up @@ -1547,4 +1548,4 @@ def enable_metrics_collection(self, group_name: str, metrics: List[str]) -> None
group.enable_metrics_collection(metrics)


autoscaling_backends = BackendDict(AutoScalingBackend, "autoscaling")
autoscaling_backends = BackendDict(AutoScalingBackend, supported_regions)
33 changes: 33 additions & 0 deletions moto/autoscaling/service_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
supported_regions = [
"af-south-1",
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-central-2",
"eu-north-1",
"eu-south-1",
"eu-south-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"me-central-1",
"me-south-1",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-gov-east-1",
"us-gov-west-1",
"us-west-1",
"us-west-2",
]

0 comments on commit 04accc1

Please sign in to comment.