Understanding the AWS Provider for Terraform

Reading material and code examples

Table of Contents

Reading material

This section is a collection of links that will help you make the most of today's session.

HashiCorp Configuration Language

Terraform Basics

Docker Provider for Terraform

AWS Provider for Terraform

Code Quality

Before plan and apply, always clean up your code:

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.

Visualizing resources

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.

Importing resources

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

Modules

Author Information

This repository is maintained by Kerim Satirli.

License

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.