[ Web Proxy ]
URL:
Viewing: https://docs.digitalocean.com/reference/terraform/reference/resources/app/ [Back]  [Original]

digitalocean_app | DigitalOcean Documentation

For AI agents: The documentation index is at https://docs.digitalocean.com/llms.txt. Markdown versions of pages use the same URL with index.html.md in place of the HTML page (for example, append index.html.md to the directory path instead of opening the HTML document).

digitalocean_app

Generated on 18 Aug 2026 from Terraform version v2.100.0

Copy page as Markdown View page as Markdown

Provides a DigitalOcean App resource.

Example Usage

To create an app, provide a DigitalOcean app spec specifying the app’s components.

Basic Example

resource "digitalocean_app" "golang-sample" {
  spec {
    name   = "golang-sample"
    region = "ams"

    service {
      name               = "go-service"
      instance_count     = 1
      instance_size_slug = "apps-s-1vcpu-1gb"

      git {
        repo_clone_url = "https://github.com/digitalocean/sample-golang.git"
        branch         = "main"
      }
    }
  }
}

Static Site Example

resource "digitalocean_app" "static-site-example" {
  spec {
    name   = "static-site-example"
    region = "ams"

    static_site {
      name          = "sample-jekyll"
      build_command = "bundle exec jekyll build -d ./public"
      output_dir    = "/public"

      git {
        repo_clone_url = "https://github.com/digitalocean/sample-jekyll.git"
        branch         = "main"
      }
    }
  }
}

Multiple Components Example

resource "digitalocean_app" "mono-repo-example" {
  spec {
    name   = "mono-repo-example"
    region = "ams"
    domain {
      name = "foo.example.com"
    }

    alert {
      rule = "DEPLOYMENT_FAILED"

      # Setup alert destination (optional)
      # If left empty, email will be set to the team's default email
      destinations {
        emails = ["[email protected]", "[email protected]"]
        slack_webhooks {
          channel = "@user1"
          url     = "https://hooks.slack.com/slack-url"
        }
      }
    }

    # Build a Go project in the api/ directory that listens on port 3000
    # and serves it at https://foo.example.com/api
    service {
      name               = "go-api"
      instance_count     = 2
      instance_size_slug = "apps-s-1vcpu-1gb"

      github {
        branch         = "main"
        deploy_on_push = true
        repo           = "username/repo"
      }

      source_dir = "api/"
      http_port  = 3000

      alert {
        value    = 75
        operator = "GREATER_THAN"
        window   = "TEN_MINUTES"
        rule     = "CPU_UTILIZATION"

        # Setup alert destination (optional)
        # If left empty, email will be set to the team's default email
        destinations {
          emails = ["[email protected]", "[email protected]"]
          slack_webhooks {
            channel = "@user1"
            url     = "https://hooks.slack.com/slack-url"
          }
        }
      }

      log_destination {
        name = "MyLogs"
        papertrail {
          endpoint = "syslog+tls://example.com:12345"
        }
      }

      run_command = "bin/api"
    }

    # Builds a static site in the project's root directory
    # and serves it at https://foo.example.com/
    static_site {
      name          = "web"
      build_command = "npm run build"

      bitbucket {
        branch         = "main"
        deploy_on_push = true
        repo           = "username/repo"
      }
    }

    database {
      name       = "starter-db"
      engine     = "PG"
      production = false
    }

    ingress {
      rule {
        component {
          name = "api"
        }
        match {
          path {
            prefix = "/api"
          }
        }
      }

      rule {
        component {
          name = "web"
        }

        match {
          path {
            prefix = "/"
          }
        }
      }
    }

    vpc {
      id = "c22d8f48-4bc4-49f5-8ca0-58e7164427ac"
    }
  }
}

Log Destination Example with Opensearch

resource "digitalocean_app" "golang-sample" {
  spec {
    name   = "golang-sample"
    region = "ams"

    service {
      name               = "go-service"
      instance_count     = 1
      instance_size_slug = "apps-s-1vcpu-1gb"

      git {
        repo_clone_url = "https://github.com/digitalocean/sample-golang.git"
        branch         = "main"
      }

      log_destination {
        name = "MyLogs"
        open_search {
          endpoint = "https://something:1234"
          basic_auth {
            user     = "user"
            password = "hi"
          }
        }
      }
    }
  }
}

Edge Controls Example

resource "digitalocean_app" "golang-sample" {
  spec {
    name                            = "golang-sample"
    region                          = "ams"
    disable_edge_cache              = true
    disable_email_obfuscation       = false
    enhanced_threat_control_enabled = true

    service {
      name               = "go-service"
      instance_count     = 1
      instance_size_slug = "apps-s-1vcpu-1gb"

      git {
        repo_clone_url = "https://github.com/digitalocean/sample-golang.git"
        branch         = "main"
      }
    }
  }
}

Maintenance Example

resource "digitalocean_app" "maintenance-example" {
  spec {
    name   = "maintenance-example"
    region = "ams"

    # Enable maintenance mode with a custom offline page
    maintenance {
      enabled          = true
      offline_page_url = "https://example.com/maintenance.html"
    }

    service {
      name               = "go-service"
      instance_count     = 1
      instance_size_slug = "apps-s-1vcpu-1gb"

      git {
        repo_clone_url = "https://github.com/digitalocean/sample-golang.git"
        branch         = "main"
      }
    }
  }
}

Argument Reference

The following arguments are supported:

A spec can contain multiple components.

A service can contain:

A static_site can contain:

A worker can contain:

A job can contain:

A function component can contain:

A database can contain:

This resource supports customized create timeouts. The default timeout is 30 minutes.

Attributes Reference

In addition to the above attributes, the following are exported:

Import

An app can be imported using its id, e.g.

terraform import digitalocean_app.myapp fb06ad00-351f-45c8-b5eb-13523c438661

In this article...


We can't find any results for your search.

Try using different keywords or simplifying your search terms.


Web Proxy Viewer  |  New URL  |  Original Page