Best infrastructure as code tools for AWS

OpenTofu and a self-run Terraform CLI can keep state and locks in an S3 bucket in your AWS account. HCP Terraform is a multi-tenant SaaS with customer data stored in the United States and no choice of hosting location, so it fits only where that is acceptable.

On this page

Which infrastructure as code tools for AWS keep state in your account

A team that wants state, locks and plan or apply runs to stay under its own AWS account control can run OpenTofu or Terraform from its own runners and point them at an S3 backend in its account, while HCP Terraform is a multi-tenant SaaS that stores customer data in the United States and offers no hosting location choice. Terraform is licensed under the Business Source License 1.1, which is not an OSI open source license. HCP Terraform is a commercial service, and OpenTofu is MPL-2.0 open source. The OpenTofu S3 backend supports native locking through use_lockfile=true or DynamoDB locking, and the Terraform S3 backend stores state as a key in an S3 bucket. Confirm the bucket settings, versioning, encryption and IAM policy in your own account before the first run, because those controls are yours to configure.

HCP Terraform fits only where US storage of customer data is acceptable to your data owners and regulators. Remote state storage is included in every HCP Terraform tier, so state held there becomes part of the service data your reviewers will ask about. Self-hosted agents on EC2 or ECS Fargate are the option for keeping execution in your account. They change where runs execute, and the control plane, workspace and remote state stay with the service. Before you commit, ask HashiCorp in writing which hosting and data handling terms apply to your contract, and compare the answer with your data classification.

Which infrastructure as code tools for AWS still need a vendor connection

This table compares three ways to run infrastructure as code against AWS-hosted state: OpenTofu, HCP Terraform and self-run Terraform. Read each row for the state backend and run path first, then for what still reaches outside your account, including public registry downloads that apply to all three. The main takeaway is that OpenTofu and self-run Terraform keep state in your own S3 bucket, while HCP Terraform adds a hosted control plane with data stored in the United States.

OptionFit with AWS-hosted state and run pathWhat still needs a connection or vendor service
OpenTofuS3 backend with use_lockfile=true or DynamoDB locking, both documented as supported with no planned deprecation.No vendor service is required for state. Confirm the public registry downloads your runs need.
HCP TerraformMulti-tenant service. Self-hosted agents can run on EC2 or ECS Fargate, per HashiCorp's validated designs.Hosted control plane stores customer data in the United States, and customers cannot choose the location. Confirm residency fit.
Terraform (self-run CLI)S3 backend stores state as a key in an S3 bucket, with the CLI run from your own AWS account.Terraform 1.6.0 and later use Business Source License 1.1. Internal use is permitted, but confirm the terms with counsel.
Provider and module downloadsSame for all three options: runs pull providers and modules from public registries by default.Confirm which registries your network allows and whether a private mirror or module source is needed.

What an AWS-hosted state and run path demands from infrastructure as code

Any infrastructure as code tool on AWS must first put state in a bucket the team controls, and it must lock that state so two applies cannot write to it at the same time. OpenTofu documents an S3 backend that stores state in an S3 bucket and supports native locking through use_lockfile=true or DynamoDB locking, and it states that both methods are supported with no planned deprecation. Terraform's S3 backend also stores state as a key in an S3 bucket, so the bucket design is much the same for both. Before you commit, confirm which locking method the version you plan to run supports, then test a concurrent apply in a non-production account. Decide who owns the bucket, how it is encrypted and versioned, and which roles can read or overwrite the state object. OpenTofu's S3 backend documentation sets out the configuration keys to review.

Credentials and execution are the second decision. Runners should assume an IAM role and keep long-lived access keys out of stored variables, and that role should be scoped to the state bucket, the lock mechanism and the resources a plan touches. Where the runner executes matters as much as the role. HashiCorp's validated designs describe self-hosted agents running on virtual machines such as EC2 or on ECS Fargate, which keeps execution inside your own AWS account. Map every network path before go-live: runner to the AWS APIs, runner to the S3 endpoint that holds state, and runner to the provider and module sources. If runners sit in private subnets, confirm which egress route reaches each source. A blocked registry or module host usually fails a plan in a way that looks like a tool bug, so test that path during the pilot and log which principal assumed the role and when.

