skyscrapr / terraform-provider-cloudability

Cloudability provider for Hashicorp Terraform
MIT License
8 stars 6 forks source link

Request for Enhancement of Retry Mechanism for cloudability_linked_account Resource #42

Closed HubGab-Git closed 2 months ago

HubGab-Git commented 3 months ago

It would be great if the cloudability_linked_account resource could have a retry mechanism. Currently, we frequently experience timeouts when trying to create a new AWS account and link it with Cloudability.

Would it be possible to implement a retry mechanism to handle these timeouts more gracefully?

Thank you!

skyscrapr commented 3 months ago

Hi. @HubGab-Git

Thanks for raising the issue. I did add support for timeouts for this resource.

However, looks like I didn't update the docs.

You should be able to add a custom timeout like this

resource "cloudability_linked_account" "aws_account" {
    vendor_account_id = var.aws_account_id

  timeouts {
    create = "5m"
  }
}

Give it a try.

I'll update the docs when I get a chance.

Cheers

R

HubGab-Git commented 3 months ago

Timeouts sound good, but is it also possible to add a retry mechanism? If those retries could affect the Cloudability API too much, maybe implementing a maximum of 3 to 5 retries would be sufficient?

Thank you for considering this enhancement!

skyscrapr commented 3 months ago

Looks fairly simple to implement. I can have a look at this over the next few days.

Can you please raise this directly with apptio as well? They really need to take on some of the work with maintaining this provider.

Thanks.

skyscrapr commented 3 months ago

Ok looking into this further. Looks like the way the api is designed, creating the linked account is asynchronous with the account verification.

The way I implemented this is to avoid blocking waiting for the account verification.

However you can wait for the verification by using the cloudability_account_verification resource. This can be configured to retry and wait for the account to be verified.

If you share the terraform that is failing for you and the error, I can explain how to integrate with that resource.

skyscrapr commented 2 months ago

@HubGab-Git can you confirm If the suggested solution works for you? You can see an example here: https://github.com/skyscrapr/terraform-cloudability-modules/blob/master/cloudability-linked-account/main.tf

If this is resolved, please confirm.

thanks

HubGab-Git commented 2 months ago

Hi @skyscrapr Thank you it is working