From Jamf Console to Code, Part 2: Terraform Concepts for Jamf Administrators
Resources, providers, variables, state, plans, and applies—translated into the world of Jamf Pro. Learn how Terraform's core concepts fit the objects and workflows you already know.
Resources, providers, variables, state, plans, and applies, translated into the world of Jamf Pro.
Terraform can look like a new language at first. The core ideas are familiar to Jamf admins: describe an object, provide the values it needs, connect it to other objects, and review a proposed change before it happens.
In the first post, we looked at why managing selected Jamf Pro configuration as code can make changes easier to review and repeat. Before building a project, it helps to get comfortable with the vocabulary.
Terraform uses a handful of concepts to describe infrastructure and manage its lifecycle. If you already manage policies, profiles, Smart Groups, and scopes in Jamf Pro, you have a useful mental model to start with.
Start with the map
| Terraform term | A useful Jamf Pro comparison |
|---|---|
| Provider | The integration Terraform uses to communicate with Jamf Pro |
| Resource | A Jamf object Terraform is configured to manage |
| Data source | Information Terraform reads about an existing object |
| Variable | An input value, such as a category ID or tenant URL |
| Local value | A named expression used to simplify configuration |
| Output | A value made available to another module or the calling configuration |
| State | Terraform’s record associating configuration with managed objects |
| Plan | A preview of proposed changes |
| Apply | The operation that carries out a reviewed plan |
| Module | A reusable collection of Terraform configuration |
These comparisons are guides, not exact one-to-one mappings. Terraform manages what its provider supports and what you explicitly configure; it does not automatically take ownership of every object in your Jamf tenant.
Provider: the connection to Jamf Pro
Terraform core does not know how to create a Jamf policy or read a configuration profile by itself. A provider supplies that service-specific integration. For this series, we’re using the Jamf Platform provider (jamf/jamfplatform). Its Jamf Pro resources use the jamfplatform_pro_* prefix and let Terraform manage supported Jamf Pro configuration through the Jamf Platform API.
A provider configuration tells Terraform how to connect to the target service. In a Jamf Pro project, that can include the base URL, environment identifier, and credentials. Those values should come from protected inputs or environment variables, not be hard-coded into a file that is committed to Git.
Provider versions matter. The provider determines which resources, arguments, and behaviors are available, so pinning and intentionally updating the version helps keep changes predictable. Always check the provider documentation for the version your project uses.
A provider’s coverage is not the same as Jamf Pro’s full feature set. Before deciding to manage an object with Terraform, confirm that the resource or data source exists and supports the configuration you need.
Resource: a managed Jamf object
A resource is a block of configuration that tells Terraform to manage a particular kind of object. Depending on provider support, that might be a policy, a category, or a configuration profile.
Terraform gives each resource block a local address. For example, an address might look like jamfplatform_pro_policy.install_chrome:
jamfplatform_pro_policyis the resource type supplied by the provider.install_chromeis the name you choose for this block in Terraform.
That address is not the Jamf display name and is not necessarily the Jamf object ID. Think of it as Terraform’s label for the object in this configuration. The resource arguments describe the Jamf settings Terraform should manage.
This distinction is useful when reading code. A Terraform address can be concise and stable for the codebase, while the Jamf display name remains meaningful to administrators in the console.
A resource block does not necessarily mean Terraform will create a brand-new Jamf object. Existing objects can be brought under Terraform management through an import workflow. That process needs care and gets its own post later in the series.
Data source: read, don’t manage
Sometimes configuration needs information about an object that already exists, but you do not want this Terraform project to own its lifecycle. A data source lets Terraform read supported information and use it elsewhere in the configuration.
For example, one project might manage a policy while reading a category created and maintained by another team. Whether that is possible depends on the provider’s available data sources and the identifier they require.
A practical rule of thumb:
- Use a resource when this configuration should manage the object’s lifecycle.
- Use a data source when this configuration only needs to look up supported information about an existing object.
Using a data source does not give Terraform ownership of that object.
Variables and local values: inputs and working notes
A variable is an input to your configuration. In Jamf work, useful inputs might include a tenant URL, category IDs, script IDs, or a name that differs between environments.
For example, a module could accept a map of category IDs instead of embedding an ID in every resource. The environment configuration supplies the map, and resources inside the module refer to the appropriate entry. This makes the dependency visible and avoids scattering the same value through multiple files.
Local values are named expressions within a module. They can make repeated values or longer expressions easier to read. They are not inputs that a user must supply, and they are not a separate Jamf object.
Keep secrets out of ordinary committed variable files. Terraform has ways to mark values sensitive in output, but that marking alone does not remove sensitive values from state. Credential handling and state protection deserve a careful treatment, which we’ll cover in a later post.
Outputs: values another part of the configuration can use
An output exposes a value from a module or root configuration. A module that creates a Smart Group might output its ID so another module can use it when configuring policy scope.
Conceptually:
1
2
3
4
5
6
7
Smart Group resource
|
v
Output: smart_group_id
|
v
Policy scope input
This is how Terraform configuration can express dependencies between Jamf objects without asking an administrator to copy an ID from the console and paste it into several places. Outputs can also present useful values after an apply. They should not be used to print credentials or other sensitive values.
State: Terraform’s connection between code and objects
Terraform configuration describes what you want managed. State records Terraform’s association between resource addresses and the remote objects it manages, along with information Terraform uses to plan future changes.
A simplified example:
1
2
3
Terraform address: jamfplatform_pro_policy.install_chrome
is associated with
Jamf object: the policy Terraform manages in this tenant
State is important, sensitive operational data. It is not a substitute for the configuration, and it is not by itself a complete backup of your Jamf environment. Treat it as protected data, store it using an appropriate backend, and make sure only authorized people and automation can access it.
If you are managing an existing tenant, do not assume that writing a resource block automatically connects it to an existing Jamf object. Import and reconciliation are deliberate steps. We will cover those separately rather than risk an accidental create, update, or deletion.
Plan and apply: preview, then make the change
Terraform’s core workflow is often summarized as write, plan, apply.
- Write configuration describing the resources and values you want Terraform to manage.
- Plan asks Terraform to compare the configuration with its state and the information available from the provider, then show proposed actions.
- Apply carries out the proposed actions against the target environment.
A plan might report that Terraform will create a resource, update one, replace one, or destroy one. Review those actions against the intent of the change and its Jamf impact. A plan is an important review aid, but it does not understand your organization’s operational context or determine whether a scope is appropriate.
Applying is the step that changes the remote environment. For production, teams commonly put additional review or approval controls in front of it. The exact workflow depends on the team’s risk tolerance and tooling.
terraform validate is useful, too, but it answers a narrower question: is the configuration structurally valid for Terraform and the initialized providers? It does not prove that the credentials work, that a target Jamf object behaves as expected, or that a plan is safe to apply.
Module: a reusable group of configuration
A module is a collection of Terraform configuration that can be called from another part of a project. It can group a related set of resources and define a consistent interface using variables and outputs.
For example, a team could organize policy resources in one module, then call that module from its development and production environment configurations. Modules can reduce duplication, but they also introduce an interface to maintain. Start with clear, repeated patterns rather than wrapping every single resource in an abstraction.
Putting the pieces together
Imagine a project managing one application installation policy:
- The provider connects Terraform to the intended Jamf environment.
- The resource describes the policy.
- Variables provide environment-specific values, such as a category ID.
- A data source could read an existing object if the provider supports that lookup and the project should not manage it.
- An output could expose a value another module needs.
- State records which Jamf object Terraform associates with the resource address.
- A plan shows proposed actions.
- An apply performs the approved change.
The next time you see Terraform configuration, try to identify those pieces before reading every argument. Ask: what object is being managed, where do its inputs come from, and what would Terraform change?
Try it
Open a Terraform project or one of the provider’s documented examples and identify:
- One provider block and the target environment values it uses.
- One resource type and its Terraform address.
- Any variables or outputs connecting it to other configuration.
- Where state is configured and protected.
- How a plan is reviewed before an apply.
You do not need to run an apply for this exercise. The goal is to become comfortable tracing the path from configuration to a proposed Jamf change.
In the next post, we’ll create a small Jamf Pro Terraform project, configure the provider, and walk through initialization, validation, and a first plan.