Providers in Terraform
- In this lecture, we will learn more about providers in Terraform
1. What is a provider?
- In Terraform a provider is a plugin that defines how to interact with a specific infrastructure platform.
- They are responsible for translating the Terraform configuration into API calls and managing the life cycle of the resources within the specified platform
- So they act as the bridge between Terraform and the target infrastructure
2. Supported platforms
- Terraform has a rich ecosystem of providers, that support various cloud providers, on-premises infrastructures and other services. Common examples include AWS, AZure and Google cloud platform (GCP) and more
- Each provider supports a set of resource types, representing the various infrastructure components you can manage. For example, the AWS provider supports resource types like 'aws_instance', 'aws_s3_bucket' and so on.
- we will see later how to view the list of resource types supported by a specific provider
- in addition to resources, providers also offer data sources, which allow you to query and retrieve information from the infrastructure without creating new resources.
- Date sources are read_only and useful for gathering information about existing infrastructure
3. Providers classification
- providers in terraform can be classified into official, partner and community providers
- If you want to see the list of official providers, you can visit https://registry.terraform.io/browse/providers and then choise official and you will get the list of official providers
- Official providers are developed and maintain by thz Hashicorp team, the creator of terraform
- They are considered the primary and most widely supported providers, for various infrastructure platforms and services
- users can generally rely on official providers for their stability, regular updates and their comprehensive documentation
-for partner providers, they are developed and maintain by a technology partner in collaboration with hashicorp
- to view the list of partner providers, visit the same page and now keep only the partner choice checked
- these providers have met certain criteria for their level of quality and their compatibility, similar to official providers. and that's why they are recognized as trustworthy and supported within the terraform ecosystem
-and finally for the community providers, they are available in the same page, just now keep only the community checkbox checked
- community providers are developed by the broader terraform community, and are not directly maintained or supported by hashicorp
- these providers are contributed by individual developers or organizations who have specific use cases or requirements
- Hashicorp does not provide official support for community providers, and their maintenance and updates depend of the contributors
4. How to use a provider?
- let's now see how to use providers when working with terraform
- we saw previously, that after writing the configuration file, you have to run the terraform init command which will initialize your project directory and download the required providers based on the resource types mentioned in the configuration file
- you can list the providers required by the configuration using the terraform providers command. you see here that only the local provider is required
- By default, terraform will install the lastest version of the required provider. but if you want to use a specific version, you can specify the version that you want in the configuration file like that.
- so here, we add the terraform block and inside this block we add the required_provider block where we mention the required providers
- so here instead of using the latest version, we want to use the version 2.3.0 of the local provider and if we run the terraform providers command, we will see that the version 2.3.0 of the local provider is required for this configuration
You see more about Terraform providers in this video
Comments
Post a Comment