EC2 - fix missing AZ on auto-generated volumes for instances (#4560)
This commit is contained in:
parent
dfe01dad17
commit
756f772c5c
@ -796,7 +796,7 @@ class Instance(TaggedEC2Resource, BotoInstance, CloudFormationModel):
|
|||||||
):
|
):
|
||||||
volume = self.ec2_backend.create_volume(
|
volume = self.ec2_backend.create_volume(
|
||||||
size=size,
|
size=size,
|
||||||
zone_name=self.region_name,
|
zone_name=self._placement.zone,
|
||||||
snapshot_id=snapshot_id,
|
snapshot_id=snapshot_id,
|
||||||
encrypted=encrypted,
|
encrypted=encrypted,
|
||||||
kms_key_id=kms_key_id,
|
kms_key_id=kms_key_id,
|
||||||
@ -808,7 +808,7 @@ class Instance(TaggedEC2Resource, BotoInstance, CloudFormationModel):
|
|||||||
def setup_defaults(self):
|
def setup_defaults(self):
|
||||||
# Default have an instance with root volume should you not wish to
|
# Default have an instance with root volume should you not wish to
|
||||||
# override with attach volume cmd.
|
# override with attach volume cmd.
|
||||||
volume = self.ec2_backend.create_volume(size=8, zone_name="us-east-1a")
|
volume = self.ec2_backend.create_volume(size=8, zone_name=self._placement.zone)
|
||||||
self.ec2_backend.attach_volume(volume.id, self.id, "/dev/sda1", True)
|
self.ec2_backend.attach_volume(volume.id, self.id, "/dev/sda1", True)
|
||||||
|
|
||||||
def teardown_defaults(self):
|
def teardown_defaults(self):
|
||||||
|
@ -561,6 +561,13 @@ def test_volume_attach_and_detach_boto3():
|
|||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
||||||
reservation = client.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
|
reservation = client.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
|
||||||
instance = reservation["Instances"][0]
|
instance = reservation["Instances"][0]
|
||||||
|
|
||||||
|
volumes = client.describe_volumes(
|
||||||
|
Filters=[{"Name": "attachment.instance-id", "Values": [instance["InstanceId"]]}]
|
||||||
|
)["Volumes"]
|
||||||
|
volumes.should.have.length_of(1)
|
||||||
|
volumes[0]["AvailabilityZone"].should.equal("us-east-1a")
|
||||||
|
|
||||||
volume = ec2.create_volume(Size=80, AvailabilityZone="us-east-1a")
|
volume = ec2.create_volume(Size=80, AvailabilityZone="us-east-1a")
|
||||||
|
|
||||||
volume.reload()
|
volume.reload()
|
||||||
|
Loading…
Reference in New Issue
Block a user