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_iot_security_solution" #10034

Merged
merged 9 commits into from
Jan 28, 2021

Conversation

njuCZ
Copy link
Contributor

@njuCZ njuCZ commented Jan 4, 2021

intro:

  1. doc https://docs.microsoft.com/en-us/azure/defender-for-iot/
  2. iot security solution is a unified security solution for identifying IoT/OT assets, vulnerabilities, and threats

for the recommendation schema,

  • if create a iot security solution with no recommendation specified, all recommendation config are auto enabled.
  • If we only pass few options in recommendation and make it enabled or disabled, all other config are auto enabled.

to handle such matter and avoid diff, I have made each recommendation config as a sub schema, please review and check whether it's ok

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

@njuCZ - all the tests are failing with:

Error: listing keys for IoTHub "acctestIoTHub-210113185506263492" (Resource Group "acctestRG-security-210113185506263492"): devices.IotHubResourceClient#ListKeys: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>

@njuCZ
Copy link
Contributor Author

njuCZ commented Jan 14, 2021

@katbyte I have rerun the acctest in my local and all could succeed. Had a look at your error message, it seems the error occurs when reading iothub resource. So May I ask could you run iothub acctest successfully?

@katbyte
Copy link
Collaborator

katbyte commented Jan 19, 2021

@njuCZ - all the tests are still failing with that error.

@njuCZ
Copy link
Contributor Author

njuCZ commented Jan 20, 2021

@katbyte I reproduce such problem when using a different location. After investigating, I found deleting a iot security solution will cause the iotHub state changed to Transitioning, any further operation such as listKeys or Delete will throw 409 conflict. So I have added wait for state func. Now the acctest for iothub and iotSecuritySolution in teamcity could pass. Could you have a review again?

@njuCZ njuCZ requested a review from katbyte January 20, 2021 06:29
@katbyte katbyte added this to the v2.44.0 milestone Jan 21, 2021
@tombuildsstuff tombuildsstuff modified the milestones: v2.44.0, v2.45.0 Jan 21, 2021
Copy link
Collaborator

@katbyte katbyte 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 the pr @njuCZ - i have some comments and questions about the schema, once addressed i'll continue reviewing the PR

website/docs/r/iot_security_solution.html.markdown Outdated Show resolved Hide resolved
website/docs/r/iot_security_solution.html.markdown Outdated Show resolved Hide resolved
Comment on lines 107 to 111
A `user_defined_resource` block supports the following:

* `query` - (Required) Azure Resource Graph query which represents the security solution's user defined resources.

* `subscription_ids` - (Required) A list of subscription Ids on which the user defined resources query should be executed..
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should improve the ux here, i'm not sure what this is doing exactly? a list of iot hubs to apply this to via a graph query?

Copy link
Contributor Author

@njuCZ njuCZ Jan 22, 2021

Choose a reason for hiding this comment

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

here is the doc about user_defined_resource: https://docs.microsoft.com/en-us/azure/defender-for-iot/quickstart-configure-your-solution. Through this field, user could monitor the entire IoT solution in one dashboard, surfacing all of your IoT devices, IoT platforms and back-end resources in Azure. so it is not for auto find iothub, but for other related resources.

In the portal, the ux is:
tempsnip

user choose the sub or resourceGroup, the portal will convert into graph query and send to the backend. Should we do like the portal and dynamically build the graph query?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it would be best to rename these to query_for_resources & query_subscription_ids?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@njuCZ njuCZ requested a review from katbyte January 22, 2021 05:04
@njuCZ
Copy link
Contributor Author

njuCZ commented Jan 25, 2021

@katbyte I have renamed the fields, could you have a look again?

Comment on lines 211 to 233
"user_defined_resource": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"query_for_resources": {
Type: schema.TypeString,
Required: true,
},

"query_subscription_ids": {
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.IsUUID,
},
},
},
},
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can move these up one level? not sure if user_defined_resource really adds any useful information/ux?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @njuCZ - some doc fixes and this is good to merge


A `recommendations_enabled` block supports the following:

* `events_to_exportacr_authentication` - (Optional) Could Service Principal Authentication be used with ACR repository? Defaults to `true`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to fix thes properties:

Suggested change
* `events_to_exportacr_authentication` - (Optional) Could Service Principal Authentication be used with ACR repository? Defaults to `true`.
* `acr_authentication` - (Optional) Is Principal Authentication enabled for the ACR repository? Defaults to `true`.

and so forth

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, sorry for all the typo

website/docs/r/iot_security_solution.html.markdown Outdated Show resolved Hide resolved
website/docs/r/iot_security_solution.html.markdown Outdated Show resolved Hide resolved
@njuCZ
Copy link
Contributor Author

njuCZ commented Jan 28, 2021

@katbyte thanks for your careful review, I have updated the doc

@katbyte katbyte merged commit c0349b7 into hashicorp:master Jan 28, 2021
katbyte added a commit that referenced this pull request Jan 28, 2021
Type: schema.TypeString,
Optional: true,
ValidateFunc: loganalyticsValidate.LogAnalyticsWorkspaceID,
DiffSuppressFunc: suppress.CaseDifference,
Copy link
Contributor

Choose a reason for hiding this comment

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

@njuCZ is there a Swagger bug tracking this API bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

have created an issue to track: Azure/azure-rest-api-specs#12721

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks @njuCZ :)

Type: schema.TypeString,
ValidateFunc: iothubValidate.IotHubID,
},
Set: set.HashStringIgnoreCase,
Copy link
Contributor

Choose a reason for hiding this comment

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

@njuCZ is there a Swagger bug tracking this API bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

above, I used the same issue to track both

@ghost
Copy link

ghost commented Jan 28, 2021

This has been released in version 2.45.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.45.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Feb 27, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Feb 27, 2021
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.

3 participants