-
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_eventhub_cluster
#7306
Conversation
azurerm_eventhub_cluster
azurerm_eventhub_cluster
azurerm_eventhub_cluster
azurerm_eventhub_cluster
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 @mbfrahry
Couple questions and comments below, but otherwise LGTM 👍
Thanks!
} | ||
|
||
if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { | ||
return resource.NonRetryableError(fmt.Errorf("creating eventhub cluster: %+v", err)) |
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.
typo here?
return resource.NonRetryableError(fmt.Errorf("creating eventhub cluster: %+v", err)) | |
return resource.NonRetryableError(fmt.Errorf("deleting eventhub cluster: %+v", err)) |
id, err := azure.ParseAzureResourceID(d.Id()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
resourceGroup := id.ResourceGroup | ||
name := id.Path["clusters"] |
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.
Worth a custom ID parser here?
if response.WasNotFound(future.Response()) { | ||
return nil | ||
} | ||
if strings.Contains(err.Error(), "Cluster cannot be deleted until four hours after its creation time") { |
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.
Is it worth a 429 check here too given the length of time this operation could be running for?
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.
Creating/deleting clusters is actually quite fast. It's just that once created you can't delete it for the first 4 hours. I don't think a case where TF would wait for 4 hours makes sense?
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 @favoretti
In this case, if the delete operation is requested before the 4 hour minimum lifetime (say as part of a daily build, or acceptance test), the provider is capable of performing the operation without error or intervention (whilst honouring any custom timeouts
). If the request is sent after that minimum interval this section of code won't trigger and will, as you point out, complete quickly.
Co-authored-by: Steve <[email protected]>
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.
Aside from one comment about upgrading all the resources to the new api looks good @mbfrahry
@@ -2,17 +2,22 @@ package client | |||
|
|||
import ( | |||
"github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" | |||
previewEventhub "github.com/Azure/azure-sdk-for-go/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub" |
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.
Is there a reason we can't upgrade the rest of the resources to this api version
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.
Good call! The preview version was a little wonky when I started but it seems to have evened out with this latest version. It's been taken care of and tests look good
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 @mbfrahry I have left some question and minor comments, please have a look
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, |
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.
Could we also check the ID before the import?
|
||
future, err := client.Put(ctx, resourceGroup, name, cluster) | ||
if err != nil { | ||
return err |
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.
Maybe we should put some custom error messages here?
|
||
read, err := client.Get(ctx, resourceGroup, name) | ||
if err != nil { | ||
return err |
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.
Maybe we should put some custom error messages here?
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.
+1
client := meta.(*clients.Client).Eventhub.ClusterClient | ||
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) | ||
defer cancel() | ||
id, err := parse.NamespaceAuthorizationRuleID(d.Id()) |
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.
Why here we are parsing this ID as a namespace authorization rule instead of cluster?
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.
aside from a few minor remarks LGTM 👍
|
||
read, err := client.Get(ctx, resourceGroup, name) | ||
if err != nil { | ||
return err |
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.
+1
name := rs.Primary.Attributes["name"] | ||
resourceGroup := rs.Primary.Attributes["resource_group_name"] |
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.
we should use the parse id function here on the id
name := rs.Primary.Attributes["name"] | ||
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] |
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.
and parse id again here
} | ||
|
||
resource "azurerm_eventhub_cluster" "test" { | ||
name = "acctesteventhubcluster-%d" |
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.
can capitals be used here?
This has been released in version 2.15.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.15.0"
}
# ... other configuration ... |
@mbfrahry how can I assign eventhub_namespaces to eventhub_cluster ? |
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! |
Fixes #6808