liveBook · Manning

AWS provider

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

The AWS provider is a Terraform provider that manages resources and data exposed by Amazon Web Services.

The AWS provider gives Terraform access to Amazon Web Services resources and data sources, such as an AWS instance. Configure its dependency and version in required_providers, then configure its AWS region in the provider block. section 2.1.3

Listing 2.1 Configuring required providers
terraform {                               #1
  required_providers {                    #2
    aws = {                               #3
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}
 
provider "aws" {                          #4
  region = "us-east-1"                    #5
}

Use this configuration to install the HashiCorp AWS provider at a compatible 5.x version and target the us-east-1 region. section 2.1.3

A practical AWS-provider workflow is:

  • Declare hashicorp/aws and constrain its version in required_providers; relying on automatic installation prevents explicit version selection and can allow breaking changes. section 2.1.3
  • Configure AWS credentials through the AWS CLI with aws configure, because the provider follows the standard configuration used by AWS tools such as Boto3 and the CLI. section 2.1.6
  • Run terraform init to download providers, terraform plan to inspect intended actions, and terraform apply after confirming the plan. section 2.1.6

Launching an AWS instance

With the provider configured, Terraform can read AWS data sources such as a VPC, AMI, and subnets, then plan creation of aws_instance.hello_world. Applying the approved plan creates the instance and reports its AWS ID.

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Explains dependency declaration, regional configuration, credentials, initialization, planning, and application, but not provider internals.
Examples
Uses an AWS instance with VPC, AMI, and subnet data sources, configured for us-east-1 and installed through Terraform initialization.
What it assumes
Assumes basic Terraform HCL familiarity and AWS account access, while introducing provider blocks and the required_providers dependency model.
What you can do after
Operate/configure Terraform to authenticate with AWS, install the provider, review a plan, and create AWS infrastructure.
How it connects
Connects required_providers, provider blocks, Terraform resources, data sources, AWS CLI, and Terraform plan and apply commands.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.