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

Inconsistent errors when planning/applying on project with around 6 domains #47

Open
terah opened this issue Jul 10, 2023 · 2 comments
Open

Comments

@terah
Copy link

terah commented Jul 10, 2023

Hi there,

Versions:

Terraform v1.5.0
on darwin_arm64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.19.0
+ provider registry.terraform.io/digitalocean/digitalocean v2.28.1
+ provider registry.terraform.io/hashicorp/aws v5.7.0
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/wgebis/mailgun v0.7.4

Your version of Terraform is out of date! The latest version
is 1.5.2. You can update by downloading from https://www.terraform.io/downloads.html

I've got an issue that's been persistent over the past months. Whenever I have a few mailgun_domains in my project, I start to see inconsistent errors:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Error retrieving domain: while making http request: Get "https://api.mailgun.net/v3/domains/email.test-worker.mydomain.net": remote error: tls: handshake failure
│
│   with module.gsr-x-worker.mailgun_domain.email-domain,
│   on ../modules/manage-worker-do-v1/email.tf line 12, in resource "mailgun_domain" "email-domain":
│   12: resource "mailgun_domain" "email-domain" {

The errors can occur on different domains across different terraform projects and different computers.

I've tried putting all the API queries into a .HTTP file and running that to see if I can get it to break outside of Terraform.

I've done a lot of searching for the cause of this without much luck.

@terah
Copy link
Author

terah commented Aug 20, 2023

I created a support ticket with mailgun for them to look into the errors when the number of resources gets a bit higher and they came back with a generic 'We don't support third-party tools' response.

I suspect that when the number of resources reaches 6+ (or thereabouts), the rapidity of API calls causes the mailgun API to drop the requests.

Is there a way to throttle down the API calls?


terraform {
  required_providers {

    mailgun = {
      source  = "wgebis/mailgun"
      version = "0.7.4"
    }
  }
  required_version = ">= 0.13"
}

provider "mailgun" {
  api_key = "<your api key>"
}

resource "random_string" "email-password" {
  length  = 31
  special = false
}

resource "mailgun_domain" "email-domain1" {
  name          = "sub1.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}


resource "mailgun_domain" "email-domain2" {
  name          = "sub2.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}



resource "mailgun_domain" "email-domain3" {
  name          = "sub3.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}



resource "mailgun_domain" "email-domain4" {
  name          = "sub4.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}

resource "mailgun_domain" "email-domain5" {
  name          = "sub5.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}

resource "mailgun_domain" "email-domain6" {
  name          = "sub6.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}

resource "mailgun_domain" "email-domain7" {
  name          = "sub7.example.com"
  region        = "us"
  spam_action   = "disabled"
  smtp_password = random_string.email-password.result
  dkim_key_size = 1024

  lifecycle {
    ignore_changes = [smtp_password]
  }
}

output "email-domain-records1" {
  value = mailgun_domain.email-domain1.sending_records_set
}


output "email-domain-records2" {
  value = mailgun_domain.email-domain2.sending_records_set
}


output "email-domain-records3" {
  value = mailgun_domain.email-domain3.sending_records_set
}


output "email-domain-records4" {
  value = mailgun_domain.email-domain4.sending_records_set
}



output "email-domain-records5" {
  value = mailgun_domain.email-domain5.sending_records_set
}



output "email-domain-records6" {
  value = mailgun_domain.email-domain6.sending_records_set
}



output "email-domain-records7" {
  value = mailgun_domain.email-domain7.sending_records_set
}

@Chupaka
Copy link

Chupaka commented Aug 21, 2023

Just my 2c: I just tested a plan on a workspace with 23 domains and it succeeded in Terraform Cloud.

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

No branches or pull requests

2 participants