Reading material and code examples
This section is a collection of links that will help you make the most of today's session.
- repository: hashicorp/hcl
- CLI commands terraform.io/docs/commands/index.html
- variables and type constraints: terraform.io/docs/configuration/variables.html
- variable definition files: terraform.io/docs/configuration/variables.html
- information about Terraform State: terraform.io/docs/state/index.html
- ChangeLog on GitHub
- documentation:
- for the provider can be found on terraform.io/docs/providers/docker
- for the
docker_image
resource can be found on terraform.io/docs/providers/docker/r/image.html - for the
docker_container
resource can be found on terraform.io/docs/providers/docker/r/container.html
- releases weekly
- ChangeLog on GitHub
- documentation:
- for the provider can be found on terraform.io/docs/providers/aws
- for the
aws_instance
resource can be found on terraform.io/docs/providers/aws/r/instance.html - for the
aws_ebs_volume
resource can be found on terraform.io/docs/providers/aws/r/ebs_volume.html - for the
aws_volume_attachment
resource can be found on terraform.io/docs/providers/aws/r/volume_attachment.html
- Learn Guide: Build infrastructure learn.hashicorp.com/terraform/getting-started/build
- Build your own AMIs with Packer: packer.io/docs/builders/amazon/
Before plan
and apply
, always clean up your code:
- use terraform fmt to rewrite Terraform configuration files to a canonical format and style.
- use terraform validate to validate the configuration syntax and internal consistency
- use pre-commit to run more checks
- community member @antonbabenko/ built and maintains pre-commit-terraform
For more advanced use-cases, have a look at tflint. This application can alert you to provider-specific issues such as defining a non-existant t12.micro
instance type.
Visualize Terraform-managed resources using the terraform graph
command:
terraform graph \
| dot -Tpng > "infrastructure.png"
This uses the dot
library to render the .digraph
file into a PNG image (infrastructure.png
).
blast-radius from Patrick McMurchie is another great way of visualizing your resources.
- use the terraform import command:
Create a resource in your Terraform code:
resource "aws_s3_bucket" "hug_demo" {
bucket = "hug-demo"
}
Then run the terraform import
command:
terraform import \
aws_s3_bucket.hug_demo "hug-demo"
specify the Terraform-native resource (aws_s3_bucket.hug_demo
) as well as the provider resource (hug-demo
)
- use Terraformer for importing large sets of resources
- use modules as building blocks
- module documentation: terraform.io/docs/configuration/modules.html
- module registry: registry.terraform.io
- Learn Guide: Modules on learn.hashicorp.com/terraform/modules/modules-overview
This repository is maintained by Kerim Satirli.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
See the License for the specific language governing permissions and limitations under the License.