# Terraform Provider

**URL:** <https://forums.balena.io/t/terraform-provider/337405>\
**Category:** Product support\
**Created:** [July 8, 2021, 2:49pm UTC](https://forums.balena.io/t/terraform-provider/337405 "2021-07-08T14:49:31Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 8, 2021, 2:49pm UTC](https://forums.balena.io/t/terraform-provider/337405/1 "2021-07-08T14:49:31Z")

</div>

Are there plans for a Terraform provider? I am looking to manage a fleet in Terraform (IaC).

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [July 9, 2021, 5:27am UTC](https://forums.balena.io/t/terraform-provider/337405/2 "2021-07-09T05:27:33Z")

</div>

Hi @nmcauliffe

Not sure I understand your question correctly - are you talking about deploying OpenBalena using Terraform?

---

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 9, 2021, 12:57pm UTC](https://forums.balena.io/t/terraform-provider/337405/4 "2021-07-09T12:57:56Z")

</div>

No, I’m looking for something I can use to configure Balena Cloud - apps, devices, orgs, etc. But it should be usable for any installation with an host name configuration parameter.

---

<div class="post-metadata">

**Author:** ![nitish](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@nitish](https://forums.balena.io/u/nitish)\
**Post date:** [July 9, 2021, 2:22pm UTC](https://forums.balena.io/t/terraform-provider/337405/7 "2021-07-09T14:22:30Z")

</div>

Hi

Thanks for getting back. We would love to understand a bit more; what use case TF helps with ? This will help us identify if there is a gap on Balena Cloud Dashboard|CLI.

---

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 13, 2021, 1:53pm UTC](https://forums.balena.io/t/terraform-provider/337405/10 "2021-07-13T13:53:24Z")

</div>

There is no way to manage the fleet, org, or apps using IaC. I would like to define everything possible as code and then use something like TF to deploy it.

---

<div class="post-metadata">

**Author:** ![nitish](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@nitish](https://forums.balena.io/u/nitish)\
**Post date:** [July 13, 2021, 3:52pm UTC](https://forums.balena.io/t/terraform-provider/337405/11 "2021-07-13T15:52:33Z")

</div>

Thanks. We have created a Product item to prioritize for IaC management of fleet via Terraform.

One question: The devices are something as first level concept (more like pets not cattle) where the management piece comes at play. I think the IaC has always given more importance to structure and associated software rather than actual devices (count), do you have a use case on similar lines? i.e. we care about the required number of devices running the desired software on them rather than all actual devices in the system.

---

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 14, 2021, 12:39pm UTC](https://forums.balena.io/t/terraform-provider/337405/13 "2021-07-14T12:39:00Z")

</div>

For what I was looking at this for, we would care more about the pets part. My initial thought was a `device` resource that would be attached to an `app` resource.

Let me know if you need any more info.

---

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 14, 2021, 2:17pm UTC](https://forums.balena.io/t/terraform-provider/337405/14 "2021-07-14T14:17:42Z")

</div>

`device` resource attributes would need to include the zip link and configuration file link.

---

<div class="post-metadata">

**Author:** ![toochevere](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@toochevere](https://forums.balena.io/u/toochevere)\
**Post date:** [July 21, 2021, 9:18pm UTC](https://forums.balena.io/t/terraform-provider/337405/15 "2021-07-21T21:18:25Z")

</div>

Hey @nmcauliffe, a question. What exactly do you mean by a zip link and configuration file link for the device? Do you mean a link to an image for flashing the device and a link to a config file for the device? I’m not personally extremely familiar with Terraform, although other team members are. I’m asking so that we can capture as much as possible of your request.

If my understanding above is correct, I’m not sure how how that would map exactly to the way Balena works. Devices do not have an image specific to the individual device somewhere on the cloud. Neither do they have a config file per se. Devices are flashed with an image that is preconfigured to point to your application / fleet. The configuration is managed between the device itself and Balena cloud. (There is a config file that lives on the device only that controls some specific things, but does not control the device state)

Please let me know if I’m on the right track or not.

---

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 22, 2021, 11:17am UTC](https://forums.balena.io/t/terraform-provider/337405/17 "2021-07-22T11:17:51Z")

</div>

@toochevere When you add a new device, there are downloads for the OS and config files you mentioned. Those are what I would expect to be in the device attributes.

 ![image](https://global.discourse-cdn.com/balena/original/2X/1/17bc3935c8892e0a02abcd366e1dded118cfe07f.png)

---

<div class="post-metadata">

**Author:** ![cmfcruz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cmfcruz/32/6878_2.png) [@cmfcruz](https://forums.balena.io/u/cmfcruz)\
**Post date:** [July 22, 2021, 1:33pm UTC](https://forums.balena.io/t/terraform-provider/337405/19 "2021-07-22T13:33:41Z")

</div>

Hi @nmcauliffe, defining a device as a “device resource” would seem like [preregistering a device](https://www.balena.io/docs/learn/more/masterclasses/advanced-cli/#52-preregistering-a-device) into the fleet. The JSON configuration file for that device could then be retrieved from the attributes, written to a JSON text file, and used with the balena CLI to configure & flash an image. On the other hand, there can be a “fleet data source” that allows you to obtain the same configuration file but not specific to a device UUID and does not pre-register any device. Let us know what you think about this approach.

We don’t have existing plans or resources to support Terraform for balenaCloud. We also have to consider that this should support openBalena as well. However, we do allow community members to take over projects like these and we may help give guidance in making sure that it works well with the balena ecosystem.

---

<div class="post-metadata">

**Author:** ![nmcauliffe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nmcauliffe/32/6245_2.png) [@nmcauliffe](https://forums.balena.io/u/nmcauliffe)\
**Post date:** [July 22, 2021, 2:18pm UTC](https://forums.balena.io/t/terraform-provider/337405/22 "2021-07-22T14:18:08Z")

</div>

I think both the `fleet` and `device` resource could be helpful depending on the scenario.

- Example 1: Deploying a fleet of cattle that behave more like an auto scaling group.
- Example 2: Deploying a fleet of pets that are assigned specific sites.

---

<div class="post-metadata">

**Author:** ![philT](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/philt/32/3070_2.png) [@philT](https://forums.balena.io/u/philT)\
**Post date:** [August 10, 2022, 10:31am UTC](https://forums.balena.io/t/terraform-provider/337405/24 "2022-08-10T10:31:49Z")

</div>

Bump

Keen to get the skinny on Terraforming all-the-Balena-things

Hopefully things have moved on

---

<div class="post-metadata">

**Author:** ![alekspickle](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alekspickle/32/8819_2.png) [@alekspickle](https://forums.balena.io/u/alekspickle)\
**Post date:** [June 19, 2023, 1:31pm UTC](https://forums.balena.io/t/terraform-provider/337405/25 "2023-06-19T13:31:00Z")

</div>

I don’t see it’s getting better. Let’s say I want to start writing tf-balena-provider.  
Would it make sense to use balena org for that? or a public repo should suffice licence-wise?
