DEV Community

AF uarabei
AF uarabei

Posted on

3 1

Terraform Standard Backends: HTTP Backend

Another backend type which we will explore is called HTTP backend.

This type of backend allows us to store state using a REST client.

State will be fetched using GET, updated via POST, and finally destroyed using DELETE.

This backend also supports state locking which, as we learned previously, is an incredibly handy feature. When locking is enabled you can use LOCK and UNLOCK requests to include the lock info in the body. The endpoint will return 423:Locked or 409:Conflict if the lock is active and 200:OK if there is no lock.

This is how you add an HTTP backend:

# terraform.tf

terraform {
  backend "http" {
    address = "http://myrest.api.com/foo"

    lock_method    = "PUT"
    lock_address   = "http://myrest.api.com/foo"

    unlock_address = "http://myrest.api.com/foo"
    unlock_method  = "DELETE"
  }
}
Enter fullscreen mode Exit fullscreen mode

This was a very short article, but since we are on the topic of backends I thought this simple backend will be a good addition.

Thank you for reading! See you in the next article!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay