Skip to content

Commit

Permalink
DEVOPS-271 azure policy exemption automation
Browse files Browse the repository at this point in the history
  • Loading branch information
githubofkrishnadhas committed Aug 5, 2024
1 parent 0fd80c0 commit f469472
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def calculate_expiry(expires_after: int, unit: str) -> str:
now = datetime.now(pytz.utc) # Get the current time in UTC

if unit == 'day':
expiry_date = now + timedelta(days=expires_after)
expiry_date = now + timedelta(days=float(expires_after))
elif unit == 'month':
expiry_date = now + relativedelta(months=expires_after)
expiry_date = now + relativedelta(months=int(expires_after))
elif unit == 'hour':
expiry_date = now + timedelta(hours=float(expires_after))
else:
Expand Down
2 changes: 1 addition & 1 deletion policy_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def create_exemption_for_policy(subscription_id: str, policy_name:str, expires_a
expires_on = expiry_date,
display_name = policy_exemption_name,
description=policy_exemption_description

)

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

except HttpResponseError as err:
# Handle HTTP response errors
Expand Down

0 comments on commit f469472

Please sign in to comment.