-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
azurerm_healthcare_dicom_service
resource & data source - support for new properties
#27375
base: main
Are you sure you want to change the base?
azurerm_healthcare_dicom_service
resource & data source - support for new properties
#27375
Conversation
Computed: true, | ||
}, | ||
|
||
"cors_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.
configuration is redundant,
"cors_configuration": { | |
"cors": { |
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, updated.
Computed: true, | ||
}, | ||
|
||
"storage_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.
ditto
"storage_configuration": { | |
"storage": { |
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, updated.
@@ -115,6 +118,86 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { | |||
Default: true, | |||
}, | |||
|
|||
"cors_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.
"cors_configuration": { | |
"cors": { |
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, updated.
}, | ||
"allowed_headers": { |
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.
}, | |
"allowed_headers": { | |
}, | |
"allowed_headers": { |
please add blank lines between properties
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, updated.
}, | ||
"max_age_in_seconds": { | ||
Type: pluginsdk.TypeInt, | ||
Optional: true, |
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.
can you validate this? i presume -3 is not a valid value? is 0? is 99999999999 ?
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.
Trid it out, can support 0 to 99998 inclusive, added the validatefunc
ValidateFunc: validation.IsURLWithHTTPS, | ||
}, | ||
|
||
"storage_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.
"storage_configuration": { | |
"storage": { |
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.
Updated
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 @hqhqhqhqhqhqhqhqhqhqhq. Could you take a look through and fix up the. comments left in-line? Once that's done we can take another look through.
"provision_state": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"event_state": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
}, |
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.
These fields contain transient information that isn't meaningful to users, we don't usually expose these in resources or data sources
"provision_state": { | |
Type: pluginsdk.TypeString, | |
Computed: true, | |
}, | |
"event_state": { | |
Type: pluginsdk.TypeString, | |
Computed: true, | |
}, |
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, this has been removed from the data source and the docs
enableDataPartitions := false | ||
if props.EnableDataPartitions != nil { | ||
enableDataPartitions = pointer.From(props.EnableDataPartitions) | ||
} | ||
d.Set("data_partitions_enabled", enableDataPartitions) |
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.
pointer.From
can do the nil check for us, so this can be reduced to
enableDataPartitions := false | |
if props.EnableDataPartitions != nil { | |
enableDataPartitions = pointer.From(props.EnableDataPartitions) | |
} | |
d.Set("data_partitions_enabled", enableDataPartitions) | |
d.Set("data_partitions_enabled", pointer.From(props.EnableDataPartitions)) |
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, updated in the resource & data source
var enableDataPartitions *bool | ||
if v, ok := d.GetOk("data_partitions_enabled"); ok { | ||
enableDataPartitions = pointer.To(v.(bool)) | ||
} | ||
|
||
var corsConfiguration *dicomservices.CorsConfiguration | ||
if v, ok := d.GetOk("cors"); ok { | ||
corsConfiguration = expandDicomServiceCorsConfiguration(v.([]interface{})) | ||
} | ||
|
||
var encryption *dicomservices.Encryption | ||
if v, ok := d.GetOk("encryption_key_url"); ok { | ||
encryption = &dicomservices.Encryption{ | ||
CustomerManagedKeyEncryption: &dicomservices.EncryptionCustomerManagedKeyEncryption{ | ||
KeyEncryptionKeyUrl: pointer.To(v.(string)), | ||
}, | ||
} | ||
} | ||
|
||
var storageConfiguration *dicomservices.StorageConfiguration | ||
if v, ok := d.GetOk("storage"); ok { | ||
storageConfiguration = expandStorageConfiguration(v.([]interface{})) | ||
} |
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 be using d.HasChanges
here so we can support the use of ignore_changes
, you may need to rewrite this to retrieve the existing resource and patch in changes with d.HasChanges
. The update method in our guide on adding new resources has an explanation on how this should be done:
Here is also a practical example from within the provider:
terraform-provider-azurerm/internal/services/network/public_ip_resource.go
Lines 297 to 368 in 8477e14
func resourcePublicIpUpdate(d *pluginsdk.ResourceData, meta interface{}) error { | |
client := meta.(*clients.Client).Network.PublicIPAddresses | |
ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) | |
defer cancel() | |
log.Printf("[INFO] preparing arguments for AzureRM Public IP update.") | |
id, err := commonids.ParsePublicIPAddressID(d.Id()) | |
if err != nil { | |
return err | |
} | |
existing, err := client.Get(ctx, *id, publicipaddresses.DefaultGetOperationOptions()) | |
if err != nil { | |
return fmt.Errorf("retrieving %s: %+v", id, err) | |
} | |
if existing.Model == nil { | |
return fmt.Errorf("retrieving %s: `model` was nil", id) | |
} | |
if existing.Model.Properties == nil { | |
return fmt.Errorf("retrieving %s: `properties` was nil", id) | |
} | |
payload := existing.Model | |
if d.HasChange("allocation_method") { | |
payload.Properties.PublicIPAllocationMethod = pointer.To(publicipaddresses.IPAllocationMethod(d.Get("allocation_method").(string))) | |
} | |
if d.HasChange("ddos_protection_mode") { | |
if payload.Properties.DdosSettings == nil { | |
payload.Properties.DdosSettings = &publicipaddresses.DdosSettings{} | |
} | |
payload.Properties.DdosSettings.ProtectionMode = pointer.To(publicipaddresses.DdosSettingsProtectionMode(d.Get("ddos_protection_mode").(string))) | |
} | |
if d.HasChange("ddos_protection_plan_id") { | |
if !strings.EqualFold(string(*payload.Properties.DdosSettings.ProtectionMode), "enabled") { | |
return fmt.Errorf("ddos protection plan id can only be set when ddos protection is enabled") | |
} | |
if payload.Properties.DdosSettings == nil { | |
payload.Properties.DdosSettings = &publicipaddresses.DdosSettings{} | |
} | |
payload.Properties.DdosSettings.DdosProtectionPlan = &publicipaddresses.SubResource{ | |
Id: pointer.To(d.Get("ddos_protection_plan_id").(string)), | |
} | |
} | |
if d.HasChange("idle_timeout_in_minutes") { | |
payload.Properties.IdleTimeoutInMinutes = utils.Int64(int64(d.Get("idle_timeout_in_minutes").(int))) | |
} | |
if d.HasChange("domain_name_label") { | |
if payload.Properties.DnsSettings == nil { | |
payload.Properties.DnsSettings = &publicipaddresses.PublicIPAddressDnsSettings{} | |
} | |
payload.Properties.DnsSettings.DomainNameLabel = utils.String(d.Get("domain_name_label").(string)) | |
} | |
if d.HasChange("reverse_fqdn") { | |
if payload.Properties.DnsSettings == nil { | |
payload.Properties.DnsSettings = &publicipaddresses.PublicIPAddressDnsSettings{} | |
} | |
payload.Properties.DnsSettings.ReverseFqdn = utils.String(d.Get("reverse_fqdn").(string)) | |
} | |
if d.HasChanges("tags") { | |
payload.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) | |
} | |
if err = client.CreateOrUpdateThenPoll(ctx, *id, *payload); 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.
Got it, have updated the update function in the resource to this format.
if configuration.FileSystemName != nil { | ||
result["file_system_name"] = *configuration.FileSystemName | ||
} |
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 could use pointer.From
here for the nil check
if configuration.FileSystemName != nil { | |
result["file_system_name"] = *configuration.FileSystemName | |
} | |
result["file_system_name"] = pointer.From(configuration.FileSystemName) |
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, updated, the flatten function (used by the resource & data source)
if configuration.StorageResourceId != nil { | ||
result["storage_account_id"] = *configuration.StorageResourceId | ||
} |
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 parse the Storage account ID that we're getting back from the API so that we can catch any casing inconsistencies and potentially prevent them from creeping into user's state
if configuration.StorageResourceId != nil { | |
result["storage_account_id"] = *configuration.StorageResourceId | |
} | |
if v := pointer.From(configuration.StorageResourceId); v != "" { | |
id, err := commonids.ParseStorageAccountID(v) | |
if err != nil { | |
return nil, err | |
} | |
result["storage_account_id"] = id.ID() | |
} |
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, updated the flatten function (used by the resource & data source), the function now also returns error to the calling function
@@ -51,6 +63,29 @@ An `authentication` supports the following: | |||
|
|||
* `audience` - The intended audience to receive authentication tokens for the service. The default value is <https://dicom.azurehealthcareapis.azure.com> | |||
|
|||
--- | |||
|
|||
A `cors` supports the following: |
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.
For data sources we say a block exports
rather than supports
since these aren't arguments that can be supplied
A `cors` supports the following: | |
A `cors` exports the following: |
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.
Updated
|
||
--- | ||
|
||
A `storage` block supports the following: |
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.
A `storage` block supports the following: | |
A `storage` block exports the following: |
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.
Updated
|
||
* `file_system_name` - The filesystem name of connected storage account. | ||
|
||
* `storage_account_id` - The resource id of connected storage account. |
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.
* `storage_account_id` - The resource id of connected storage account. | |
* `storage_account_id` - The resource ID of connected storage account. |
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.
Updated the doc with required changes & other parts where it is id rather than ID
|
||
* `file_system_name` - (Required) The filesystem name of connected storage account. Changing this forces a new Healthcare DICOM Service to be created. | ||
|
||
* `storage_account_id` - (Required) The resource id of connected storage account. Changing this forces a new Healthcare DICOM Service to be created. |
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.
* `storage_account_id` - (Required) The resource id of connected storage account. Changing this forces a new Healthcare DICOM Service to be created. | |
* `storage_account_id` - (Required) The resource ID of connected storage account. Changing this forces a new Healthcare DICOM Service to be created. |
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.
Updated
|
||
* `storage_account_id` - (Required) The resource id of connected storage account. Changing this forces a new Healthcare DICOM Service to be created. | ||
|
||
~> **Note:** The `is_hns_enabled` needs to be set to `true` for the storage account to be used with the Healthcare DICOM Service. |
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 this is the case then shouldn't this be set in the complete
test config?
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 property is currently set for azurerm_storage_account
resource in the complete test
@stephybun Thanks for all the reviews🙏, I have addressed all of them and reran the tests: Please help give another review when available, thank you! |
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.
Sorry for the delayed re-review @hqhqhqhqhqhqhqhqhqhqhq. This looks mostly fine, I posted a response to one of the comments regarding the default values for the cors
and storage
block, please take a look at the detail in the response.
Community Note
Description
For
azurerm_healthcare_dicom_service
resource, added properties:cors_configuration
encryption_key_url
storage_configuration
data_partitions_enabled
For
azurerm_healthcare_dicom_service
data source, added properties:cors_configuration
encryption_key_url
storage_configuration
data_partitions_enabled
provision_state
event_state
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_healthcare_dicom_service
resource & data source - support for new propertiesThis is a (please select all that apply):
Note
If this PR changes meaningfully during the course of review please update the title and description as required.