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

New Resource: azurerm_automanage_configuration_profile #19358

Closed
wants to merge 16 commits into from

Conversation

@liuwuliuyun
Copy link
Contributor Author

GOROOT=C:\Program Files\Go #gosetup
GOPATH=C:\Users\yunliu1\go #gosetup
"C:\Program Files\Go\bin\go.exe" test -c -o C:\Users\yunliu1\AppData\Local\Temp\GoLand___go_test_github_com_hashicorp_terraform_provider_azurerm_internal_services_automanage.test.exe github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage #gosetup
"C:\Program Files\Go\bin\go.exe" tool test2json -t C:\Users\yunliu1\AppData\Local\Temp\GoLand___go_test_github_com_hashicorp_terraform_provider_azurerm_internal_services_automanage.test.exe -test.v -test.paniconexit0 #gosetup
=== RUN TestAccAutoManageConfigurationProfile_basic
=== PAUSE TestAccAutoManageConfigurationProfile_basic
=== CONT TestAccAutoManageConfigurationProfile_basic
--- PASS: TestAccAutoManageConfigurationProfile_basic (133.55s)
=== RUN TestAccAutoManageConfigurationProfile_requiresImport
=== PAUSE TestAccAutoManageConfigurationProfile_requiresImport
=== CONT TestAccAutoManageConfigurationProfile_requiresImport
--- PASS: TestAccAutoManageConfigurationProfile_requiresImport (75.75s)
=== RUN TestAccAutoManageConfigurationProfile_complete
=== PAUSE TestAccAutoManageConfigurationProfile_complete
=== CONT TestAccAutoManageConfigurationProfile_complete
--- PASS: TestAccAutoManageConfigurationProfile_complete (135.67s)
=== RUN TestAccAutoManageConfigurationProfile_update
=== PAUSE TestAccAutoManageConfigurationProfile_update
=== CONT TestAccAutoManageConfigurationProfile_update
--- PASS: TestAccAutoManageConfigurationProfile_update (167.86s)
PASS

Process finished with the exit code 0

@liuwuliuyun
Copy link
Contributor Author

GOROOT=C:\Program Files\Go #gosetup
GOPATH=C:\Users\yunliu1\go #gosetup
"C:\Program Files\Go\bin\go.exe" test -c -o C:\Users\yunliu1\AppData\Local\Temp\GoLand___go_test_github_com_hashicorp_terraform_provider_azurerm_internal_services_automanage.test.exe github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage #gosetup
"C:\Program Files\Go\bin\go.exe" tool test2json -t C:\Users\yunliu1\AppData\Local\Temp\GoLand___go_test_github_com_hashicorp_terraform_provider_azurerm_internal_services_automanage.test.exe -test.v -test.paniconexit0 #gosetup
=== RUN TestAccAutoManageConfigurationProfile_basic
=== PAUSE TestAccAutoManageConfigurationProfile_basic
=== CONT TestAccAutoManageConfigurationProfile_basic
--- PASS: TestAccAutoManageConfigurationProfile_basic (144.44s)
=== RUN TestAccAutoManageConfigurationProfile_requiresImport
=== PAUSE TestAccAutoManageConfigurationProfile_requiresImport
=== CONT TestAccAutoManageConfigurationProfile_requiresImport
--- PASS: TestAccAutoManageConfigurationProfile_requiresImport (83.68s)
=== RUN TestAccAutoManageConfigurationProfile_complete
=== PAUSE TestAccAutoManageConfigurationProfile_complete
=== CONT TestAccAutoManageConfigurationProfile_complete
--- PASS: TestAccAutoManageConfigurationProfile_complete (141.47s)
=== RUN TestAccAutoManageConfigurationProfile_update
=== PAUSE TestAccAutoManageConfigurationProfile_update
=== CONT TestAccAutoManageConfigurationProfile_update
--- PASS: TestAccAutoManageConfigurationProfile_update (174.85s)
PASS

Process finished with the exit code 0

@liuwuliuyun liuwuliuyun changed the title new resource azurerm_automanage_configuration_profile New Resource: azurerm_automanage_configuration_profile Nov 25, 2022
Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks for this PR @liuwuliuyun, this is off to a good start but there are two issues that need to be addressed. I've pointed these out in-line. Once those have been fixed up we can take another look through this.

Comment on lines 121 to 130
configuration_json = jsonencode({
"Antimalware/Enable" : false,
"AzureSecurityCenter/Enable" : true,
"Backup/Enable" : false,
"BootDiagnostics/Enable" : true,
"ChangeTrackingAndInventory/Enable" : true,
"GuestConfiguration/Enable" : true,
"LogAnalytics/Enable" : true,
"UpdateManagement/Enable" : true,
"VMInsights/Enable" : true
Copy link
Member

Choose a reason for hiding this comment

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

These should be exposed as individual properties instead of relying on the user to provide a valid json config.

Copy link
Contributor Author

@liuwuliuyun liuwuliuyun Nov 29, 2022

Choose a reason for hiding this comment

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

I agree that making this as individual properties would make it more user friendly. However, this part of property is not specified in swagger. Which means service team could protentially change this. For example, they could add/delete supported properties in the same API version. If that happens, we will introduce breaking change to customers without knowing.

Copy link
Contributor Author

@liuwuliuyun liuwuliuyun Nov 29, 2022

Choose a reason for hiding this comment

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

I have meet this multiple times and it is painful to resolve this kind of issue. Here is a recent example: Azure/azure-rest-api-specs#21553 . Plus, jsonencode is a terraform supported function and it is more flexible in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

@JeffreyRichter any chance you could comment on the design of this API? We've seen instances of this previously where the API has been defined in this manner which have ultimately had a number of breaking changes to the API contract/payload (e.g. AKS/Kusto) - as such I'm wondering what consistency guarantees are available for the API here, as exposing this as JSON both isn't a good user experience and leaves this pretty brittle.

My understanding was that these "generic settings" API's were not recommended, so I'm kinda surprised to see the API version 2022-05-04 include this approach?

Choose a reason for hiding this comment

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

I agree with Tom that this looks very suspicious. I don't have the full context here, but it also seems surprising to me that an open-ended JSON object would have passed by the ARM review board (I'll contact someone on that team and refer them to this). If the Azure service teams knows what can go here, then it should be in the swagger.

Copy link

Choose a reason for hiding this comment

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

I tracked down the original PR where this was introduced and looks like it did go through an ARM review. I think it was either some lack of understanding on the part of the reviewer or a genuine miss. We have already recognized the need for a blocking linter rule for catching this issue in future and we are actively working on plugging this hole. After this automation is put in place, any PR with a "generic setting" will be blocked until either the change is reverted or an exception is granted explicitly.

@stephybun stephybun self-assigned this Nov 28, 2022
@liuwuliuyun
Copy link
Contributor Author

liuwuliuyun commented Dec 8, 2022

Hi @stephybun and @tombuildsstuff , I just got the complete list supported by the json input from service developers and there are a dozen of them. Do we still need to change each one of them to seperate property so that adding ~20 new properties to this resource? Plus, this does have possibility to change in the future according to the developers.

            "Alerts/AutomanageStatusChanges/Enable": "true", 
            "Antimalware/Enable": "true",
            "Antimalware/EnableRealTimeProtection": "true",
            "Antimalware/RunScheduledScan": "true",
            "Antimalware/ScanType": "Quick",
            "Antimalware/ScanDay": "7",
            "Antimalware/ScanTimeInMinutes": "120",
            "Backup/Enable": "true",
            "Backup/PolicyName": "dailyBackupPolicy",
            "Backup/TimeZone": "UTC",   
            "Backup/InstantRpRetentionRangeInDays": 2,
            "Backup/SchedulePolicy/ScheduleRunFrequency": "Daily",
            "Backup/SchedulePolicy/ScheduleRunTimes": [
                "2017-01-26T00:00:00Z"
            ],
            "Backup/SchedulePolicy/SchedulePolicyType": "SimpleSchedulePolicy",
            "Backup/RetentionPolicy/RetentionPolicyType": "LongTermRetentionPolicy",
            "Backup/RetentionPolicy/DailySchedule/RetentionTimes": [
                "2017-01-26T00:00:00Z"
            ],
            "Backup/RetentionPolicy/DailySchedule/RetentionDuration/Count": "180",
            "Backup/RetentionPolicy/DailySchedule/RetentionDuration/DurationType": "Days",
            "VMInsights/Enable": "true",
            "AzureSecurityCenter/Enable": "true",
            "DefenderForCloud/Enable": "true",
            "UpdateManagement/Enable": "true",
            "ChangeTrackingAndInventory/Enable": "true",
            "GuestConfiguration/Enable": "true",
            "LogAnalytics/Enable": "true",
            "BootDiagnostics/Enable": "true"

@liuwuliuyun liuwuliuyun requested review from tombuildsstuff and stephybun and removed request for stephybun and tombuildsstuff December 8, 2022 01:38
@liuwuliuyun
Copy link
Contributor Author

Close this PR for now till further discussion.

@liuwuliuyun liuwuliuyun closed this Jan 4, 2023
@github-actions
Copy link

github-actions bot commented Feb 4, 2023

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants