Skip to content

Commit 66e2f0d

Browse files
add support for limiting destination regions on copy (#229)
1 parent 048de90 commit 66e2f0d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

upload-ami/src/upload_ami/upload_ami.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def upload_ami(
298298
prefix: str,
299299
run_id: str,
300300
public: bool,
301+
dest_regions: list[str],
301302
) -> dict[str, str]:
302303
"""
303304
Upload NixOS AMI to AWS and return the image ids for each region
@@ -323,7 +324,8 @@ def upload_ami(
323324
)
324325

325326
regions = filter(
326-
lambda x: x.get("RegionName") != ec2.meta.region_name,
327+
lambda x: x.get("RegionName") != ec2.meta.region_name
328+
and (True if dest_regions == [] else x.get("RegionName") in dest_regions),
327329
ec2.describe_regions()["Regions"],
328330
)
329331

@@ -354,6 +356,13 @@ def main() -> None:
354356
"--prefix", required=True, help="Prefix to prepend to image name"
355357
)
356358
parser.add_argument("--run-id", help="Run id to append to image name")
359+
parser.add_argument(
360+
"--dest-region",
361+
help="Regions to copy to if copy-to-regions is enabled",
362+
action="append",
363+
default=[],
364+
)
365+
357366
args = parser.parse_args()
358367

359368
level = logging.DEBUG if args.debug else logging.INFO
@@ -370,6 +379,7 @@ def main() -> None:
370379
args.prefix,
371380
args.run_id,
372381
args.public,
382+
args.dest_region,
373383
)
374384
print(json.dumps(image_ids))
375385

0 commit comments

Comments
 (0)