Export to infrastructure-as-code

Export a deployment plan as Terraform, YAML, or JSON, or turn existing AWS, Google Cloud, or Azure resources into native Terraform.

Everything you build with emma is real, portable infrastructure. This guide shows how to export it as infrastructure-as-code — so you can commit it, review it, or run it through your own pipeline. There's no lock-in: the prompt is a faster way to author, not a place your infrastructure gets trapped.

There are two different exports, and they produce different code:

Export a planExport existing resources
Starts froma deployment plan emma generatedresources that already exist
FormatsTerraform, YAML, or JSONTerraform only
Terraform provideremma's own (emma-community/emma)the cloud's own (hashicorp/aws, hashicorp/google, hashicorp/azurerm)
Cloudsany the plan targetsAWS, Google Cloud, and Azure only

Before you start you need something to export — a plan you've generated in the chat, or resources on AWS, Google Cloud, or Azure that emma can see on the diagram.

1. Export a whole plan

When emma has generated a deployment plan — the app you just deployed, say — ask for it as code. emma returns a single file in the chat, ready to copy: main.tf, deployment.yaml, or deployment.json.

Try this

Export this plan as Terraform

FormatGood for
Terraform (.tf)HCL pipelines, managing the plan's resources with emma's Terraform provider
YAMLDeclarative configs, GitOps
JSONProgrammatic consumption

Try this

Give me that as YAML instead

Run the plan's Terraform

The exported Terraform uses emma's own Terraform provider (emma-community/emma), which authenticates with an emma service application. Service applications are created in the emma portal (portal.emma.ms), in your project's Settings → Service Apps — not in the AI Console. See Developer API for creating one and Terraform provider for the provider itself.

Supply the service application's client ID and secret as the variables emma_client_id and emma_client_secret — in a terraform.auto.tfvars file or as TF_VAR_emma_client_id / TF_VAR_emma_client_secret — then run terraform init, terraform plan, and terraform apply.

2. Export existing resources as native Terraform

For resources already running on AWS, Google Cloud, or Azure, emma can write Terraform that uses that cloud's own provider. It covers VMs, Kubernetes clusters, volumes, security groups, and subnets, with a basic set of attributes (name, region, instance type, image, tags, SSH key). You pick one target cloud per export; resources on any other provider are skipped with a warning.

Try this

Export the web-prod VM as AWS Terraform

This Terraform describes resources that already exist. Running terraform apply on it as-is would try to create them again. Run terraform import for each resource first, so Terraform adopts what's there, then plan and apply.

What's next

How is this guide?

Last updated on 24 Sept 2026

On this page