EBS - Defer imports until it's necessary (#5265)

This commit is contained in:
Bert Blommers 2022-06-26 15:45:33 +00:00 committed by GitHub
parent e5830181dd
commit 6cf37c4b4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,4 @@
from moto.core import get_account_id, CloudFormationModel
from moto.kms import kms_backends
from moto.packages.boto.ec2.blockdevicemapping import BlockDeviceType
from ..exceptions import (
InvalidAMIAttributeItemValueError,
@ -404,6 +403,8 @@ class EBSBackend:
# https://aws.amazon.com/kms/features/#AWS_Service_Integration
# An AWS managed CMK is created automatically when you first create
# an encrypted resource using an AWS service integrated with KMS.
from moto.kms import kms_backends
kms = kms_backends[self.region_name]
ebs_alias = "alias/aws/ebs"
if not kms.alias_exists(ebs_alias):

View File

@ -6,13 +6,13 @@ from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from moto.apigateway.exceptions import ValidationException
from moto.core import get_account_id, BaseBackend, BaseModel, CloudFormationModel
from moto.core.utils import get_random_hex, unix_time, BackendDict
from moto.utilities.tagging_service import TaggingService
from moto.core.exceptions import JsonRESTError
from .exceptions import ValidationException
from .utils import (
RESERVED_ALIASES,
decrypt,