Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide deployment of alert policy definitions from Azure Resources section of AMBA website #467

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

judyer28
Copy link
Contributor

@judyer28 judyer28 commented Dec 18, 2024

Overview/Summary

Added a Deploy to Azure button for policy definitions for individual Azure resource type alerts. Also, removed '[[' from the Policy section of each alert so that users can easily copy and paste policy definition snippet to Azure portal.

This PR fixes/adds/changes/removes

  1. Adds new policy generator and "policy-arm" directory under each resource type that contains policy templates used by Deploy to Azure button for resource type alert.
  2. Fixes policy snippet for each resource type alert to remove "[[" so that the policy can be easily copied and pasted into Azure portal.

Breaking Changes

  1. Replace me
  2. Replace me

As part of this Pull Request I have

  • Read the Contribution Guide and ensured this PR is compliant with the guide
  • Checked for duplicate Pull Requests
  • Associated it with relevant GitHub Issues or ADO Work Items (Internal Only)
  • Ensured my code/branch is up-to-date with the latest changes in the main branch
  • Ensured PR tests are passing
  • Updated relevant and associated documentation (e.g. Contribution Guide, Docs etc.)

@judyer28 judyer28 marked this pull request as ready for review December 18, 2024 20:27
Copy link
Contributor

@arjenhuitema arjenhuitema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @judyer28,

I have identified a few areas for your review.

I am questioning the necessity of maintaining the policy-arm folder along with its templates. There seems to be considerable code duplication merely for the deployment of individual policy definitions, which is quite a limited use case. The following points elaborate on this:

  • The deployment does not include the Policy Assignment.
  • There is a limit of 200 Policy or Initiative assignments at any given scope. Deploying and assigning policies individually will quickly meet this limit, which we should avoid recommending.

I strongly advocate for policies to be incorporated into an initiative and assigned per initiative. This responsibility should lie with the pattern owners.

}
},
"variables": {
"pidDeploymentName": "[take(concat('pid-8bb7cf8a-bcf7-4264-abcb-703ace2fc84d-', uniqueString(managementGroup().id, parameters('currentDateTimeUtcNow'))), 64)]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you review, there are template validation errors in all templates:

Template validation failed: The template variable 'pidDeploymentName' is not valid: The template function 'managementGroup' is not valid. Please see https://aka.ms/arm-template-expressions for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to deploy this specific file and it deployed ok for me. Can you tell me how you are trying to deploy it? I just did a Custom Deployment in the portal, loaded the file and deployed without error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjenhuitema I looked at this again and I think it may be an issue with the template validator in VS Code. As far as I can tell 'managementGoup' is a valid template function. See here https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-scope#managementgroup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loaded template file shows no error on line 39 when loaded into portal:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be known issue: microsoft/vscode-azurearmtools#1428

"displayName": "[parameters('displayName')]",
"description": "[parameters('description')]",
"metadata": {
"version": "1.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be tagged as "version": "1.0.0-preview",

Also the metadata should include "preview": true,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Preview" indicates the Policy is still in preview, applicable to built-in policies as well. Generally, the versions end with "-preview." For example: https://www.azadvertizer.net/azpolicyadvertizer/4485d24b-a9d3-4206-b691-1fad83bc5007.html. Although not strictly required, these policies were auto-generated and remain in their initial release phase. They have yet to be thoroughly vetted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjenhuitema I added the version and preview information back into the template

@judyer28
Copy link
Contributor Author

@arjenhuitema thanks for taking the time to review and provide feedback. Regarding:

  • The deployment does not include the Policy Assignment.
  • There is a limit of 200 Policy or Initiative assignments at any given scope. Deploying and assigning policies individually will quickly meet this limit, which we should avoid recommending.

I strongly advocate for policies to be incorporated into an initiative and assigned per initiative. This responsibility should lie with the pattern owners.

This feature is not meant for those users looking to apply a specific pattern such as ALZ. In those cases, users should go to the pattern section and follow the guidance there. This feature is meant for users not following a specific pattern and want to pick and choose specific alerts to deploy from the Azure Resources section of the AMBA website. This is a first step for those users to deploy the policy definitions. They can then include them in their own custom initiatives and assign them as they see fit. Future iterations of this could include automation for the custom initiatives and assignments.

@judyer28
Copy link
Contributor Author

judyer28 commented Jan 7, 2025

@arjenhuitema I believe I have addressed all comments. Please let me know if there is anything else needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants