惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Register - Security
The Register - Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
V
Visual Studio Blog
云风的 BLOG
云风的 BLOG
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
L
LangChain Blog
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
H
Hacker News: Front Page
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
T
Threatpost
AWS News Blog
AWS News Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tor Project blog
Google Online Security Blog
Google Online Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tenable Blog
W
WeLiveSecurity
博客园 - 叶小钗
K
Kaspersky official blog
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
Hacker News - Newest:
Hacker News - Newest: "LLM"
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
小众软件
小众软件
D
Docker
爱范儿
爱范儿
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
S
Schneier on Security
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno Zero-config Debugging with Deno and OpenTelemetry | Deno Exploring Art with TypeScript, Jupyter, Polars, and Observable Plot | Deno Deno v Oracle Update 3: Fighting the JavaScript Trademark | Deno Build a custom RAG AI agent in TypeScript and Jupyter | Deno How to get deep traces in your Node.js backend with OTel and Deno | Deno toranoana.deno #20 登録受付中(2025年3月14日) | Deno Node just added TypeScript support. What does that mean for Deno? | Deno The Dino 🦕, the Llama 🦙, and the Whale 🐋 | Deno Publish a lint rule, get a prize | Deno Deno 2.2: OpenTelemetry, Lint Plugins, node:sqlite | Deno If you're not using npm specifiers, you're doing it wrong | Deno How Deno's documentation is evolving | Deno Oracle justified its JavaScript trademark with Node.js—now it wants that ignored | Deno Introducing the JSR open governance board | Deno Intro to Wasm in Deno | Deno Announcing OpenAI on JSR | Deno Deno in 2024 | Deno Goodbye WinterCG, welcome WinterTC | Deno Build a SolidJS app with Deno | Deno Run your Next.js SSR app on Deno Deploy | Deno Solve Advent of Code 2024 with Deno and Win Prizes! | Deno Deno v. Oracle: Canceling the JavaScript Trademark | Deno Deno 2.1: Wasm Imports and other enhancements | Deno Build a Typesafe API with tRPC and Deno | Deno Self-contained Executable Programs with Deno Compile | Deno Build a Database App with Drizzle ORM and Deno | Deno Introducing your new JavaScript package manager: Deno | Deno Announcing Growthbook on JSR | Deno Build an Astro site with Deno | Deno How to convert CommonJS to ESM | Deno Announcing Deno 2 | Deno The Final Touches: What’s New In v2.0.0-rc.10 | Deno Announcing Stable V8 Bindings for Rust | Deno Deno 2.0 Release Candidate | Deno Secure, efficient private npm registries with Cloudsmith and Deno | Deno Painting the Plane as We Fly It: Designing JSR | Deno Introducing Web Cache API support on Deno Deploy | Deno Deno 1.46: The Last 1.x Release | Deno Protect your cloud spend with new Deno Deploy spend limits | Deno What we got wrong about HTTP imports | Deno Benchmarking AWS Lambda Cold Starts Across JavaScript Runtimes | Deno Announcing Supabase on JSR | Deno Deno 1.45: Workspace and Monorepo Support | Deno Introducing KV Backup for Deno Subhosting | Deno A Gentle Intro to TypeScript | Deno Announcing Hono on JSR | Deno How We Made the Deno Language Server Ten Times Faster | Deno How the Guardian uses Deno to audit accessibility and performance across their 2.7 million articles | Deno Introducing More Flexible Domain Association for Deno Subhosting | Deno The stabilization process of the Standard Library has begun | Deno Deno 1.44: Private npm registries, improved Node.js compat, and performance boosts | Deno How we built a secure, performant, multi-tenant cloud platform to run untrusted code | Deno The Deno Standard Library is now available on JSR | Deno How to document your JavaScript package | Deno Your Low Code Solution Needs an Escape Hatch | Deno Deno 1.43: Improved Language Server performance | Deno How Slack used Deno to save months of engineering effort in launching their new platform | Deno JSR Is Not Another Package Manager | Deno Announcing the Hookdeck SDK on JSR | Deno Announcing the Neon Serverless Driver on JSR | Deno An intro to TSConfig for JavaScript Developers | Deno How we built JSR | Deno How Netlify used Deno Subhosting to build a successful edge functions product | Deno Introducing Simpler Project Creation in Deno Deploy | Deno Deno 1.42: Better dependency management with JSR | Deno Introducing deployctl, the command line interface for Deno Deploy | Deno Introducing JSR - the JavaScript Registry | Deno How to add Monaco to a Next.js app and securely run untrusted user code | Deno Survey Results and Roadmap | Deno Deno 1.41: smaller deno compile binaries | Deno
Manage your Deno Deploy and Deno Subhosting projects with Terraform | Deno
2023-12-06 · via Deno

