-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_maintenance_configuration
#6038
Conversation
azurerm_maintenance_configuration
azurerm_maintenance_configuration
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.
Thanks for the new resource @njuCZ,
Aside from a couple minor comments iv'e left inline this is off to a great start!
azurerm/internal/services/maintenance/data_source_maintenance_configuration.go
Show resolved
Hide resolved
azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go
Show resolved
Hide resolved
azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/maintenance/tests/resource_arm_maintenance_configuration_test.go
Show resolved
Hide resolved
azurerm/internal/services/maintenance/tests/resource_arm_maintenance_configuration_test.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/maintenance/tests/resource_arm_maintenance_configuration_test.go
Outdated
Show resolved
Hide resolved
scope = "Host" | ||
|
||
tags = { | ||
env = "test" |
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.
could we ensure uppercase works?
env = "test" | |
EnV = "TesT" |
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.
I have changed the value to TesT
as for the key, this service will return small case key, regardless of the input case.
If we set EnV = "TesT"
, the service will return env = "TesT"
@katbyte Thanks for the suggestion, I have refined the codes accordingly. Please have a look again |
334e017
to
2c917ab
Compare
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.
Hi @njuCZ
Thanks for this PR for the preview resource.
The code looks largely OK, but there are aspects/issues with the API that are going to make this problematic for Terraform, in particular the non-standard behaviour around Tag keys. I think we should investigate getting that behaviour corrected before trying to compensate in the provider, or progressing the PR towards merging.
if _, err := client.CreateOrUpdate(ctx, resGroup, name, configuration); err != nil { | ||
return fmt.Errorf("Error creating/updating MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err) | ||
} | ||
|
||
resp, err := client.Get(ctx, resGroup, name) | ||
if err != nil { | ||
return fmt.Errorf("Error retrieving MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err) | ||
} |
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.
I have concerns around this as the ID in the return from CreateOrUpdate
and Get
are the same values, but the latter is returned entirely in lower case. This feels like a bug in the API and I'm concerned that when (if?) it is fixed, it will break for us here (since the parsing of the ID elements is case sensitive). Are you aware of any issue raised against this?
}, | ||
|
||
// can not contain upper case key | ||
"tags": tags.Schema(), |
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.
I believe this behaviour to be a problem. Whilst Azure does not treat the Keys as case sensitive, normal expected behaviour is to return the casing provided by the user. Terraform also expects the keys to be returned as originally defined. Can we open an issue on this?
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
|
||
* `scope` - (Optional) The scope of the Maintenance Configuration. Possible values are `All`, `Host`, `Resource` or `InResource`. Default to `All`. | ||
|
||
* `tags` - (Optional) A mapping of tags to assign to the resource. |
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.
If the tag key bug cannot be addressed, this needs to be highlighted here. Users specifying Tags that are not all lower will experience problems using this resource.
2c917ab
to
56f4749
Compare
@jackofallops I have added some support for case insensitive resource ID, and added some notes in the doc, do you think it's ok? The service team says it's by design to make the case insensitive |
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.
given the API has an issue could we open a ticket on the SDK & link to it in the code as well as add validation to prevent any tags from being added with upper case chars in the key?
}, | ||
|
||
// can not contain upper case key | ||
"tags": tags.Schema(), |
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
@katbyte I have added custom validation for the tags and opened an issue, Could you please have a look again? |
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.
Aside from one comment LGTM @njuCZ! I'm gonna approve this and merge to get it in but i'd be great if you could open an issue on the SDK for the comment i've left inline (not a big deal to not link in code but that would be ideal). Thanks!
if name, err := id.PopSegment("maintenanceconfigurations"); err != nil { | ||
if name, err = id.PopSegment("maintenanceConfigurations"); err != nil { |
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.
We should open an SKD issue here and link to it
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.
thank you. I have added such bug about returned resource id:
Azure/azure-rest-api-specs#8653
I have noted in the resource_group_name
schema defnition
This has been released in version 2.7.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.7.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
partially address #6037
Once it is merged, I'll go on implementing
azurerm_maintenance_assignment
After tested, I found the
resource_group_name
from the response of read api is always small case, so I useazure.SchemaResourceGroupNameDiffSuppress()
Another point is the key of
tags
from the response of read api is always small case