-
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_iothub_shared_access_policy
#3009
Conversation
45c05de
to
3950d5c
Compare
azurerm/resource_arm_iothub.go
Outdated
@@ -114,12 +114,12 @@ func resourceArmIotHub() *schema.Resource { | |||
|
|||
"shared_access_policy": { | |||
Type: schema.TypeList, | |||
Computed: true, | |||
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.
this is going to need to become:
Optional: true, | |
Type: schema.TypeSet, | |
Optional: true, | |
Computed: true, |
This needs to remain computed
since it's possible that users may only want to retrieve these and not set the values; otherwise this'll be a breaking change.
In addition - since these can now be defined in-line this'll need to be a TypeSet
, which is a breaking change - but is required since these could be returned in any order at this point (and may differ from the ordering defined in a users config). Unfortunately this would also be a breaking change; as such I believe defining these in-line may not be the best way to expose these fields.
Instead I believe it would make sense to expose a Virtual Resource (ala the azurerm_virtual_Machine_data_disk_attachment` resource which looks up the VM and adds the Disk, then returns) as an independent resource - rather than defining these in-line. This would also allow these to be retrieved as a Data Source.
Unfortunately this would require the use of a Lock to ensure concurrent changes aren't made; however it should be possible to do so - as it appears there's no independent API available to manage Shared Access Policies within an IoTHub.
What do you think?
hey @maxbog Thanks for this PR :) Taking a quick look through this I believe the Shared Access Policies may be better managed as a separate resource, rather than defined in-line (I've left a comment inline with more information) - WDYT? Thanks! |
hey @tombuildsstuff, However, there is a matter of the default access policies that are created together with the IoTHub. The new resource could "take over" the default policies if a policy with the same name is defined in the .tf file. For example, when we would have a .tf file as below, I would expect the resource "azurerm_iothub" "test" {
resource_group_name = "${azurerm_resource_group.iothub_sap.name}"
location = "${azurerm_resource_group.iothub_sap.location}"
name = "test_iothub"
sku {
capacity = 1
name = "S1"
tier = "Standard"
}
}
resource "azurerm_iothub_shared_access_policy" "iothubowner" {
name = "iothubowner"
registry_read = true
registry_write = true
} Also, I think that the user should have control over whether the default policies should be created, so I was thinking about a new Taking the above example further, if the However, if it were to Another thing is the existing Could you point me in the right direction here? All in all, I think that the existing attribute should be deprecated in favour of a new data source and actually removed in v2.0. What do you think? |
3950d5c
to
1566bd7
Compare
@tombuildsstuff: I created a new |
azurerm_iothub_shared_access_policy
- requiresImport - writeWithoutRead
1566bd7
to
78d5b21
Compare
@tombuildsstuff I'm stumped why the build is failing :( Here is the file that I am using: Do you have any pointers to why the build is failing? |
@maxbog sorry missed these pings, will take a look now |
@tombuildsstuff Sorry for pestering, but did you have any time to review the PR? Is there anything I could do to make the review easier for 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.
Hi @maxbog, sorry for the delay. I've left some comments inline with my main comment being that i'm surprised by the number of dependencies affects by simply including the customDiff.all
function? feels like some of those changes are spurious.
@katbyte Thanks for the review! I addressed all the issues |
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 revisions @maxbog,
Aside from some minor comments my one question is the suppress.CaseDifference
on the iothub_name
, we don't suppress it anywhere else so i question if it is required here?
Overall this is looking great!
BTW this solves #2201 |
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 updates @maxbog, LGTM 👍
This has been released in version 1.25.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 = "~> 1.25.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 👉 [email protected]. Thanks! |
also, add test and docs
(resolves #2201)