-
Notifications
You must be signed in to change notification settings - Fork 4
Add optional preserveResources flag to skip cleanup of resources and custom role definition #110
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
…tom role definition Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
cmd/armCmd.go
Outdated
@@ -146,7 +146,7 @@ func getMPFARM(cmd *cobra.Command, args []string) { | |||
initialPermissionsToAdd = []string{"Microsoft.Resources/deployments/*", "Microsoft.Resources/subscriptions/operationresults/read"} | |||
permissionsToAddToResult = []string{"Microsoft.Resources/deployments/read", "Microsoft.Resources/deployments/write"} | |||
|
|||
mpfService = usecase.NewMPFService(ctx, rgManager, spRoleAssignmentManager, deploymentAuthorizationCheckerCleaner, mpfConfig, initialPermissionsToAdd, permissionsToAddToResult, true, false, true) | |||
mpfService = usecase.NewMPFService(ctx, rgManager, spRoleAssignmentManager, deploymentAuthorizationCheckerCleaner, mpfConfig, initialPermissionsToAdd, permissionsToAddToResult, true, false, true, flgPreserveResources) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag is only needed for terraform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. I've removed the preserveResources
flag from the ARM command. It now uses false
instead of flgPreserveResources
since ARM deployments don't perform expensive infrastructure destruction like terraform destroy
. The flag remains available in the CLI for consistency but has no effect for ARM commands. Fixed in commit a38b73c.
cmd/bicepCmd.go
Outdated
@@ -173,7 +173,7 @@ func getMPFBicep(cmd *cobra.Command, args []string) { | |||
|
|||
// Always auto-create resource group since only resource group scoped deployments are supported | |||
var autoCreateResourceGroup bool = true | |||
mpfService = usecase.NewMPFService(ctx, rgManager, spRoleAssignmentManager, deploymentAuthorizationCheckerCleaner, mpfConfig, initialPermissionsToAdd, permissionsToAddToResult, true, false, autoCreateResourceGroup) | |||
mpfService = usecase.NewMPFService(ctx, rgManager, spRoleAssignmentManager, deploymentAuthorizationCheckerCleaner, mpfConfig, initialPermissionsToAdd, permissionsToAddToResult, true, false, autoCreateResourceGroup, flgPreserveResources) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag is only needed for terraform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I've removed the preserveResources
flag from the Bicep command as well. It now uses false
instead of flgPreserveResources
since Bicep deployments, like ARM, don't have the same infrastructure destruction semantics as Terraform. The flag has no effect for Bicep commands. Fixed in commit a38b73c.
…y needed for Terraform Co-authored-by: maniSbindra <6338721+maniSbindra@users.noreply.github.com>
This PR adds a new global
--preserveResources
flag that allows users to preserve resources created during MPF execution, including the custom role definition, instead of automatically cleaning them up.Problem
Previously, MPF would always clean up all resources at the end of execution:
terraform destroy
This made it difficult for users to:
Solution
Added a new global flag
--preserveResources
(environment variable:MPF_PRESERVERESOURCES
) that:Usage Examples
Implementation Details
PreserveResources
field todomain.MPFConfig
to pass flag through the systemMPFService.CleanUpResources()
to conditionally skip cleanup operationsTesting
Fixes #84.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.