Update tags that are required by policy using automation

Rory Pollock 0 Reputation points
2023-07-28T04:12:50.1133333+00:00

My company enforces a policy that requires "UseBy" and "Owner" tags on all test resources,
The policy only enforces the existence of the tags not the content,
Sometimes we need to extend the life of a test resource or change the Owner, and we would like to be able to do this via automation.
However whenever either tag is set anywhere except in the gui it is reverted by policy to the original value,

Is this intended behavior or am I missing something?

Community Center | Not monitored
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2023-07-28T14:22:27.2466667+00:00

    Hello there,

    Updating tags that are required by policy using automation can be achieved through scripting or programming. The specific steps and methods will depend on the cloud platform or environment you are using and the programming language you prefer. Here is a general outline of the process:

    Identify Resources: First, identify the cloud resources for which you want to update or enforce tags. These resources might include virtual machines, storage accounts, databases, etc.

    Define Tag Policy: Determine the specific tag policy that needs to be enforced or updated. This may involve specifying the required tags, tag names, tag values, and any tag restrictions.

    Choose Automation Tool: Select an automation tool or scripting language that is suitable for your cloud platform. Some common choices include PowerShell for Azure, Python for AWS, and gcloud CLI for Google Cloud Platform.

    Authenticate: Ensure that your automation script can authenticate and access the cloud environment with sufficient permissions to update tags. This may involve using service accounts, access keys, or other authentication mechanisms.

    Script the Tag Updates: Write a script that queries the resources that need to be updated, checks their current tag values, and updates them if necessary to comply with the tag policy. The script should include error handling and logging to ensure a smooth operation.

    Schedule Automation: Decide whether this script should run as a one-time operation or as a scheduled task to enforce the tag policy continuously. For scheduled automation, you can use cron jobs, Azure Automation, AWS Lambda, or other cloud-specific scheduling services.

    Testing and Validation: Before deploying the automation in a production environment, thoroughly test the script in a controlled or staging environment to verify that it behaves as expected and does not cause any unintended side effects.

    Monitoring and Alerts: Implement monitoring and alerting mechanisms to be notified of any issues that may occur during the automated tag updates. This will help you proactively address any potential problems.

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.