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

security_center_subscription_pricing_resource: add extensions support #22643

Conversation

Ihab-Zhaika
Copy link
Contributor

@Ihab-Zhaika Ihab-Zhaika commented Jul 23, 2023

This PR contains changes to the azurerm_security_center_subscription_pricing resource which adds the extension block to the resource schema, to support for Defender for Cloud Pricing Advanced configuration.

Closes: #16217

@Ihab-Zhaika
Copy link
Contributor Author

Need to solve │ * resource azurerm_security_center_subscription_pricing: extensions: Elem must be set for lists

Copy link
Member

@catriona-m catriona-m 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 @Ihab-Zhaika - could we include a test for this new property to ensure that it works as expected? Thanks!

@Ihab-Zhaika Ihab-Zhaika force-pushed the feature/ihabzhaika/add_extension_to_pricing branch from f736035 to 09f43fd Compare July 24, 2023 13:50
@Ihab-Zhaika Ihab-Zhaika force-pushed the feature/ihabzhaika/add_extension_to_pricing branch 5 times, most recently from 3164755 to b586332 Compare July 24, 2023 14:36
@Ihab-Zhaika Ihab-Zhaika force-pushed the feature/ihabzhaika/add_extension_to_pricing branch from b586332 to cfdce75 Compare July 24, 2023 14:39
@Ihab-Zhaika Ihab-Zhaika force-pushed the feature/ihabzhaika/add_extension_to_pricing branch from b393570 to 82d84e7 Compare July 25, 2023 10:21
Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Hi @Ihab-Zhaika, thanks for taking the time to work on this! I left a few comments/suggestions inline but once those are addressed I can take another look at this. Thanks!

Signed-off-by: Ihab Zhaika <ihabzhaika@microsoft.com>
@github-actions github-actions bot added size/L and removed size/M labels Aug 6, 2023
@Ihab-Zhaika
Copy link
Contributor Author

@tombuildsstuff All changes are done, can you please check if it can be approved ?

Signed-off-by: Ihab Zhaika <ihabzhaika@microsoft.com>
@Ihab-Zhaika
Copy link
Contributor Author

@catriona-m can you please run the final checks, we are on rush

Signed-off-by: Ihab Zhaika <ihabzhaika@microsoft.com>
@Ihab-Zhaika
Copy link
Contributor Author

@catriona-m can you please run the final checks, we are on rush

@catriona-m can you please run once again the checks

@Ihab-Zhaika
Copy link
Contributor Author

@catriona-m can you please run the final checks, we are on rush

@catriona-m can you please run once again the checks

@catriona-m Thanks for running the checks, all passed, can it be merged ?

@catriona-m
Copy link
Member

Hi @Ihab-Zhaika thanks for making the additional changes to this. I ran the test locally and found that it is currently failing with this error:

=== RUN   TestAccSecurityCenterSubscriptionPricing_cloudPostureExtension
    testcase.go:120: Step 1/2 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # azurerm_security_center_subscription_pricing.test will be updated in-place
          ~ resource "azurerm_security_center_subscription_pricing" "test" {
                id            = "/subscriptions/xxxx/providers/Microsoft.Security/pricings/CloudPosture"
                # (2 unchanged attributes hidden)
        
              - extension {
                  - additional_extension_properties = {} -> null
                  - name                            = "AgentlessDiscoveryForKubernetes" -> null
                }
              - extension {
                  - additional_extension_properties = {} -> null
                  - name                            = "ContainerRegistriesVulnerabilityAssessments" -> null
                }
        
                # (2 unchanged blocks hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccSecurityCenterSubscriptionPricing_cloudPostureExtension (35.25s)

FAIL

If you are happy for me to push changes to the PR, I can take a look at fixing this tomorrow and adding the additional test steps we need.

Thanks!

@Ihab-Zhaika
Copy link
Contributor Author

Hi @Ihab-Zhaika thanks for making the additional changes to this. I ran the test locally and found that it is currently failing with this error:

=== RUN   TestAccSecurityCenterSubscriptionPricing_cloudPostureExtension
    testcase.go:120: Step 1/2 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # azurerm_security_center_subscription_pricing.test will be updated in-place
          ~ resource "azurerm_security_center_subscription_pricing" "test" {
                id            = "/subscriptions/xxxx/providers/Microsoft.Security/pricings/CloudPosture"
                # (2 unchanged attributes hidden)
        
              - extension {
                  - additional_extension_properties = {} -> null
                  - name                            = "AgentlessDiscoveryForKubernetes" -> null
                }
              - extension {
                  - additional_extension_properties = {} -> null
                  - name                            = "ContainerRegistriesVulnerabilityAssessments" -> null
                }
        
                # (2 unchanged blocks hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccSecurityCenterSubscriptionPricing_cloudPostureExtension (35.25s)

FAIL

If you are happy for me to push changes to the PR, I can take a look at fixing this tomorrow and adding the additional test steps we need.

Thanks!

@catriona-m
Sure, I would be happy to

Copy link
Contributor Author

@Ihab-Zhaika Ihab-Zhaika left a comment

Choose a reason for hiding this comment

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

Seems good

@Ihab-Zhaika
Copy link
Contributor Author

Seems good

@catriona-m Thanks for adding those improvements, when it can be merged ?

@catriona-m
Copy link
Member

Seems good

@catriona-m Thanks for adding those improvements, when it can be merged ?

@Ihab-Zhaika I am waiting on the tests completing, then we can request another review and hopefully this should be good to merge soon 👍

@Ihab-Zhaika
Copy link
Contributor Author

(2 unchanged blocks hidden)

Sure, @catriona-m I see all tests passed

@catriona-m
Copy link
Member

(2 unchanged blocks hidden)

Sure, @catriona-m I see all tests passed

Apologies @Ihab-Zhaika , I meant the acceptance tests. Going to merge this now! Thanks!

@catriona-m catriona-m merged commit 4f01764 into hashicorp:main Aug 9, 2023
24 checks passed
catriona-m added a commit that referenced this pull request Aug 9, 2023
@github-actions github-actions bot added this to the v3.69.0 milestone Aug 9, 2023
@Ihab-Zhaika
Copy link
Contributor Author

@tombuildsstuff @catriona-m

I want to discuss something, Is there a slack or something or just via comments ?

This PR is already completed so not for it but for next PR:

in the extensions, you mentioned that if the "extension" appear then it is enabled and if not exist in the template then it is off, this is "required" behavior or something that I can change in the upcoming PRS ?

Since for example we want that if the customer did not specify any extension that by default turn all of them for him, which conflicts with the approach of specifying the required extensions one by one
Now I understand that IsChanged can help drive this approach, but as we know lot of customers won't be aware about it, so what do you suggest ?
Is it Ok for example to have similar case

tf apply
tf apply

without changing the template and the second apply would do some changes ?

Copy link

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 May 18, 2024
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.

Support for Defender for Cloud Pricing Advanced Configuration
4 participants