How would I deploy a Marketplace item in terraform?

Hi,

I was wondering if it is possible to deploy a marketplace item with terraform.

For example, can I deploy the OpenVpn instance in the marketplace using terraform?

Thanks,
Jake

2 Replies

Hey Jake!

This earlier Community Questions post has an example of how you can go about deploying Marketplace Apps as StackScripts.

For example, if you want to find the Open VPN StackScript ID, you can use the following API call:

curl -k https://api.linode.com/v4/linode/stackscripts -H 'X-Filter: {"label": {"+contains": "OpenVPN"}}' -H "Content-Type: application/json" | jq '.data | .[] | .label,.id'

The result will be the following:

"OpenVPN Access Server (Login Data in Weblish/SSH)"
1037321
"Debian 7.5 OpenVPN"
10219
"Docker (OpenVPN)"
332143
"openvpn"
640933
"OpenVPN"
384501
"OpenVPN Install"
326757
"Linode openVPN Server"
325612
"Pritunl - Enterprise Distributed OpenVPN Server"
15091
"OpenVPN One-Click"
401719

Any Market Place apps are labeled "One-Click". You can then use our API Documentation to deploy a Linode using the StackScript ID.

I hope this helps!

The stack script id is also visible as part of the URL behind the "Deploy This App" button/link in the Marketplace, it's the value of the appID parameter. (e.g. 607026 for MySQL)

Use the API to get the list of user defined fields required for that stack script:

curl -H "Authorization: Bearer $LINODE_TOKEN" https://api.linode.com/v4/linode/stackscripts/607026 | jq

To use that with Terraform, use the stackscript_id and stackscript_data attributes of the linode_instance resource. Example:

resource "linode_instance" "db" {
  label           = var.label
  image           = var.image
  region          = var.region
  type            = var.instance_type
  root_pass       = random_password.root_pw.result
  authorized_keys = [chomp(var.ssh_public_key)]
  tags            = var.tags

  stackscript_id = 607026
  stackscript_data = {
    database        = "MariaDB"
    dbroot_password = random_password.dbroot_pw.result
    dbuser          = var.db_user
    dbuser_password = random_password.db_password.result
    database_name   = var.db_name
  }
}

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct