Skip to content

Commit 1c9fae9

Browse files
Support region
1 parent f1beaf5 commit 1c9fae9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ optional arguments:
2929
-h, --help show this help message and exit
3030
--tags TAGS A comma-separated list of tag names to be considered for
3131
concatenation. If omitted, all tags will be used
32+
--region Append the region name at the end of the concatenation
3233
--private Use private IP addresses (public are used by default)
3334
```
3435

aws-ssh-config.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
]
1919

2020

21-
def generate_id(instance, tags_filter):
21+
def generate_id(instance, tags_filter, region):
2222
id = ''
2323

2424
if tags_filter is not None:
@@ -40,12 +40,16 @@ def generate_id(instance, tags_filter):
4040
if not id:
4141
id = instance.id
4242

43+
if region:
44+
id += '-' + instance.placement
45+
4346
return id
4447

4548

4649
def main():
4750
parser = argparse.ArgumentParser()
4851
parser.add_argument('--tags', help='A comma-separated list of tag names to be considered for concatenation. If omitted, all tags will be used')
52+
parser.add_argument('--region', action='store_true', help='Append the region name at the end of the concatenation')
4953
parser.add_argument('--private', action='store_true', help='Use private IP addresses (public are used by default)')
5054
args = parser.parse_args()
5155

@@ -67,7 +71,7 @@ def main():
6771

6872
instances[instance.launch_time].append(instance)
6973

70-
id = generate_id(instance, args.tags)
74+
id = generate_id(instance, args.tags, args.region)
7175

7276
if id not in counts_total:
7377
counts_total[id] = 0
@@ -98,7 +102,7 @@ def main():
98102
if instance.ip_address:
99103
ip = instance.ip_address
100104

101-
id = generate_id(instance, args.tags)
105+
id = generate_id(instance, args.tags, args.region)
102106

103107
if counts_total[id] != 1:
104108
counts_incremental[id] += 1

0 commit comments

Comments
 (0)