-
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 Data Source/Resource: azurerm_elasticsearch
#14821
New Data Source/Resource: azurerm_elasticsearch
#14821
Conversation
|
||
id := parse.NewElasticTagRuleID(subscriptionId, resourceGroup, name, ruleSetName).ID() | ||
|
||
existing, err := client.Get(ctx, resourceGroup, name, ruleSetName) |
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 function is used in both create
and update
, so we need to know whether this is a new resource by d.IsNewResource()
, because if it's a new resource, it must not exist otherwise we'll throw ImportAsExistsError
.
if d.IsNewResource() {
existing, err := client.Get(ctx, id.ResourceGroup, id.MonitorName, id.RuleSetName)
if err != nil {
if !utils.ResponseWasNotFound(existing.Response) {
return fmt.Errorf("checking for existing %q: %+v", id, err)
}
}
if !utils.ResponseWasNotFound(existing.Response) {
return tf.ImportAsExistsError("azurerm_elastic_tag_rule", id.ID())
}
}
@utkarshjain1508 , thanks for the PR! I took a loot at it, overall looks good but I have some minor comments to address that I've left inline. |
@tombuildsstuff can you please trigger the workflows ? |
@tombuildsstuff can you review and approve the PR ? All checks have passed and review comments resolved. |
@utkarshjain1508 , would you please change the title to be more descriptive like "new resource |
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 @utkarshjain1508 for the PR. Most part looks good to me, though there still are some minor changes need to address.
} | ||
} | ||
|
||
d.Set("log_rules", 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.
No need to set it nil here since we're removing this resource.
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.
will be updated in the next commit.
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.
@ms-henglu I checked our RP and it seems we do not support delete request explicitly for this resource type. We set the resource to null and update it as a way of deletion. Let me know if this is acceptable.
}, | ||
} | ||
|
||
if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.MonitorName, id.TagRuleName, &body); 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.
I think we should use client.Delete
?
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.
will be updated in the next commit
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.
Reference previous conversation https://github.com/hashicorp/terraform-provider-azurerm/pull/14821#discussion_r795040966
@tombuildsstuff this PR has been open for a very long time. Can we prioritize this ? |
71e43d6
to
8a32f7d
Compare
hey @utkarshjain1508 Thanks for this PR - apologies for the delayed review here. Due to the size of this PR with the Embedded (Legacy) SDK, I ended up pulling this down locally yesterday to review it and understand the use-case a little more fully. Having spent some time investigating this, I believe there's a number of design changes we need to make here:
Since these are some larger changes I hope you don't mind but I've gone ahead and made those changes in this branch - and at the same time introduced a Data Source for the Elastic Stack cluster. Running the tests for those unfortunately it appears there's an issue in either the Elastic ARM API or the Elastic Cloud API (which presumably ARM is calling to tear-down the cluster) - where during the deletion of the Elastic Stack the Resource Group is also being deleted. I didn't check whether this behaviour also happens if the Resource Group contains other items, however this behaviour causes an issue in Terraform and as such needs to be fixed in either the Azure / Elastic API to be able to get this supported in Terraform. As this is a bug in the upstream API, I've opened this issue on the Azure Rest API Specs repository to track this - where once this is fixed we should be able to run the tests and get this merged. Thanks! |
azurerm_elastic_stack
8a32f7d
to
3a0bf2f
Compare
@tombuildsstuff can you send us list of subscriptions you were using while testing ? |
e15aa7a
to
80e88ce
Compare
azurerm_elastic_stack
azurerm_elasticsearch
@koikonom @tombuildsstuff We have discussed the issue for the resource name with elasticsearch team and PMs. We have decided to go aheadwith the name azurerm_elasticsearch. I have made the changes and pushed. Please have a look. |
@utkarshjain1508 as mentioned above unfortunately this name would be misleading.. are there any other suggestions from the team? |
@karansinghkushwah Your thoughts on this ? |
@osmanis, @rotata - Can you please share your perspective here? // cc: @hashah-msft |
@karansinghkushwah IMO |
@hemantmalik @utkarshjain1508 thanks for confirming - let's go with I think the only other blocker here is that the API failed when the email contained the word |
@tombuildsstuff That failure was not due to email containing "test" but due to some other issue. That has been fixed. You can see that current acceptance tests have the email with word test. |
Hello @utkarshjain1508 Unfortunately the acceptance tests are still not passing. The first issue is this:
This is happening because no ID is being set in the data source's Read() method. I fixed it (see 6d98ca9 ) but now the tests are failing because vairous checks fail too. For example:
Please revisit this test. |
@koikonom let mecheck that. |
@koikonom I have made changes to the resource name and fixed the acceptance tests. They seem to be passing on my local now. |
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. |
Adding elastic plugin for azure resource provider