# Terraform GCP emulator workflow

> Validate Terraform against LocalCloud GCP emulator endpoints before production, without default GCP credentials or cloud billing.
>
> Source: https://local.cloud/workflows/terraform-gcp-emulator/

Terraform

LocalCloud can provide local endpoint overrides for Terraform validation. Use it to catch resource wiring mistakes before a real Google Cloud plan or apply.

[Read docs](https://local.cloud/docs/) [Check compatibility](https://local.cloud/compatibility/) [SDK examples](https://local.cloud/docs/sdk-examples/)

Fact

Use the Terraform env export endpoint.

Fact

Keep real provider credentials out of local validation.

Fact

Run real GCP plan/apply only as a separate production gate.

Endpoint export

## Generate local provider overrides

Use the LocalCloud Terraform export endpoint to set local service endpoints. Keep those overrides scoped to the local shell or CI job that runs the validation.

Agent instruction

## Ask for the smallest plan first

Have the agent identify used Google provider resources, export LocalCloud endpoints, and run the narrowest local Terraform validation before proposing broader IaC changes.

Copy-ready setup

## Commands and prompts

### Copy a prompt for your coding agent

#### Configure internal CI

Have an agent add a permitted non-production LocalCloud CI workflow.

```
Read https://local.cloud/docs/licensing/ before changing this automation. Keep the workflow within the Public Preview License's non-production boundary. Propose the smallest change that starts LocalCloud, waits for readiness, exports emulator env vars, runs integration tests locally, and avoids real GCP secrets.
```

#### Configure this repo

Have an agent wire an existing project to LocalCloud safely.

```
Set up this repository to use LocalCloud for local GCP development. First read https://local.cloud/ai/agents.md, then inspect this repo, identify the GCP services and SDK language, configure emulator environment variables, and run the narrowest integration test against localhost. Do not use real GCP credentials or production endpoints.
```

Terraform local setup

```
localcloud env --format terraform
export GOOGLE_APPLICATION_CREDENTIALS="$PWD/.localcloud/fake-service-account.json"
curl -fsS http://localhost:5380/terraform/readiness?mode=endpoint
terraform init
terraform plan
```

Production boundary

## Before production

Use LocalCloud for non-production development, testing, and CI under the [Public Preview License](https://local.cloud/license/), check [each service's local boundaries](https://local.cloud/compatibility/), and validate against real Google Cloud before you deploy.

- Terraform provider behavior that depends on IAM, org policy, quotas, or regional managed services still needs real Google Cloud validation.

Related

## Next steps

- [Terraform docs](https://local.cloud/docs/terraform/) — LocalCloud Terraform setup details.
