When defining a provider in Terraform, what does the 'alias' meta-argument signify?
This is the core purpose of aliases.
Why this answer
An alias allows you to create multiple instances of a provider with different configurations (e.g., regions).
32 questions · Provider Management · All types, answers revealed
When defining a provider in Terraform, what does the 'alias' meta-argument signify?
This is the core purpose of aliases.
Why this answer
An alias allows you to create multiple instances of a provider with different configurations (e.g., regions).
Which meta-argument is used to explicitly associate a resource with a non-default provider instance?
The provider meta-argument selects the configuration.
Why this answer
The 'provider' meta-argument allows you to select a specific aliased provider configuration.
How do you pass a provider instance from a root module into a child module?
This is the correct way to pass aliased providers.
Why this answer
You use the 'providers' map in the module block to map the child module's provider requirements to a specific instance in the root module.
What is the primary function of the 'source' attribute in the 'required_providers' block?
Source provides the namespace and provider name.
Why this answer
It specifies the registry address where the provider binary can be downloaded.
What is the purpose of the 'terraform providers lock' command?
It ensures consistent provider versions across environments via checksums.
Why this answer
It updates the .terraform.lock.hcl file to include all necessary provider checksums for the current configuration.
A team wants to ensure their Terraform configuration uses a specific major version of the AWS provider to prevent breaking changes. Which block should they use?
This is the correct syntax for pinning provider versions.
Why this answer
The required_providers block within the terraform block is the standard way to constrain provider versions.
What are the ways to configure provider credentials? (Select THREE)
Standard method.
Why this answer
Environment variables, shared credentials files, and hardcoded provider blocks are all common ways to supply credentials.
What is the correct way to specify a version constraint for a provider that must be at least 3.0 but less than 4.0?
~> 3.0 allows any 3.x version.
Why this answer
The ~> operator (pessimistic constraint) with 3.0 allows for updates within the 3.x minor range.
Which of the following are valid provider version constraint operators? (Select TWO)
Used for exact version.
Why this answer
= and ~> are both standard operators for version constraints.
What happens if you have a provider version conflict in your module dependencies?
Dependency resolution failure prevents initialization.
Why this answer
Terraform will stop and return an error because it cannot satisfy the conflicting version constraints.
How does Terraform resolve the version of a provider if the version is defined in both 'terraform' block and the 'provider' block?
Required_providers in the terraform block is the correct place for versions.
Why this answer
The 'required_providers' block in 'terraform' is the authoritative source for version constraints; the 'provider' block configuration does not dictate versions.
If you want to use a provider that is not published in the Terraform Registry, how do you install it?
Filesystem mirrors allow local development or air-gapped installation.
Why this answer
Local provider mirrors can be configured by placing the binary in specific directory structures and using a CLI configuration file.
You need to manage resources in two different AWS regions using the same provider configuration. How do you achieve this?
The provider meta-argument links a resource to a specific aliased provider instance.
Why this answer
Using alias in the provider block allows you to define multiple configurations for the same provider.
Which are characteristics of the Terraform Plugin SDK? (Select TWO)
Core function of the SDK.
Why this answer
It handles the communication between Terraform and the provider binary, and it provides helper functions to define resources.
When writing a custom provider, what is the 'Schema' used for?
Schemas define the fields, types, and requirements.
Why this answer
The schema defines the data structure, types, and constraints for resources and data sources.
Which file is automatically generated to lock provider versions and their checksums?
This is the lock file for providers.
Why this answer
.terraform.lock.hcl is the dependency lock file.
Which of the following are valid ways to specify provider versions? (Select TWO)
This is the primary way.
Why this answer
Version constraints can be specified in the required_providers block and through CLI variables (though the latter is less common).
When debugging provider issues, which commands are most useful? (Select THREE)
Shows provider dependencies.
Why this answer
terraform providers, terraform init, and TF_LOG are the standard ways to troubleshoot provider issues.
If a resource is not specified with a provider meta-argument, which provider instance does it use?
Resources implicitly use the default provider configuration.
Why this answer
It defaults to the instance of that provider without an alias.
When using multiple provider instances with different regions, what must be defined in the provider configuration?
Alias is required to distinguish multiple instances of the same provider.
Why this answer
You must provide an alias for every provider instance except for the default one.
Where are providers physically stored by default when running 'terraform init'?
This is the default local cache directory.
Why this answer
Terraform downloads providers into the .terraform/providers directory within your project working directory.
Which command helps verify if the providers are properly initialized?
This command lists the initialized providers.
Why this answer
'terraform providers' lists all providers required by the configuration, confirming they are initialized.
Which of these are required components when defining a provider in 'required_providers'? (Select TWO)
Version is the standard requirement.
Why this answer
The source address and the version are the two standard components for defining a provider requirement.
Which block is used to configure provider-level settings like region or profile?
This is the block for provider-specific settings.
Why this answer
The 'provider' block is used to configure the provider itself.
A provider binary is not found in the local Terraform registry cache. What command should you run to force Terraform to download the provider again?
The -upgrade flag forces the re-download of providers based on constraints.
Why this answer
terraform init -upgrade forces Terraform to re-evaluate and download the latest allowed versions of providers.
If a developer wants to use a provider that is not in the public registry, can they still use it?
These are standard ways to handle private providers.
Why this answer
Yes, by using a custom provider installation method like the filesystem mirror.
What is the effect of running 'terraform init -upgrade' on the '.terraform.lock.hcl' file?
This is the correct function of the upgrade flag.
Why this answer
The -upgrade flag causes Terraform to ignore existing lock file constraints and update to the latest compatible versions, updating the lock file accordingly.
If a user omits the 'version' in 'required_providers', what version does Terraform use?
Without a constraint, the latest is pulled.
Why this answer
Terraform will attempt to use the latest version available in the registry if no constraint is provided.
What are common reasons to use multiple provider instances? (Select TWO)
This is a standard use case.
Why this answer
Multiple instances are primarily used for multi-region or multi-account deployments.
Which of the following are true regarding the .terraform.lock.hcl file? (Select TWO)
Yes, it is generated when providers are initialized.
Why this answer
It stores checksums for providers to ensure consistency and security across different environments.
You are creating a custom provider. What is the standard language used to write Terraform providers?
Terraform providers are built using Go.
Why this answer
Terraform providers are written in Go (Golang) using the Terraform Plugin SDK.
What are requirements for a custom provider to be recognized by Terraform? (Select THREE)
Providers must be executable binaries.
Why this answer
Custom providers need a specific binary name, a specific directory structure, and possibly a configuration in .terraformrc or CLI config.
Ready to test yourself?
Try a timed practice session using only Provider Management questions.