0
0
Terraformcloud~30 mins

Multiple provider configurations in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Multiple provider configurations
📖 Scenario: You are managing infrastructure across two different cloud providers: AWS and Azure. You want to configure Terraform to connect to both providers in the same project.
🎯 Goal: Create a Terraform configuration that sets up two provider blocks: one for AWS and one for Azure, each with an alias. Then create a resource in each provider using the correct provider alias.
📋 What You'll Learn
Configure the AWS provider with alias aws_east and region us-east-1
Configure the Azure provider with alias azure_west
Create an AWS S3 bucket resource named aws_bucket using the aws_east provider
Create an Azure resource group named azure_group using the azure_west provider
💡 Why This Matters
🌍 Real World
Many companies use multiple cloud providers. Knowing how to configure Terraform to manage resources across them is essential.
💼 Career
Cloud engineers and DevOps professionals often manage multi-cloud environments and need to write Terraform code that handles multiple providers.
Progress0 / 4 steps
1
Set up AWS provider with alias
Write a Terraform provider block for AWS with the alias aws_east and set the region to us-east-1.
Terraform
Need a hint?

The alias attribute lets you name this provider configuration so you can use it later.

2
Add Azure provider with alias
Add a Terraform provider block for Azure with the alias azure_west and include the required features {} block.
Terraform
Need a hint?

Azure provider requires a features {} block even if empty.

3
Create AWS S3 bucket using aliased provider
Create a resource block for an AWS S3 bucket named aws_bucket. Use the provider alias aws_east by specifying provider = aws.aws_east.
Terraform
Need a hint?

Use provider = aws.aws_east to tell Terraform which provider alias to use for this resource.

4
Create Azure resource group using aliased provider
Create a resource block for an Azure resource group named azure_group. Use the provider alias azure_west by specifying provider = azurerm.azure_west. Set the resource group name to myResourceGroup and location to westus.
Terraform
Need a hint?

Use provider = azurerm.azure_west to assign the resource to the Azure provider alias.