The control plane and the state location are separate decisions, and each needs its own answer. A tool can run inside your AWS account while a hosted service keeps run logs, variables or other metadata elsewhere. HCP Terraform is multi-tenant, stores customer data in the United States, and does not let customers choose a hosting location, according to HashiCorp's data location overview. An organization with a residency requirement should check that against its own rules before choosing it. For a self-managed or open-source deployment, confirm where the state bucket, run logs and stored variables physically live, which AWS region holds them, and who can read them. Put these questions to the vendor in writing and file the answers with the architecture review.

How OpenTofu, Terraform and HCP Terraform each fit an AWS account

OpenTofu and Terraform share a configuration language, so the choice turns on the license, who operates the control plane and where state and runs live. Each card gives the license label, the AWS account situation it fits and the case where it is the weaker pick.

OpenTofu

Licensed under MPL-2.0, with stewardship under the Linux Foundation and CNCF Sandbox acceptance on April 23, 2025. It fits an AWS account where the team wants an open-source license and runs its own workflow, storing state in an S3 bucket with native locking (use_lockfile=true) or DynamoDB locking, both documented as supported. It is the weaker choice when the team depends on a vendor-run service or on a Terraform-only feature it has not confirmed in OpenTofu, so test provider and module compatibility before migrating.

OpenTofu S3 backend

Terraform CLI

Licensed under the Business Source License 1.1 for version 1.6.0 and later, with IBM named as licensor. Internal use fits an AWS account: the license states that running Terraform for internal purposes within an organization is not a competitive offering, so a team managing its own accounts can use it in production. It is the weaker choice if you plan to offer Terraform to third parties on a paid basis, including through paid support, in a way that overlaps with IBM's paid versions. Each version converts to MPL 2.0 four years after publication, which matters if you pin older versions.

HCP Terraform

A commercial SaaS with Essentials, Standard and Premium tiers, listed at $0.10, $0.47 and $0.99 per resource per month according to the HashiCorp pricing page. It fits an AWS account when the team wants remote runs, VCS connections, a private registry and team management without operating the control plane, and it can run self-hosted agents on EC2 or ECS Fargate so runs execute inside your own AWS environment. It is the weaker choice where customer data must stay in a location you choose, because the service stores customer data in the United States and customers cannot pick the hosting location.

HCP Terraform overview

Terraform Enterprise

A self-managed edition of Terraform on custom pricing, with license and deployment terms to confirm with HashiCorp before you plan an AWS deployment. It fits an AWS account when policy requires the control plane, state and run data to sit inside your own accounts, and the team has the platform skills to install, upgrade and back it up. It is the weaker choice for a small team without platform operators, or when license and deployment terms are not yet confirmed in writing. Ask for the deployment architecture, upgrade path and support scope in the quote.

Where state, locks and run data sit in an AWS account

The diagram starts at a workstation or CI job that passes credentials to a self-hosted agent on EC2 or ECS Fargate. The agent runs plan and apply inside the team's AWS account, reading and writing state in an S3 bucket and taking a lock with use_lockfile or DynamoDB. The HCP Terraform branch exists only if you choose that service: run logs go to a control plane in the United States, and run metadata and variables are shown alongside them. Confirm which data HCP Terraform stores when a workspace uses an external backend before you assume state is the only thing left in your bucket.

Runner, state and lock sit in your AWS account; HCP Terraform is optional.

Running each infrastructure as code option in AWS day to day

OpenTofu runs on runners your team operates, such as CI runners or a small pool of EC2 hosts in your own AWS accounts. Your team owns every layer: the OpenTofu version, the state bucket, the IAM policies and the hosts. OpenTofu is licensed under the Mozilla Public License 2.0, so internal use of an unmodified binary raises few license questions, but confirm with counsel what the license requires if you modify and redistribute OpenTofu itself.

  • Installing and pinning: Pin the OpenTofu version in the runner image and in required_version in each configuration, and commit the .terraform.lock.hcl file so provider versions are reviewed like code.
  • Upgrades and state: Read the OpenTofu releases notes for each version, then test the upgrade against a copy of production state in a non-production account before any runner moves.
  • Bucket, locking and IAM: Your team owns the S3 bucket, its versioning and encryption, and the IAM policy that scopes each runner to its own state key. The S3 backend supports native locking with use_lockfile = true or DynamoDB locking.
  • Monitoring runs and drift: Logs, plan output and drift checks are your build. A scheduled plan job that flags unexpected changes and sends alerts to your existing tooling is the common pattern.
  • Project status: OpenTofu is under Linux Foundation stewardship and was accepted to the CNCF at the Sandbox maturity level on April 23, 2025, which matters if procurement asks about governance.

Check who is on call when a runner or bucket policy breaks, and whether your change process covers OpenTofu version bumps.

What HCP Terraform adds to your AWS bill and what it does not cover

HCP Terraform adds a subscription fee on top of the AWS resources you already pay for, and that fee scales with how many resources it manages. HashiCorp's pricing page lists HCP Terraform Essentials at $0.10 per resource per month ($0.00013 per hour), Standard at $0.47 per resource per month and Premium at $0.99 per resource per month. Terraform Enterprise (self-managed) and HCP Terraform Europe are custom priced, so they need a written quote. Before you compare tiers, count the resources in your current Terraform state and confirm with HashiCorp which objects count, since a single VPC with many subnets, route tables and security groups may add many resources. Standard and Premium add features such as unlimited module publishing and change requests that Essentials lacks, so price the tier that includes the features your teams will use.

