This example exercises every resource type currently registered for Terraform Query and imports the discovered objects into disposable local Terraform state. It covers:
ona_announcement_bannerona_automationona_integrationona_github_app_integrationona_runnerona_runner_llm_integrationona_scm_integrationona_git_authenticationona_environment_classona_group_membershipona_team_membershipona_custom_domainona_groupona_teamona_sso_configurationona_terms_of_serviceona_oidc_configona_organization_policiesona_organization_role_assignmentona_projectona_warm_poolona_scim_configurationona_security_policyona_secretona_service_accountona_skill
The example only generates imports for objects that already exist and can be represented by the provider. To exercise the complete workflow, use an Ona organization containing at least one importable object of each type.
For a repeatable fixture, apply the local development loop first. Its default configuration creates runners, SCM integrations, an environment class, a project, and a warm pool. The import loop can also discover other matching objects in the organization, so review the generated configuration before applying it.
Git authentication is opt-in in the local development loop. Enable its
ona_git_authentication.devloop resource and supply the ephemeral personal
access token when you need a repeatable Git-authentication import fixture.
From the repository root, build the provider and configure a development override:
mkdir -p .bin
go build -o .bin/terraform-provider-ona .
cat >terraformrc <<EOF
provider_installation {
dev_overrides {
"gitpod-io/ona" = "${PWD}/.bin"
}
direct {}
}
EOF
export ONA_TOKEN="<service-account-or-personal-access-token>"
export ONA_HOST="${ONA_HOST:-https://app.gitpod.io}"
export TF_CLI_CONFIG_FILE="${PWD}/terraformrc"Do not commit .bin/, terraformrc, credentials, generated configuration,
plans, or Terraform state.
Run Query to generate resource blocks and identity-based import blocks for all
registered list resources. Set TF_VAR_group_membership_group_id to a
customer-managed group whose user and service-account memberships should be
included. Set TF_VAR_team_membership_team_id to a team whose user
memberships should be included:
export TF_VAR_group_membership_group_id="<group-id>"
export TF_VAR_team_membership_team_id="<team-id>"
terraform -chdir=dev/local-importloop query \
-generate-config-out=generated.tfAn organization-owned GitHub App can appear in both ona_integration and
ona_github_app_integration results. Keep only the dedicated resource and its
import block for each App; remove the matching generic resource and import
block before applying. Leave App credentials and credentials_version unset
when adopting existing Apps. See the resource guidance
for migration from an existing generic resource.
The dedicated Query uses the dashboard's App metadata comparison. An integration matching the shared definition's App ID, slug, and client ID is excluded even when its credentials were configured locally.
Review the generated configuration, then create and inspect the import plan:
terraform -chdir=dev/local-importloop plan \
-input=false \
-out=import.tfplan
terraform -chdir=dev/local-importloop show import.tfplanProceed only when the plan contains imports and no remote create, update, replace, or delete actions. Apply the saved plan and verify that the imported configuration is stable:
terraform -chdir=dev/local-importloop apply -input=false import.tfplan
terraform -chdir=dev/local-importloop plan -detailed-exitcode -input=falseThe final command exits with status 0 when the imported configuration is a
no-op. Status 1 means Terraform failed, while status 2 means Terraform still
proposes changes and the generated configuration or provider mapping needs
investigation.
Terraform Query is read-only. Applying the generated import blocks writes only
the local state in this directory, but that state then represents real remote
objects. When the local development loop supplied the fixtures, both directories
temporarily track the same objects. Never run terraform destroy from the
import loop.
Reset the import loop by removing its generated configuration, saved plan, and state together without running another plan or apply:
rm -f \
dev/local-importloop/generated.tf \
dev/local-importloop/import.tfplan \
dev/local-importloop/terraform.tfstate \
dev/local-importloop/terraform.tfstate.backupAfter removing the import-loop state, the local development loop remains the sole owner of its fixtures and can destroy them normally.
The list-resource coverage test fails when a future Query-enabled resource is
registered without a matching block in query.tfquery.hcl.