Skip to content

Commit 70c014b

Browse files
committed
Make region selection work
1 parent 11954d9 commit 70c014b

File tree

1 file changed

+7
-3
lines changed
  • pacu/modules/ebs__download_snapshots

1 file changed

+7
-3
lines changed

pacu/modules/ebs__download_snapshots/main.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@
3434
parser.add_argument(
3535
'--region',
3636
required=False,
37-
help='InstanceId of instance to target'
37+
help='Region to target'
3838
)
3939

4040

41-
def snapshot_prompt(snapshots: List[dict]) -> dict:
41+
def snapshot_prompt(snapshots: List[dict], region) -> dict:
4242
"""Prompt's the user for an item to select from the items passed. Item is expected to support the Item protocol."""
43+
if region:
44+
snapshots = [ss for ss in snapshots if ss['Region'] == region]
45+
if not snapshots:
46+
raise UserWarning("No snapshots found.")
4347
for i, snap in enumerate(snapshots):
4448
print(f"{i}) Id: {snap['SnapshotId']}, VolumeId: {snap['VolumeId']}, OwnerId {snap['OwnerId']}, Size: {snap['VolumeSize']}, {snap['Description']})")
4549
answer = int(input('Select Snapshot: '))
@@ -71,7 +75,7 @@ def main(args, pacu: Main):
7175
return False
7276

7377
try:
74-
s = snapshot_prompt(session.EC2['Snapshots'])
78+
s = snapshot_prompt(session.EC2['Snapshots'], region)
7579
snapshot_id = s['SnapshotId']
7680
region = s['Region']
7781
except UserWarning as e:

0 commit comments

Comments
 (0)