Skip to content

Commit acb8aa8

Browse files
authored
Filter out cost-center from IAM user tags (#984)
* Fix build issue during quay uploads * Filter cost-center from IAM user tags
1 parent 89695e0 commit acb8aa8

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

POLICIES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Environment Variables required:
6868

6969
| KeyName | Value | Description |
7070
|----------------------------|--------|----------------------------------------------------------------------------|
71-
| IBM_CUSTOM_TAGS_LIST | string | pass string with separated with comma. i.e: "cost-center: test, env: test" |
71+
| IBM_CUSTOM_TAGS_LIST | string | pass string with separated with comma. i.e: "env: test, team: dev" |
7272
| RESOURCE_TO_TAG (optional) | string | pass the resource names to tag. ex: "virtual_servers,resource_instances" |
7373
| IBM_CLOUD_API_KEY | string | IBM Cloud API Key |
7474
| IBM_API_KEY | string | IBM Classic infrastructure key ( SoftLayer ) |
@@ -82,7 +82,7 @@ Environment Variables required:
8282
-e policy="tag_resources" \
8383
-e account="${ACCOUNT_NAME}" \
8484
-e IBM_CLOUD_API_KEY="${IBM_CLOUD_API_KEY}" \
85-
-e IBM_CUSTOM_TAGS_LIST="cost-center:675, env:test" \
85+
-e IBM_CUSTOM_TAGS_LIST="env:test, team:dev" \
8686
-e IBM_ACCOUNT_ID="${IBM_ACCOUNT_ID}" \
8787
-e IBM_API_USERNAME="${IBM_API_USERNAME}" \
8888
-e IBM_API_KEY="${IBM_API_KEY}" \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ podman pull quay.io/cloud-governance/cloud-governance
116116
| IBM_API_USERNAME | | IBM Account Username |
117117
| IBM_API_KEY | | IBM Account Classic Infrastructure key |
118118
| IBM_CLOUD_API_KEY | | IBM Cloud API Key |
119-
| IBM_CUSTOM_TAGS_LIST | | pass string with separated with comma. i.e: "cost-center: test, env: test" |
119+
| IBM_CUSTOM_TAGS_LIST | | pass string with separated with comma. i.e: "env: test, team: dev" |
120120

121121
### AWS Configuration
122122

cloud_governance/common/clouds/aws/iam/iam_operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class IAMOperations:
1212

1313
ACCESS_KEY_LABEL_MAP = {"access key 1": 0, "access key 2": 1}
14+
EXCLUDED_PROPAGATION_TAGS = {'cost-center'}
1415

1516
def __init__(self, iam_client=None):
1617
self.iam_client = iam_client if iam_client else get_boto3_client('iam')
@@ -30,7 +31,8 @@ def get_user_tags(self, username: str):
3031
try:
3132
user = self.iam_client.get_user(UserName=username)['User']
3233
if user.get('Tags'):
33-
return user.get('Tags')
34+
return [tag for tag in user.get('Tags')
35+
if tag.get('Key', '').lower() not in self.EXCLUDED_PROPAGATION_TAGS]
3436
else:
3537
return []
3638
except:

0 commit comments

Comments
 (0)