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_dynatrace_tag_rules #27985

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

jiaweitao001
Copy link
Contributor

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_resource - support for the thing1 property [GH-00000]

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #0000

Note

This PR is related to #27432, the same as the previous one, it cannot be tested on TeamCity. Here is the test result from my end with service team's subscription:

=== RUN   TestAccDynatraceTagRules_basic
=== PAUSE TestAccDynatraceTagRules_basic
=== RUN   TestAccDynatraceTagRules_requiresImport
=== PAUSE TestAccDynatraceTagRules_requiresImport
=== CONT  TestAccDynatraceTagRules_basic
=== CONT  TestAccDynatraceTagRules_requiresImport
--- PASS: TestAccDynatraceTagRules_requiresImport (287.09s)
--- PASS: TestAccDynatraceTagRules_basic (288.82s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/dynatrace     288.856s

@divyansh3131
Copy link

@katbyte Do we have any ETA by when can we expect this PR to be reviewed? It's already couple of weeks.

This PR is a follow-up for a dependent child RT related to the previously released monitors resource. It is crucial for our functionality, and without it, our service will have a broken experience. Could you please help prioritize it

@catriona-m catriona-m self-assigned this Nov 26, 2024
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 @jiaweitao001 I've had a look through this and left some comments inline, I can take another look once those are addressed. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

should this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Will do.

MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*schema.Schema{
"send_aad_logs": {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"send_aad_logs": {
"send_azure_active_directory_logs": {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change.

Comment on lines 67 to 71
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"Enabled",
"Disabled",
Copy link
Member

Choose a reason for hiding this comment

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

should we consider making this a bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change.

}, false),
},

"send_activity_logs": {
Copy link
Member

Choose a reason for hiding this comment

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

should we consider making this a bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change.

}, false),
},

