Skip to content

Commit

Permalink
Update DO Terraform files
Browse files Browse the repository at this point in the history
  • Loading branch information
muratugureminoglu committed Feb 17, 2025
1 parent 9255cd1 commit d229939
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 0 additions & 1 deletion terraform/do/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ wget https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/
bash 90-cleanup.sh
bash 99-img-check.sh
history -c
shutdown -h now
31 changes: 31 additions & 0 deletions terraform/do/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ resource "digitalocean_droplet" "enterprise" {
}
}

resource "null_resource" "poweroff-enterprise" {
count = length(digitalocean_droplet.enterprise) # Tüm droplet'ler için döngü

provisioner "local-exec" {
command = <<EOT
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer ${var.do_token}" \
"https://api.digitalocean.com/v2/droplets/${digitalocean_droplet.enterprise[count.index].id}/actions" \
-d '{"type":"power_off"}'
EOT
}

depends_on = [digitalocean_droplet.enterprise]
}


resource "digitalocean_droplet_snapshot" "ams-enterprise-snapshot" {
count = var.do_droplet_enable ? 1 : 0
droplet_id = digitalocean_droplet.enterprise[count.index].id
Expand Down Expand Up @@ -89,6 +105,21 @@ resource "digitalocean_droplet" "community" {
}
}

resource "null_resource" "poweroff-community" {
count = length(digitalocean_droplet.community) # Tüm droplet'ler için döngü

provisioner "local-exec" {
command = <<EOT
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer ${var.do_token}" \
"https://api.digitalocean.com/v2/droplets/${digitalocean_droplet.community[count.index].id}/actions" \
-d '{"type":"power_off"}'
EOT
}

depends_on = [digitalocean_droplet.community]
}

resource "digitalocean_droplet_snapshot" "ams-community-snapshot" {
count = var.do_droplet_enable ? 1 : 0
droplet_id = digitalocean_droplet.community[count.index].id
Expand Down

0 comments on commit d229939

Please sign in to comment.