We recently launched Deno Subhosting (built on the Deno Deploy infrastructure), the easiest and most secure way to run and host your users’ code. Companies can use Subhosting to extend their products’ functionalities via a developer platform or a third-party application marketplace. Deno Subhosting’s simple API make it easy to integrate into your platform, so you can programmatically manage deployments, projects, and more.

However, many developers prefer to manage business-critical infrastructure in the cloud with infrastructure-as-code patterns such as Terraform, since it’s a safe, reliable, and predictable way to provision and manage cloud services. Now, we’re excited to announce that you are able to use Deno Subhosting and Deno Deploy through Terraform with our official Deno Terraform Provider.

This provider will allow you to manage a large number of projects, custom domains, deployments, and more, using Terraform. We will maintain this provider and keep it in sync with the new Subhosting API.

Though we’re still working to complete the documentation, you can find the auto-generated provider docs here, as well as a number of working examples in the GitHub.

Keep on reading to learn more about:

  • Publish a local directory of code to Deno Deploy
  • Defining the Terraform file
  • Running Terraform to deploy
  • What’s next

How to publish a local directory of code to Deno Deploy

To give you an example of how the Deno Terraform Provider works, let’s walk through an example that will publish a local directory of code to Deno Deploy.

Given the below project structure (simplified for this example):

.
├── deno.json
├── src
│   └── main.ts
├── static
│   └── cat.png
└── terraform
    └── main.tf

We’d like to deploy src/main.ts , which accesses static/cat.png and an environment variable FOO:

Deno.serve(async (req) => {
  const url = new URL(req.url);

  
  
  switch (url.pathname) {
    case "/cat.png": {
      const file = await Deno.open("./static/cat.png");
      return new Response(file.readable, {
        headers: {
          "content-type": "image/png",
        },
      });
    }
    default: {
      return new Response(`FOO is ${Deno.env.get("FOO")}`);
    }
  }
});

Defining the Terraform file

Next, let’s define the .tf file. Note that there are two required parameters: your organization ID, and an access token which you can generate on the deploy dashboard. In the example below we hard code these in the terraform file; alternatively you can pass them via environment variables, DENO_DEPLOY_ORGANIZATION_ID and DENO_DEPLOY_TOKEN, respectively.

terraform {
  required_providers {
    deno = {
      source = "denoland/deno"
    }
  }
}

provider "deno" {
  
  
  
  organization_id = "e1ae3bcc-923e-4930-a6a7-5841e69849ed"

    
  
  token = "ddo_3JfdN41GxH0PufmzcoahcJtQXcbde144Z7l9"
}

Next, let’s create a project using the deno_project resource. Note that name is optional (if it’s omitted, a random name is automatically generated) but it must be globally unique.

resource "deno_project" "sample_project" {
  name = "awesome-deno-40"
}

Then, let’s define “assets” using the deno_assets data source. You can think of this as a set of files to be uploaded. The first required parameter, path, serves as a root directory path where Terraform looks for assets. The second parameter, pattern, is a glob string whose matches determine which assets to be included.

In this example, src/main.ts and static/cat.png will be included:

data "deno_assets" "sample_assets" {
  path    = "../"
  pattern = "{src,static}/**/*.{ts,png}"
}

