Skip to content

Commit ab3cae5

Browse files
committed
cmd-aws-replicate: dynamically fetch list of AWS regions
1 parent 2540f7b commit ab3cae5

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/cmd-aws-replicate

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,13 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
1919
from cosalib.builds import Builds
2020
from cosalib.cmdlib import write_json
2121

22-
# default region list
23-
default_all_regions = [
24-
"us-east-1", "us-east-2", "us-west-1", "us-west-2", "eu-west-1",
25-
"eu-west-2", "eu-west-3", "eu-central-1", "eu-north-1",
26-
"ap-south-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1",
27-
"ap-northeast-2", "sa-east-1", "ca-central-1"]
28-
2922
# Parse args and dispatch
3023
parser = argparse.ArgumentParser()
3124
parser.add_argument("--build", help="Build ID",
3225
required=True)
3326
parser.add_argument("--name-suffix", help="Suffix for name")
34-
parser.add_argument("--regions", help="EC2 regions",
35-
default=default_all_regions, nargs='+')
27+
parser.add_argument("--regions", help="EC2 regions, default: all regions",
28+
default=[], nargs='+')
3629
parser.add_argument("--log-level", help="ore log level")
3730
args = parser.parse_args()
3831

@@ -52,6 +45,8 @@ else:
5245
def run_ore():
5346
if len(buildmeta['amis']) < 1:
5447
raise SystemExit("buildmeta doesn't contain source AMIs. Run buildextend-aws first")
48+
if not args.regions:
49+
args.regions = subprocess.check_output(['ore', 'aws', 'list-regions']).decode().strip().split()
5550
# only replicate to regions that don't already exist
5651
existing_regions = [item['name'] for item in buildmeta['amis']]
5752
duplicates = list(set(args.regions).intersection(existing_regions))

0 commit comments

Comments
 (0)