diff --git a/moto/ec2/models/elastic_block_store.py b/moto/ec2/models/elastic_block_store.py index 020330d1b..b057fefaa 100644 --- a/moto/ec2/models/elastic_block_store.py +++ b/moto/ec2/models/elastic_block_store.py @@ -23,6 +23,7 @@ from ..utils import ( IOPS_REQUIRED_VOLUME_TYPES = ["io1", "io2"] IOPS_SUPPORTED_VOLUME_TYPES = ["gp3", "io1", "io2"] +THROUGHPUT_SUPPORTED_VOLUME_TYPES = ["gp3"] GP3_DEFAULT_IOPS = 3000 @@ -114,6 +115,7 @@ class Volume(TaggedEC2Resource, CloudFormationModel): kms_key_id: Optional[str] = None, volume_type: Optional[str] = None, iops: Optional[int] = None, + throughput: Optional[int] = None, ): self.id = volume_id self.volume_type = volume_type or "gp2" @@ -127,6 +129,7 @@ class Volume(TaggedEC2Resource, CloudFormationModel): self.kms_key_id = kms_key_id self.modifications: List[VolumeModification] = [] self.iops = iops + self.throughput = throughput def modify( self, @@ -272,6 +275,7 @@ class EBSBackend: kms_key_id: Optional[str] = None, volume_type: Optional[str] = None, iops: Optional[int] = None, + throughput: Optional[int] = None, ) -> Volume: if kms_key_id and not encrypted: raise InvalidParameterDependency("KmsKeyId", "Encrypted") @@ -283,6 +287,8 @@ class EBSBackend: iops = GP3_DEFAULT_IOPS elif volume_type not in IOPS_SUPPORTED_VOLUME_TYPES and iops: raise InvalidParameterDependency("VolumeType", "Iops") + if volume_type not in THROUGHPUT_SUPPORTED_VOLUME_TYPES and throughput: + raise InvalidParameterDependency("VolumeType", "Throughput") volume_id = random_volume_id() zone = self.get_zone_by_name(zone_name) # type: ignore[attr-defined] @@ -302,6 +308,7 @@ class EBSBackend: kms_key_id=kms_key_id, volume_type=volume_type, iops=iops, + throughput=throughput, ) self.volumes[volume_id] = volume return volume diff --git a/moto/ec2/responses/elastic_block_store.py b/moto/ec2/responses/elastic_block_store.py index a2b2e3feb..6eb57e488 100644 --- a/moto/ec2/responses/elastic_block_store.py +++ b/moto/ec2/responses/elastic_block_store.py @@ -67,6 +67,7 @@ class ElasticBlockStore(EC2BaseResponse): encrypted = self._get_bool_param("Encrypted", if_none=False) kms_key_id = self._get_param("KmsKeyId") iops = self._get_param("Iops") + throughput = self._get_param("Throughput") self.error_on_dryrun() @@ -78,6 +79,7 @@ class ElasticBlockStore(EC2BaseResponse): kms_key_id=kms_key_id, volume_type=volume_type, iops=iops, + throughput=throughput, ) volume.add_tags(volume_tags) template = self.response_template(CREATE_VOLUME_RESPONSE) @@ -246,6 +248,9 @@ CREATE_VOLUME_RESPONSE = """ @@ -295,6 +300,9 @@ DESCRIBE_VOLUMES_RESPONSE = """