We’re now ready to create the deployment using the deno_deployment resource. This resource accepts parameters project_id and assets data that have been created so far. Other parameters, such as env_vars can also be provided. (For more details, check out this example usage.)

resource "deno_deployment" "sample_deployment" {
  project_id      = deno_project.sample_project.id
  entry_point_url = "src/main.ts"
  assets          = data.deno_assets.sample_assets.output
  env_vars = {
    FOO = "42"
  }
}

And that’s it!

Running Terraform

Let’s run terraform plan to see if we have configured things correctly:

$ cd terraform
$ terraform plan
data.deno_assets.sample_assets: Reading...
data.deno_assets.sample_assets: Read complete after 0s

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  
  + resource "deno_deployment" "sample_deployment" {
      + assets          = {
          + "src/main.ts" = {
              + content_source_path = "../src/main.ts"
              + kind                = "file"
            },
          + "static/cat.png" = {
              + content_source_path = "../static/cat.png"
              + kind                = "file"
            },
        }
      + created_at      = (known after apply)
      + deployment_id   = (known after apply)
      + domains         = (known after apply)
      + entry_point_url = "src/main.ts"
      + env_vars        = {
          + "FOO" = "42"
        }
      + project_id      = (known after apply)
      + status          = (known after apply)
      + updated_at      = (known after apply)
      + uploaded_assets = (known after apply)
    }

  
  + resource "deno_project" "sample_project" {
      + created_at = (known after apply)
      + id         = (known after apply)
      + name       = "awesome-deno-40"
      + updated_at = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.

Looks good! Now let’s run terraform apply.

$ terraform apply
data.deno_assets.sample_assets: Reading...
data.deno_assets.sample_assets: Read complete after 0s

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  
  + resource "deno_deployment" "sample_deployment" {
      + assets          = {
          + "src/main.ts" = {
              + content_source_path = "../src/main.ts"
              + kind                = "file"
            },
          + "static/cat.png" = {
              + content_source_path = "../static/cat.png"
              + kind                = "file"
            },
        }
      + created_at      = (known after apply)
      + deployment_id   = (known after apply)
      + domains         = (known after apply)
      + entry_point_url = "src/main.ts"
      + env_vars        = {
          + "FOO" = "42"
        }
      + project_id      = (known after apply)
      + status          = (known after apply)
      + updated_at      = (known after apply)
      + uploaded_assets = (known after apply)
    }

  
  + resource "deno_project" "sample_project" {
      + created_at = (known after apply)
      + id         = (known after apply)
      + name       = "awesome-deno-40"
      + updated_at = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

deno_project.sample_project: Creating...
deno_project.sample_project: Creation complete after 0s [id=82672716-5aee-4279-a7da-3a3554ec9f74]
deno_deployment.sample_deployment: Creating...
deno_deployment.sample_deployment: Creation complete after 4s

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Done! Let’s take a look at the Terraform state to get a URL to access the deployment:

$ terraform state show deno_deployment.sample_deployment

resource "deno_deployment" "sample_deployment" {
    // ...
    deployment_id   = "rpxayrskrhzt"
    domains         = [
        "awesome-deno-40-rpxayrskrhzt.deno.dev",
    ]
    entry_point_url = "src/main.ts"
    // ...
}

To check if our code is successfully deployed on Deno Deploy and works properly, let’s visit https://awesome-deno-40-rpxayrskrhzt.deno.dev/ , which should show the configured environment variable. Also, going to https://awesome-deno-40-rpxayrskrhzt.deno.dev/cat.png should show your cute cat picture.

Cute cat picture

What’s next

Even though Deno Subhosting provides simple APIs to manage projects, deployments, and more on Deno Deploy, for those familiar with infrastructure-as-code patterns, using the Deno Terraform Provider can be simpler, especially when coordinating hundreds of projects.

We hope to add documentation and more examples, but if you would like technical help, please join us in our active Discord or create an issue here.

💡️ Learn how you can unlock the last 10% of your platform’s value with Deno Subhosting in our livestream where Kevin and Bert offer Subhosting examples from innovative companies and demo the Subhosting API.

Linkedin Event