Skip to Content
DocsVirtual CloudOverview

Virtual Cloud Emulator

InfraSpec includes a built-in AWS emulator called Virtual Cloud that lets you test your infrastructure code instantly without provisioning real AWS resources. It runs locally, requires no setup, and is completely free.

Why Use the Emulator?

Testing infrastructure against real AWS is expensive, slow, and risky:

  • High costs - Every API call costs money, test resources get forgotten
  • Slow feedback - Network latency means seconds per operation
  • Cleanup headaches - Failed tests leave orphaned resources
  • Security concerns - CI/CD pipelines need AWS credentials
  • Rate limits - AWS throttles API calls during heavy testing

The Virtual Cloud emulator solves all of these problems.

Key Benefits

Fast

Tests run in milliseconds. No network latency, no API rate limits, instant feedback.

Free

The emulator is built into InfraSpec. No AWS costs, no subscriptions, no limits.

Zero Setup

No Docker, no configuration, no credentials. Just run your tests.

No Cleanup

Everything is ephemeral. Resources disappear when tests finish.

How It Works

The emulator starts automatically when you run InfraSpec. It intercepts Terraform’s AWS API calls and responds with realistic AWS behavior.

Install InfraSpec

brew install infraspec # or go install github.com/robmorgan/infraspec@latest

Run Your Tests

infraspec features/

That’s it! The emulator handles everything automatically.

The emulator is the default behavior. To test against real AWS instead, use the --live flag: infraspec --live features/

Supported AWS Services

Virtual Cloud emulates the most commonly used AWS services for infrastructure testing. See the AWS Compatibility page for detailed coverage information.

CI/CD Integration

The emulator works seamlessly in CI/CD pipelines with no special configuration:

.github/workflows/test.yml
name: Infrastructure Tests on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install InfraSpec run: | curl -fsSL https://infraspec.sh/install.sh | bash - name: Run Tests run: infraspec features/

No AWS credentials needed. No environment variables to configure. Just install and run.

Comparison with LocalStack

Already using LocalStack? Here’s how Virtual Cloud compares:

FeatureVirtual CloudLocalStack
SetupBuilt-in, zero configDocker + configuration
Testing FrameworkIncluded (BDD/Gherkin)Bring your own
Infrastructure Assertions100+ built-inWrite your own
AWS Parity TrackingWeekly via CloudMirrorWeekly
FocusInfrastructure testingGeneral AWS emulation
CostFreeFree tier + paid

Virtual Cloud is purpose-built for testing infrastructure code. If you need general AWS development, LocalStack may be a better fit. For infrastructure testing with InfraSpec, Virtual Cloud provides a more integrated experience.

Staying Current with AWS

AWS releases hundreds of API changes every year. Virtual Cloud stays current through CloudMirror, which automatically tracks the AWS SDK and identifies new operations weekly.

This means you get up-to-date AWS behavior without waiting for manual updates.

FAQ

How accurate is the emulator?

Virtual Cloud provides high-fidelity emulation of AWS APIs for infrastructure testing scenarios. It accurately models resource creation, validation errors, and state management. For edge cases or advanced features, use --live to validate against real AWS.

Can I test against both the emulator and real AWS?

Yes! Use the emulator for fast iteration during development, then validate with --live before deploying:

# Fast feedback during development infraspec features/ # Validate against real AWS before deploy infraspec --live features/

What if I need an unsupported operation?

Check the compatibility page for current coverage. If you need an operation that’s not supported, you can:

  1. Open an issue on GitHub
  2. Contribute the implementation (see CloudMirror for guidance)
  3. Use --live for tests that require that operation

Does it support Terraform state?

Yes. The emulator works with Terraform’s normal state management. State is stored locally and cleared between test runs.

Next Steps

Last updated on