Skip to content

Commit de93c11

Browse files
Merge pull request hashicorp#25 from hashicorp/betterMouseTrap
Updated so Owner, owner, TTL and ttl all work for proper tagging.
2 parents 65513ed + 86efc68 commit de93c11

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

infrastructure-as-code/aws-lambda-ec2-lifecycles/files/getTaggedInstances.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ def check_instance_tags(region):
2525
# logger.info(instance.tags)
2626
taglist = []
2727
for tag in instance.tags:
28-
taglist.append(tag['Key'])
28+
if tag['Key'] == 'TTL' or tag['Key'] == 'ttl':
29+
if isInteger(tag['Value']):
30+
taglist.append(tag['Key'].upper())
31+
elif tag['Key'] == 'Owner' or tag['Key'] == 'owner':
32+
taglist.append(tag['Key'].lower())
33+
else:
34+
taglist.append(tag['Key'])
2935
# logger.info(taglist)
3036
if set(mandatory_tags).issubset(set(taglist)):
3137
nice_list.append(instance.id)
@@ -63,9 +69,9 @@ def get_tagged_instances():
6369
for tag in instance['Tags']:
6470
if tag['Key'] == "Name":
6571
name = tag['Value']
66-
if tag['Key'] == "owner":
72+
if tag['Key'] == "owner" or tag['Key'] == "Owner":
6773
owner = tag['Value']
68-
if tag['Key'] == "TTL":
74+
if tag['Key'] == "TTL" or tag['Key'] == "ttl":
6975
if isInteger(tag['Value']):
7076
ttl = tag['Value']
7177
else:
Binary file not shown.

infrastructure-as-code/aws-lambda-ec2-lifecycles/files/getUntaggedInstances.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ def check_instance_tags(region):
2525
taglist = []
2626
for tag in instance.tags:
2727
# Ensures that TTL is valid
28-
if tag['Key'] == 'TTL':
28+
if tag['Key'] == 'TTL' or tag['Key'] == 'ttl':
2929
if isInteger(tag['Value']):
30-
taglist.append(tag['Key'])
30+
taglist.append(tag['Key'].upper())
31+
elif tag['Key'] == 'Owner' or tag['Key'] == 'owner':
32+
taglist.append(tag['Key'].lower())
3133
else:
3234
taglist.append(tag['Key'])
3335
if set(mandatory_tags).issubset(set(taglist)):
@@ -64,9 +66,9 @@ def get_untagged_instances():
6466
for tag in instance['Tags']:
6567
if tag['Key'] == "Name":
6668
name = tag['Value']
67-
if tag['Key'] == "owner":
69+
if tag['Key'] == "owner" or tag['Key'] == "Owner":
6870
owner = tag['Value']
69-
if tag['Key'] == "TTL":
71+
if tag['Key'] == "TTL" or tag['Key'] == "ttl":
7072
if isInteger(tag['Value']):
7173
ttl = tag['Value']
7274
else:
Binary file not shown.

0 commit comments

Comments
 (0)