Skip to content

Commit f469472

Browse files
DEVOPS-271 azure policy exemption automation
1 parent 0fd80c0 commit f469472

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

common_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ def calculate_expiry(expires_after: int, unit: str) -> str:
88
now = datetime.now(pytz.utc) # Get the current time in UTC
99

1010
if unit == 'day':
11-
expiry_date = now + timedelta(days=expires_after)
11+
expiry_date = now + timedelta(days=float(expires_after))
1212
elif unit == 'month':
13-
expiry_date = now + relativedelta(months=expires_after)
13+
expiry_date = now + relativedelta(months=int(expires_after))
1414
elif unit == 'hour':
1515
expiry_date = now + timedelta(hours=float(expires_after))
1616
else:

policy_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def create_exemption_for_policy(subscription_id: str, policy_name:str, expires_a
9595
expires_on = expiry_date,
9696
display_name = policy_exemption_name,
9797
description=policy_exemption_description
98-
9998
)
10099

101100
exemption = client.policy_exemptions.create_or_update(scope=scope,policy_exemption_name=policy_exemption_name, parameters=parameters)
102101
print("Policy exemption created or updated successfully.")
102+
print(f'Policy Exemption will expire at {expiry_date}')
103103

104104
except HttpResponseError as err:
105105
# Handle HTTP response errors

0 commit comments

Comments
 (0)