Set up the provider
Use Terraform 1.11 or later. In the Opper dashboard, select the organization you want to manage and create a key under Settings → API Keys → Management keys. The management key determines which organization Terraform manages. Give the keyprojects:read to refresh or import projects and
projects:write to create or update them. Grant projects:delete only to
operators who need to delete projects. For a CI job that only runs plans, use a
separate key with the read scopes for the resources in your configuration.
Set OPPER_MANAGEMENT_API_KEY in your shell or inject it from your CI secret
store. The provider expects a management key (op-mak-…). Applications use a
separate runtime key (op-…) for inference. Keep credentials out of HCL and
version control.
Save the following as main.tf in an empty directory. Choose a unique project
name in the organization. The example creates a project with Organization
access. If the project needs to start out Restricted, set initial_access
before applying and grant the key project_access:write in addition to
projects:write.
main.tf
terraform apply when you’re ready to
create it, and review the proposed change at the confirmation prompt.
Import an existing project
To adopt a project you already have, start in an empty directory with theterraform and provider blocks from the example. Add the resource and import
blocks below, using the project’s current name, description, and UUID. Leave
initial_access out, and make sure no other Terraform state manages the project.
If you’re adding the project to an existing Terraform configuration, use an
unused resource address and match it in the import block.
terraform init and terraform plan. If your goal is adoption without a
configuration change, look for 1 to import, 0 to add, 0 to change, 0 to
destroy. Fix any unexpected differences before running terraform apply. A
key with projects:read is enough for this import-only plan and apply. Run
terraform plan again to check for a clean plan.
To look up a project by UUID without managing it, use the
opper_project data source.
State and credentials
For shared environments, use an encrypted, access-controlled remote state backend with locking. Commit.terraform.lock.hcl so CI and local runs select the
same provider version. Restrict access to saved plan files as well as state.
The runtime key resource
manages project-owned keys. Terraform hides newly minted runtime secrets in
normal CLI output and stores them in state. Import recovers key metadata only.
Keep personal keys outside Terraform.
What you can manage
For each resource, check the provider reference
for its management-key scopes, import format, and plan requirements.
To manage a project’s access policy after creation, import it separately as
an
opper_project_access resource.
For a larger configuration, see the
complete example.