Skip to content

Commit d84bc0f

Browse files
gursewak1997dustymabe
authored andcommitted
Add aws-credentials to list-regions and copy-image
Add ability to add aws-credentials file to list-regions and copy-image commands for aws-replicate.
1 parent 596af28 commit d84bc0f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/cosalib/aws.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@ def aws_run_ore_replicate(build, args):
4444
if not args.source_region:
4545
args.source_region = buildmeta['amis'][0]['name']
4646

47+
ore_args = ['ore', 'aws', '--region', args.source_region]
48+
if args.log_level:
49+
ore_args.extend(['--log-level', args.log_level])
50+
if args.credentials_file:
51+
ore_args.extend(['--credentials-file', args.credentials_file])
52+
4753
# If no region specified then autodetect the regions to replicate to.
4854
# Specify --region=args.source_region here so ore knows to talk to
4955
# a region that exists (i.e. it will talk to govcloud if copying
5056
# from a govcloud region).
5157
if not args.region:
52-
args.region = subprocess.check_output([
53-
'ore', 'aws', '--region', args.source_region, 'list-regions'
54-
]).decode().strip().split()
58+
args.region = subprocess.check_output(
59+
ore_args + ['list-regions']).decode().strip().split()
5560

5661
# only replicate to regions that don't already exist
5762
existing_regions = [item['name'] for item in buildmeta['amis']]
@@ -75,13 +80,7 @@ def aws_run_ore_replicate(build, args):
7580
raise Exception(("Unable to find AMI ID for "
7681
f"{args.source_region} region"))
7782

78-
ore_args = ['ore']
79-
if args.log_level:
80-
ore_args.extend(['--log-level', args.log_level])
81-
ore_args.extend([
82-
'aws', 'copy-image', '--image',
83-
source_image, '--region', args.source_region
84-
])
83+
ore_args.extend(['copy-image', '--image', source_image])
8584
ore_args.extend(region_list)
8685
print("+ {}".format(subprocess.list2cmdline(ore_args)))
8786

0 commit comments

Comments
 (0)