Terraform Cheat Sheet
Terraform cheat sheet
Categories:
2 minute read
Terraform cheat sheet
2 minute read
Terraform Cloud runs Terraform operations and stores state remotely, so you can use Terraform without worrying about the stability of your local machine, or the security of your state file.
less than a minute
Using Terraform modules can help promote code reuse, reduce duplication of effort, and improve maintainability of infrastructure code.
5 minute read
A Terraform provider is a plugin that enables Terraform to manage resources of a specific technology or service, such as cloud platforms, databases, or APIs, by exposing its resources and operations through a set of APIs.
2 minute read
Terraform state is a persistent data store that tracks the current state of infrastructure resources provisioned by Terraform, allowing it to manage changes and track resource dependencies.
less than a minute
To authenticate Terraform Cloud with Azure or AWS you can create an Azure SPN or AWS IAM user with the relevant permissions and then define the credentials as variables in the Terraform Cloud environment.
less than a minute
To authenticate Terraform Cloud with Azure or AWS you can create an SPM or IAM user in the cloud with the relevant permissions and then define the credentials as variables in the Terraform Cloud environment.
less than a minute
When you use Terraform Cloud with module and configuration files, the outputs from the module are captured and made available as output variables in the Terraform Cloud workspace. These output variables can then be used in other Terraform configurations or modules.
less than a minute
Projects are collections of related workspaces and, workspaces are logical environments that allow you to organize and manage your infrastructure code
less than a minute
Variable sets allow Terraform Cloud users to reuse both Terraform-defined and environment variables not just from root to child modules, but across certain workspaces or an entire organization.
less than a minute
Variable sets allow Terraform Cloud users to reuse both Terraform-defined and environment variables not just from root to child modules, but across certain workspaces or an entire organization.
2 minute read
How authentication works in Terraform
less than a minute
How authentication works in Terraform
less than a minute
Using the AWS CLI ~/.aws/credentials file.
less than a minute
How authentication works in Terraform
less than a minute
To authenticate Terraform with Azure, you can use Azure Active Directory (Azure AD) to generate a service principal (SPN), and then use the workstation CLI to configure the necessary environment variables for Terraform to access and manage Azure resources.
5 minute read
To authenticate Terraform with Azure, you can use Azure Active Directory (Azure AD) to generate a service principal (SPN), and then use the workstation CLI to configure the necessary environment variables for Terraform to access and manage Azure resources.
4 minute read
Checkov is a powerful tool for organizations that use IaC to provision their cloud infrastructure. By scanning configuration files for security misconfigurations, Checkov helps teams catch and fix potential issues before they become actual security incidents.
3 minute read
Terraform conditionals are expressions that allow you to dynamically set values based on the evaluation of specified conditions, enabling greater flexibility and adaptability in your infrastructure configuration.
2 minute read
Terraform console is an interactive command-line tool used to evaluate expressions and interpolate variables in Terraform configurations.
2 minute read
Used to manage the flow of code execution and control how resources or modules are created and configured.
less than a minute
An Azure Service Principal (SPN) is a security identity used by applications and services to access Azure resources.
2 minute read
Setting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables.
less than a minute
Stores small snippets of code or other types of data that can be easily referenced in the future
less than a minute
Terraform functions are built-in utilities that perform operations on data and metadata within the Terraform configuration files to enable dynamic and reusable configurations.
less than a minute
Creating a Terraform module involves defining input variables, output values, and one or more resource definitions that can be reused in other Terraform configurations.
12 minute read
A Terraform provider is a plugin that enables Terraform to manage resources of a specific technology or service, such as cloud platforms, databases, or APIs, by exposing its resources and operations through a set of APIs.
less than a minute
Terraform module inputs are variables that allow users to customize and parameterize the behavior of a module.
2 minute read
Installing a provider in Terraform involves specifying the required providers and their versions in the Terraform configuration, and then running terraform init
, which automatically downloads and installs the providers in your local environment.
2 minute read
Terraform state isolation ensures that each Terraform configuration maintains its own separate and independent state file to prevent interference or conflicts with other configurations.
4 minute read
Terraform module locals are variables that are used to simplify expressions or avoid repeating values within a module
2 minute read
Terraform state file locations can be configured to be stored locally on the machine running Terraform or remotely in a backend like Amazon S3, Terraform Cloud, or Azure Blob, enabling collaboration and sharing state across teams.
4 minute read
Terraform loops, implemented using count
or for_each
meta-arguments, allow the creation of multiple instances of a resource or module based on an integer count or items in a map or set, simplifying repetitive resource configurations.
8 minute read
Terraform modules are reusable configurations that can be called from other Terraform configurations.
less than a minute
Using multiple providers in Terraform involves specifying each required provider in your configuration file, each with its unique settings, allowing management of resources across different platforms or regions within the same configuration.
less than a minute
Using multiple providers in Terraform involves specifying each required provider in your configuration file, each with its unique settings, allowing management of resources across different platforms or regions within the same configuration.
2 minute read
Terraform module outputs are values that a module can return to the calling code to expose information about the resources it created or modified.
3 minute read
Terraform module paths refer to the hierarchical structure used to organize and reference resources within a Terraform configuration, facilitating resource management and interdependencies in infrastructure as code deployments.
2 minute read
Terraform preconditions are mechanisms used to assert certain states or conditions before executing Terraform operations, thereby enforcing the desired state and ensuring the integrity of the infrastructure-as-code deployment.
2 minute read
A Terraform provider is a plugin that enables Terraform to manage resources of a specific technology or service, such as cloud platforms, databases, or APIs, by exposing its resources and operations through a set of APIs.
less than a minute
Stores small snippets of code or other types of data that can be easily referenced in the future
2 minute read
Terraform secret management involves securely storing and accessing sensitive information, such as API keys or passwords, within Terraform configurations and workflows.
7 minute read
Terraform security involves implementing measures to protect the integrity, confidentiality, and availability of infrastructure-as-code deployments, including secure authentication, access controls, and vulnerability management.
less than a minute
Terraform state is a persistent data store that tracks the current state of infrastructure resources provisioned by Terraform, allowing it to manage changes and track resource dependencies.
less than a minute
Terraform remote state data source allows retrieving and using the current state of a Terraform-managed infrastructure from a remote backend as an input to other Terraform configurations.
less than a minute
Hard-coding credentials directly into the Terraform provider block.
less than a minute
Terraform state file locations can be configured to be stored locally on the machine running Terraform or remotely in a backend like Amazon S3, Terraform Cloud, or Azure Blob, enabling collaboration and sharing state across teams.
5 minute read
Stores small snippets of code or other types of data that can be easily referenced in the future
less than a minute
Terraform is an open-source infrastructure-as-code tool that allows developers to define and manage infrastructure resources, such as virtual machines, storage, and networks, in a declarative way. It provides a consistent, repeatable way to create and update infrastructure, and supports a wide range of cloud providers and services.
less than a minute
Terraform Cloud is a SaaS platform that provides collaboration, governance, and automation features for managing infrastructure as code with Terraform.
less than a minute
Automate creating README.md files for your Terraform code
2 minute read
Terratest is an open-source Go library that provides patterns and helper functions for testing infrastructure, with first-class support for Terraform, Docker, Packer, and other infrastructure-as-code tools, facilitating the writing and execution of automated tests to ensure the correctness and robustness of the infrastructure.
less than a minute
Terraform testing involves validating the infrastructure-as-code templates and configurations to ensure the provisioning and management of cloud resources function correctly
less than a minute
Terraform testing types primarily include unit testing, integration testing, and end-to-end testing, used to validate individual components, the interactions between components, and the complete functionality of the Terraform code respectively.
less than a minute
TFLint is a linter specifically designed for Terraform configurations.
2 minute read
Unit tests in Terraform are used to validate the behavior of individual resources or modules, ensuring that they function as expected when given specific input, thereby contributing to the robustness and reliability of the infrastructure as code.
less than a minute
Terraform validations are a set of checks performed on a Terraform configuration to ensure its correctness and adherence to best practices before executing the infrastructure-as-code deployment.
2 minute read
Terraform module versioning is a mechanism for managing changes and ensuring consistency of infrastructure deployments by assigning unique version numbers to modules.
8 minute read
4 minute read
Terraform’s “create_before_destroy” approach ensures that when updating an existing resource, a new version is first created before the old one is destroyed to minimize downtime and data loss.
2 minute read
This is a production site.