OpenTofu lets you declaratively manage your cloud infrastructure.
Go to file
Martin Atkins 7bee77bdd3 command: Start of propagating OpenTelemetry context
Several times over the years we've considered adding tracing
instrumentation to Terraform, since even when running in isolation as a
CLI program it has a "distributed system-like" structure, with lots of
concurrent internal work and also some work delegated to provider plugins
that are essentially temporarily-running microservices.

However, it's always felt a bit overwhelming to do it because much of
Terraform predates the Go context.Context idiom and so it's tough to get
a clean chain of context.Context values all the way down the stack without
disturbing a lot of existing APIs.

This commit aims to just get that process started by establishing how a
context can propagate from "package main" into the command package,
focusing initially on "terraform init" and some other commands that share
some underlying functions with that command.

OpenTelemetry has emerged as a de-facto industry standard and so this uses
its API directly, without any attempt to hide it behind an abstraction.
The OpenTelemetry API is itself already an adapter layer, so we should be
able to swap in any backend that uses comparable concepts. For now we just
discard the tracing reports by default, and allow users to opt in to
delivering traces over OTLP by setting an environment variable when
running Terraform (the environment variable was established in an earlier
commit, so this commit builds on that.)

When tracing collection is enabled, every Terraform CLI run will generate
at least one overall span representing the command that was run. Some
commands might also create child spans, but most currently do not.
2023-07-14 10:24:10 -07:00
.github Result of tsccr-helper -log-level=info -pin-all-workflows . (#33527) 2023-07-14 18:02:38 +01:00
.release [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
docs docs: Describe the plugin protocol encoding of refined unknown values 2023-05-24 13:48:16 -07:00
internal command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
scripts [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
testing/equivalence-tests [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
tools [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
version Update main branch version to 1.6.0 2023-05-15 10:37:27 -04:00
website Merge pull request #33433 from chaosaffe/fix-getcommand-helptext 2023-07-14 10:12:10 -07:00
.copywrite.hcl Configure copywrite to ignore more generated code 2023-04-26 16:47:54 -04:00
.gitignore Fix .gitignore terraform entry to be root-relative 2022-05-05 10:24:38 -04:00
.go-version Build with Go 1.20.4 2023-05-31 08:37:34 -07:00
.tfdev Remove revision from version command 2021-01-12 16:35:30 -05:00
BUGPROCESS.md Update BUGPROCESS.md 2023-03-18 17:14:20 -04:00
CHANGELOG.md update CHANGELOG.md 2023-06-28 14:02:11 -04:00
checkpoint.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
codecov.yml [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
CODEOWNERS Update codeowner of gcs backend to include Strategic Integrations team (#31848) 2022-09-27 21:38:52 +01:00
commands.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
copyright_headers.go build: Generate copyright headers automatically 2023-05-30 08:21:40 -07:00
Dockerfile [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
experiments.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
go.mod main: Optionally configure an OpenTelemetry OTLP exporter 2023-07-14 10:24:10 -07:00
go.sum main: Optionally configure an OpenTelemetry OTLP exporter 2023-07-14 10:24:10 -07:00
help.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
LICENSE [COMPLIANCE] Update MPL 2.0 LICENSE 2022-10-12 17:36:01 +00:00
main_test.go command: test plan -refresh= arg ordering (#33483) 2023-07-06 19:28:09 +01:00
main.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
Makefile chore: Update Digital Team Files (#32037) 2022-10-20 14:04:57 -04:00
plugins.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
provider_source.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
README.md Update README.md 2022-06-27 15:40:37 -04:00
signal_unix.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
signal_windows.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
telemetry.go command: Start of propagating OpenTelemetry context 2023-07-14 10:24:10 -07:00
tools.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
version.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
working_dir.go [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00

Terraform

Terraform

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

The key features of Terraform are:

  • Infrastructure as Code: Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

  • Execution Plans: Terraform has a "planning" step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.

  • Resource Graph: Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

  • Change Automation: Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

For more information, refer to the What is Terraform? page on the Terraform website.

Getting Started & Documentation

Documentation is available on the Terraform website:

If you're new to Terraform and want to get started creating infrastructure, please check out our Getting Started guides on HashiCorp's learning platform. There are also additional guides to continue your learning.

Show off your Terraform knowledge by passing a certification exam. Visit the certification page for information about exams and find study materials on HashiCorp's learning platform.

Developing Terraform

This repository contains only Terraform core, which includes the command line interface and the main graph engine. Providers are implemented as plugins, and Terraform can automatically download providers that are published on the Terraform Registry. HashiCorp develops some providers, and others are developed by other organizations. For more information, see Extending Terraform.

License

Mozilla Public License v2.0