Fixing terraform race condition.
This commit is contained in:
20
main.tf
20
main.tf
@@ -12,10 +12,6 @@ terraform {
|
||||
source = "hashicorp/null"
|
||||
version = "3.3.0"
|
||||
}
|
||||
time = {
|
||||
source = "hashicorp/time"
|
||||
version = "0.14.0"
|
||||
}
|
||||
cloudflare = {
|
||||
source = "cloudflare/cloudflare"
|
||||
version = "5.22.0"
|
||||
@@ -86,6 +82,10 @@ variable "digitalocean_volume_size" {
|
||||
|
||||
provider "digitalocean" {
|
||||
token = var.do_token
|
||||
|
||||
http_retry_max = 10
|
||||
http_retry_wait_min = 2
|
||||
http_retry_wait_max = 60
|
||||
}
|
||||
|
||||
provider "cloudflare" {
|
||||
@@ -142,21 +142,11 @@ resource "digitalocean_droplet" "machine" {
|
||||
size = var.server_type
|
||||
ssh_keys = [digitalocean_ssh_key.first.fingerprint]
|
||||
user_data = file("ignition.json")
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "time_sleep" "wait_10_seconds" {
|
||||
create_duration = "10s"
|
||||
}
|
||||
|
||||
resource "digitalocean_reserved_ip_assignment" "machine" {
|
||||
depends_on = [digitalocean_volume_attachment.machine]
|
||||
ip_address = digitalocean_reserved_ip.machine.ip_address
|
||||
droplet_id = digitalocean_droplet.machine.id
|
||||
# sometimes digital ocean throws an error for this resource
|
||||
# saying the droplet has a pending event so we delay a few seconds
|
||||
depends_on = [time_sleep.wait_10_seconds]
|
||||
}
|
||||
|
||||
resource "digitalocean_volume_attachment" "machine" {
|
||||
|
||||
Reference in New Issue
Block a user