Most of the one-time cost falls on the AWS foundation and the code, not on the subscription. Your team or a partner designs the state bucket, its encryption and versioning, and the IAM policies that let runners read and write only their own state keys. You also plan how state is split into stacks, move existing state into the new backend and rework modules. These costs stay the same whichever HCP Terraform tier you choose. Recurring costs are the per-resource fees, compute for self-hosted agents (HashiCorp's self-hosted agents guide describes VMs such as EC2 or ECS Fargate), bucket storage for state and retained versions, log retention and the team hours spent on upgrades and plan review. Agent compute and logs grow with run volume and stack count, so ask how many agents you need at peak and whether one agent pool can serve several teams.

The subscription is not the whole AWS bill. HCP Terraform fees do not include S3 storage for state, DynamoDB locking tables if you use them, or the EC2 or Fargate capacity that runs agents. Take the AWS rates for storage, locking and agent hosts in your region from AWS pricing before you model the total, using your expected state size and run volume. OpenTofu's S3 backend supports native locking with use_lockfile=true as well as DynamoDB locking, so confirm which option your tool version uses before you size a DynamoDB table. In the quote, ask for the resource count basis with a worked example, the tier-by-tier feature list, whether Enterprise or Europe pricing applies, term and minimum commitments, support level, whether agents or logging are included, and how fees change if you later move between tiers or leave for OpenTofu.

Questions buyers ask before hiring help with infrastructure as code tools for AWS

Can Terraform or OpenTofu state stay in our own AWS account?

Yes, in most setups state can stay in a bucket in your own AWS account. OpenTofu documents an S3 backend that stores state in an S3 bucket, and locking is supported either with use_lockfile = true or with DynamoDB. Terraform has an S3 backend with the same basic model. Where state lives is only part of the answer. Bucket encryption, versioning, access policies, and cross-account roles for CI runners all need design and review, because state files often contain secrets. Residency rules matter too: confirm with your compliance team which Region the bucket and its logs must stay in, and check the backend syntax against the current OpenTofu documentation before you rely on it. OpenTofu S3 backend documentation

Do we need HCP Terraform if we already use OpenTofu?

No. HCP Terraform is an optional hosted service from HashiCorp, and OpenTofu can run from your CI system with an S3 backend in your own account without it. HCP Terraform adds remote runs, VCS connections, a private registry, secure variable storage and team management. Its paid tiers are priced per resource per month: Essentials at $0.10, Standard at $0.47 and Premium at $0.99, according to the HashiCorp pricing page. The service is multi-tenant, stores customer data in the United States and does not let customers choose a hosting location, so check that against your residency rules. Self-hosted agents can run on EC2 or ECS Fargate. Confirm with HashiCorp whether any HCP Terraform feature you need works with OpenTofu before you assume it does. HCP Terraform overview

How much effort does an AWS infrastructure as code setup take?

Effort depends mostly on scope, so ask for the estimate in writing before you compare options. The main drivers are the number of AWS accounts, the number of state files or workspaces, how many modules must be written or refactored, how many pipelines call them, and whether residency or change control rules add approval steps. A single account with a few stacks and an existing pipeline is a much smaller job than a multi-account landing zone with separate state per environment and a locked-down CI runner. Ask any partner to split the work into state backend setup, module and pipeline work, access controls and handover, with a deliverable for each. For each one, ask what it depends on from your side, such as account access, approvals and named reviewers.

Can our internal team run OpenTofu on AWS without an outside partner?

Often yes, if your team already writes Terraform or OpenTofu code, reviews IAM policies and runs CI pipelines. The harder parts are state design, locking and recovery, module ownership, tool and provider upgrades, and reviewing plans before they touch production. Ask whether at least two engineers can read a plan, debug a failed apply and recover from a locked state without outside help. The drivers are team size, how many workspaces need a named owner, and how often the platform changes. For a small team, a handover with written runbooks plus a retainer for upgrades and reviews may fit better than a one-time build. DeployOpen documents the platforms it implements and offers ongoing support, upgrades and continuous testing as retainers, so you can choose between a handover and continued support.

Does the Terraform license allow internal use, and does a consultant change that?

Terraform 1.6.0 and later are under the Business Source License 1.1, which permits internal use, but whether an outside consultant changes that needs counsel. The grant allows production use, and it states that hosting or using Terraform for internal purposes within an organization is not a competitive offering. The restriction targets offering Terraform to third parties on a hosted or embedded basis that competes with IBM's paid versions. The definition also covers paid support arrangements, so a paid service sold to others can matter. A consultant working on your own infrastructure is a different question from selling a Terraform-based product to others, but that distinction depends on the exact wording and on how the engagement is structured. Send the LICENSE file and your engagement terms to counsel. OpenTofu is licensed under MPL 2.0 and is an alternative if counsel prefers it.

What does a fixed-scope infrastructure as code engagement need from us?

A fixed-scope engagement needs a written scope, deliverables and timeline agreed before work begins, and a quote follows from that scope. DeployOpen does not publish a price list. In practice you will usually need to provide AWS account access for the accounts in scope, with an owner who can approve IAM and bucket changes; an inventory of existing stacks, state files and modules; access to your CI pipelines and a description of the runner model; residency and logging rules from your compliance team; and a named technical reviewer and sign-off decision maker. Ask for the stated assumptions and exclusions in the written scope, so an unclear dependency does not become a change request later. Ongoing support and upgrades are separate retainers.

How teams move from HCP Terraform or Terraform to OpenTofu on S3

The sequence moves state and runs from HashiCorp's hosted service or a Terraform backend into an S3 bucket in the team's own AWS account, with OpenTofu executing plans and applies. Each step closes with a check that confirms the state and plan are intact before the next step starts. Version and provider compatibility is confirmed in the team's own environment at every stage.

  1. Inventory workspaces and their backends

    The platform team lists every HCP Terraform workspace or Terraform root module, along with its current backend, state location, Terraform or provider version pins, variable sets, VCS triggers, run tasks and any self-hosted agent pool it uses. Someone with administrator access to the organization should own the list, and the security team should review it for anything that depends on HCP Terraform features, such as policy checks or the private registry, that the new setup must replace. The step is done when the inventory is signed off and every workspace has a named owner and a target S3 key.

  2. Back up state and confirm locking

    Export the current state from every workspace and store each file in an encrypted location that the migration does not touch, then record its checksum next to the workspace name. For Terraform S3 backends, note whether locking uses a DynamoDB table, since that is one of the two locking methods OpenTofu supports. For HCP Terraform workspaces, note that locking is handled by the service's run queue, which ends at cutover. The step is done when each backup opens as a readable state file and the locking method for every workspace is written down.

  3. Create the S3 bucket with required controls

    The cloud team creates a bucket in the team's own AWS account, enables versioning and default encryption, blocks public access and writes a bucket policy that limits reads and writes to the roles that run OpenTofu. Access logging and key management follow the team's written policy, and the compliance lead should confirm each control against that policy before any state moves. OpenTofu's OpenTofu S3 backend documentation describes native locking with use_lockfile=true and DynamoDB locking, both supported with no planned deprecation, so pick one and set it in the backend block. The step is done when a test state file can be written, read and locked by the CI role and is denied to an unauthorized role.

  4. Point backends at S3 and migrate state

    The platform engineer changes each root module's backend block to the S3 backend, with a unique key per workspace, then runs tofu init -migrate-state so OpenTofu copies the existing state into the bucket. The original state stays in its prior location until the plan in the next step passes, so a rollback only requires reverting the backend block and migrating back. Pause runs in HCP Terraform for the migrated workspaces so that no run writes to the old location. The step is done when tofu state list against the new backend matches the resource list recorded in the backup.

  5. Run plans to confirm no unexpected changes

    Run tofu plan against each migrated root module using the same variables and the same provider lock file, and expect no changes unless the team has already planned one. OpenTofu describes itself as a drop-in replacement that preserves existing workflows and configurations, but the team should confirm version compatibility and provider versions in its own environment, including the OpenTofu release it pins and every provider the modules call. Any unexpected diff, even a cosmetic one, stops the cutover until someone explains it. The step is done when every workspace shows a clean plan in the pipeline, with the plan output saved alongside the state backup.

  6. Retire remote runs and self-hosted agents

    Once every plan is clean, move applies into the team's CI system using the same role model that the S3 backend uses, then disable VCS-triggered runs and remote run queues in HCP Terraform. Drain and decommission any self-hosted agent pools, which may run on EC2 or ECS Fargate, and revoke the API tokens and variable sets that still hold cloud credentials. Export the workspace settings and variable lists before deleting anything, so the configuration history stays available for review. The step is done when a test change applies from CI, HCP Terraform creates no new runs, and the agents and tokens no longer appear in the organization's settings.

How DeployOpen helps teams set up infrastructure as code in AWS

DeployOpen plans, implements and documents self-hosted open-source platforms inside your own AWS accounts, data centers or air-gapped networks. For OpenTofu on AWS, that means reviewing state storage, locking, and how the code is run and reviewed before any work begins. Scope, deliverables and timelines are agreed in writing before work starts, so the tool choice and its boundaries are documented before the build begins.

How we scope

  • The written scope names the AWS accounts, regions and state backends covered by the IaC code.
  • Scope also records whether runs happen in your CI system, on self-hosted agents or from an operator workstation.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before any build work starts.

How we build

  • The build covers state backend setup on S3, with locking configured as the written scope specifies.
  • Modules, variables and pipeline steps are customized and integrated with your identity, secrets and logging tools.
  • Security settings such as IAM roles, least-privilege policies and secret handling are hardened and reviewed before handover.

How we hand over

  • Documentation covers repository layout, state backend configuration, run procedures and how to add a new AWS account.
  • Your team receives the code, runbooks and access model, with a review of who can apply changes to production.
  • Confirm with your auditors which change records and approval evidence they expect from the IaC pipeline.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the initial handover.
  • Upgrade planning covers OpenTofu or Terraform version changes and provider updates in your AWS environment.
  • Ask whether a retainer includes retesting of the pipeline and state access after each change to the code.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.