"send_subscription_logs": {
Copy link
Member

Choose a reason for hiding this comment

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

should we consider making this a bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Comment on lines 111 to 113
if input.SendAadLogs != nil {
sendAadLogs = string(*input.SendAadLogs)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if input.SendAadLogs != nil {
sendAadLogs = string(*input.SendAadLogs)
}
sendAadLogs = pointer.From(input.SendAadLogs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

Comment on lines 115 to 117
if input.SendSubscriptionLogs != nil {
sendSubscriptionLogs = string(*input.SendSubscriptionLogs)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if input.SendSubscriptionLogs != nil {
sendSubscriptionLogs = string(*input.SendSubscriptionLogs)
}
sendSubscriptionLogs = pointer.From(input.SendSubscriptionLogs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same.

Comment on lines 134 to 158
var name string
var value string
var action string
tags := *input
v := tags[0]

if v.Name != nil {
name = *v.Name
}

if v.Value != nil {
value = *v.Value
}

if v.Action != nil {
action = string(*v.Action)
}

return []FilteringTag{
{
Name: name,
Value: value,
Action: action,
},
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var name string
var value string
var action string
tags := *input
v := tags[0]
if v.Name != nil {
name = *v.Name
}
if v.Value != nil {
value = *v.Value
}
if v.Action != nil {
action = string(*v.Action)
}
return []FilteringTag{
{
Name: name,
Value: value,
Action: action,
},
}
tags := pointer.From(input)[0]
return []FilteringTag{
{
Name: pointer.From(tags.Name),
Value: pointer.From(tags.Value),
Action: string(pointer.From(tags.Action)),
},
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

return []MetricRule{}
}

var filteringTags []FilteringTag
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var filteringTags []FilteringTag
filteringTags := make([]FilteringTag, 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change.

Comment on lines 124 to 127
* `create` - (Defaults to 1 hour) Used when creating the Dynatrace tag rules.
* `read` - (Defaults to 5 minutes) Used when retrieving the Dynatrace tag rules.
* `update` - (Defaults to 1 hour) Used when updating the Dynatrace tag rules.
* `delete` - (Defaults to 1 hour) Used when deleting the Dynatrace tag rules.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* `create` - (Defaults to 1 hour) Used when creating the Dynatrace tag rules.
* `read` - (Defaults to 5 minutes) Used when retrieving the Dynatrace tag rules.
* `update` - (Defaults to 1 hour) Used when updating the Dynatrace tag rules.
* `delete` - (Defaults to 1 hour) Used when deleting the Dynatrace tag rules.
* `create` - (Defaults to 30 minutes) Used when creating the Dynatrace tag rules.
* `read` - (Defaults to 5 minutes) Used when retrieving the Dynatrace tag rules.
* `delete` - (Defaults to 30 minutes) Used when deleting the Dynatrace tag rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

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 updating this @jiaweitao001. I ran the tests on this and it looks like there are some failures. Could you take a look at fixing these up and then we can have another look at this? Thanks!

------- Stdout: -------
=== RUN   TestAccDynatraceTagRules_basic
=== PAUSE TestAccDynatraceTagRules_basic
=== CONT  TestAccDynatraceTagRules_basic
    testcase.go:173: Step 1/3 error: Error running pre-apply plan: exit status 1
        Error: expected "user.0.first_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 50, in resource "azurerm_dynatrace_monitor" "test":
          50:     first_name   = ""
        Error: expected "user.0.last_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 51, in resource "azurerm_dynatrace_monitor" "test":
          51:     last_name    = ""
        Error: test: user.0.email, "" is not an valida email address
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 52, in resource "azurerm_dynatrace_monitor" "test":
          52:     email        = ""
        Error: expected "user.0.phone_number" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 53, in resource "azurerm_dynatrace_monitor" "test":
          53:     phone_number = ""
        Error: expected "user.0.country" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 54, in resource "azurerm_dynatrace_monitor" "test":
          54:     country      = ""
--- FAIL: TestAccDynatraceTagRules_basic (4.70s)
FAIL

@jiaweitao001
Copy link
Contributor Author

Thanks for updating this @jiaweitao001. I ran the tests on this and it looks like there are some failures. Could you take a look at fixing these up and then we can have another look at this? Thanks!

------- Stdout: -------
=== RUN   TestAccDynatraceTagRules_basic
=== PAUSE TestAccDynatraceTagRules_basic
=== CONT  TestAccDynatraceTagRules_basic
    testcase.go:173: Step 1/3 error: Error running pre-apply plan: exit status 1
        Error: expected "user.0.first_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 50, in resource "azurerm_dynatrace_monitor" "test":
          50:     first_name   = ""
        Error: expected "user.0.last_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 51, in resource "azurerm_dynatrace_monitor" "test":
          51:     last_name    = ""
        Error: test: user.0.email, "" is not an valida email address
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 52, in resource "azurerm_dynatrace_monitor" "test":
          52:     email        = ""
        Error: expected "user.0.phone_number" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 53, in resource "azurerm_dynatrace_monitor" "test":
          53:     phone_number = ""
        Error: expected "user.0.country" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 54, in resource "azurerm_dynatrace_monitor" "test":
          54:     country      = ""
--- FAIL: TestAccDynatraceTagRules_basic (4.70s)
FAIL

Hi @catriona-m , these acc tests should not be triggered automatically, I've add some logics to prevent it from happening. As mentioned in the description, because of some cost issue, I'll have to manually run the tests on the subs provided by the service team and paste the results here.

@catriona-m
Copy link
Member

Thanks for updating this @jiaweitao001. I ran the tests on this and it looks like there are some failures. Could you take a look at fixing these up and then we can have another look at this? Thanks!

------- Stdout: -------
=== RUN   TestAccDynatraceTagRules_basic
=== PAUSE TestAccDynatraceTagRules_basic
=== CONT  TestAccDynatraceTagRules_basic
    testcase.go:173: Step 1/3 error: Error running pre-apply plan: exit status 1
        Error: expected "user.0.first_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 50, in resource "azurerm_dynatrace_monitor" "test":
          50:     first_name   = ""
        Error: expected "user.0.last_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 51, in resource "azurerm_dynatrace_monitor" "test":
          51:     last_name    = ""
        Error: test: user.0.email, "" is not an valida email address
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 52, in resource "azurerm_dynatrace_monitor" "test":
          52:     email        = ""
        Error: expected "user.0.phone_number" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 53, in resource "azurerm_dynatrace_monitor" "test":
          53:     phone_number = ""
        Error: expected "user.0.country" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 54, in resource "azurerm_dynatrace_monitor" "test":
          54:     country      = ""
--- FAIL: TestAccDynatraceTagRules_basic (4.70s)
FAIL

Hi @catriona-m , these acc tests should not be triggered automatically, I've add some logics to prevent it from happening. As mentioned in the description, because of some cost issue, I'll have to manually run the tests on the subs provided by the service team and paste the results here.

Thanks @jiaweitao001 - I'll take another look at this once the test results are available.

@jiaweitao001
Copy link
Contributor Author

Thanks for updating this @jiaweitao001. I ran the tests on this and it looks like there are some failures. Could you take a look at fixing these up and then we can have another look at this? Thanks!

------- Stdout: -------
=== RUN   TestAccDynatraceTagRules_basic
=== PAUSE TestAccDynatraceTagRules_basic
=== CONT  TestAccDynatraceTagRules_basic
    testcase.go:173: Step 1/3 error: Error running pre-apply plan: exit status 1
        Error: expected "user.0.first_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 50, in resource "azurerm_dynatrace_monitor" "test":
          50:     first_name   = ""
        Error: expected "user.0.last_name" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 51, in resource "azurerm_dynatrace_monitor" "test":
          51:     last_name    = ""
        Error: test: user.0.email, "" is not an valida email address
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 52, in resource "azurerm_dynatrace_monitor" "test":
          52:     email        = ""
        Error: expected "user.0.phone_number" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 53, in resource "azurerm_dynatrace_monitor" "test":
          53:     phone_number = ""
        Error: expected "user.0.country" to not be an empty string, got
          with azurerm_dynatrace_monitor.test,
          on terraform_plugin_test.tf line 54, in resource "azurerm_dynatrace_monitor" "test":
          54:     country      = ""
--- FAIL: TestAccDynatraceTagRules_basic (4.70s)
FAIL

Hi @catriona-m , these acc tests should not be triggered automatically, I've add some logics to prevent it from happening. As mentioned in the description, because of some cost issue, I'll have to manually run the tests on the subs provided by the service team and paste the results here.

Thanks @jiaweitao001 - I'll take another look at this once the test results are available.

Hi @catriona-m , these tests should not be available on your teamcity pipeline because of cost issue. We have agreed that acc tests related to this resource will be ran under the subs provided by the service team, same as a previous resource here: #27432 . You can find the tests results in the description above.

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 @jiaweitao001 - I had another look through a left a couple more comments. I also wanted to note that if it is not possible to update his resource, then all the properties should be marked as ForceNew.

Comment on lines +66 to +79
"send_azure_active_directory_logs_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
},

"send_activity_logs_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
},

"send_subscription_logs_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

do these have default values?

return pointer.To(true), nil
}

func (r TagRulesResource) basic(data acceptance.TestData) string {
Copy link
Member

Choose a reason for hiding this comment

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

The basic test is typically creating the resource with the minimal required properties, could we change this test to only the required properties and have a separate complete test which includes all the properties?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants