By xenlet
I am having a problem deploying a droplet on DigitalOcean with Terraform. I followed the documentation in the official Terraform website but it does not work. I am getting the following error:
Error: Error creating droplet: POST https://api.digitalocean.com/v2/droplets: 422 The image you specified is not available in the selected region.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
I recently deployed a droplet with Terraform on my own and had the same issue. However, I fixed it by doing the following:
1st part (I assume you already did that)
variable "do_token" {
default = "YOUR-API-KEY"
}
4.link the do_token variable to the provider block:
provider "digitalocean" {
version = "2.0.0"
token = var.do_token
}
2nd part
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer YOUR-API-KEY" "https://api.digitalocean.com/v2/images?page=2&per_page=1&type=distribution"
image = "centos-6-x64"
name = "web-1"
region = "lon1"
size = "s-1vcpu-1gb"
}```
And that's it. I hope this helps. If you need more information on the DO API, please check it here - https://developers.digitalocean.com/documentation/v2/
Best,
Dennis
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.