terraform
Terraform Error Codes
Diagnostic error types produced by the Terraform CLI. These appear as structured diagnostics in human-readable output and in machine-readable JSON (terraform plan -json), covering configuration, state, backend, provider, and plan/apply errors.
40 codes
references developer.hashicorp.com/terraform/internals/json-output-formatdeveloper.hashicorp.com/terraform/language/expressions/
· All codes 40 codes
- backend_initialization_required Backend initialization required The backend configuration has changed or has not yet been initialised. Run terraform init to initialise or reconfigure the backend before running other commands.
- cycle_error Cycle error Terraform detected a circular dependency in the configuration — a chain of references that eventually leads back to the starting resource. Break the cycle by restructuring dependencies or using the depends_on meta-argument carefully to avoid circular chains.
- duplicate_resource Duplicate resource Two resource blocks in the configuration share the same type and name, which must be unique within a module. Rename one of the conflicting resource blocks.
- error_locking_state Error locking state Terraform could not write the state lock to the backend (e.g. a DynamoDB table for S3 backends), typically due to a missing table, insufficient permissions, or a network failure. Verify the backend configuration and required permissions.
- error_refreshing_state Error refreshing state Terraform failed to read the current state of a resource from the provider during the refresh phase, often because the resource was deleted outside of Terraform. Remove the resource from state with terraform state rm or re-import it.
- failed_to_read_schema Failed to read schema Terraform could not retrieve the schema from the provider plugin, usually because the provider binary is corrupted, incompatible, or the gRPC connection failed. Run terraform init to reinstall the provider.
- incompatible_provider_version Incompatible provider version The installed provider version does not satisfy the version constraint specified in required_providers. Update the constraint or run terraform init -upgrade to install a compatible version.
- insufficient_permissions Insufficient permissions The provider credentials in use do not have the required IAM or RBAC permissions to perform the requested operation. Grant the necessary permissions to the account or role being used by Terraform.
- invalid_block_definition Invalid block definition A block label or block type is not valid in the current context, often caused by a missing or extra label, or placing a block where an argument is expected. Review the HCL block syntax and provider schema.
- invalid_count_argument Invalid count argument The value supplied to the count meta-argument is not a whole number, is negative, or cannot be determined until apply time (a value that depends on a resource attribute). Use a known, non-negative integer or move the count dependency to a data source.
- invalid_depends_on Invalid depends_on reference The depends_on meta-argument contains a reference that is not a resource or module address, or it attempts to reference an output or attribute rather than a whole resource. Use only bare resource or module references (e.g. aws_instance.web, not aws_instance.web.id).
- invalid_expression Invalid expression An expression in the configuration could not be parsed or evaluated, typically due to a syntax error such as a missing closing bracket or an invalid token. Review the expression syntax at the indicated source location.
- invalid_for_each_argument Invalid for_each argument The value supplied to the for_each meta-argument is not a map or set of strings, or it cannot be determined until apply time. The collection must be fully known at plan time; use toset() or tomap() conversion functions as needed.
- invalid_function_call Invalid function call A built-in function was called with the wrong number of arguments, an argument of the wrong type, or an invalid value (such as a negative index in substr). Check the function's signature in the Terraform documentation.
- invalid_index Invalid index An expression accesses a list or tuple element with an index that is out of range, or accesses a map with a key that does not exist. Check that the index or key is within the bounds of the collection.
- invalid_module_output_reference Module has no output with name An expression references an output value from a module that the module does not declare. Verify the output name against the module's output blocks and ensure the module is the correct version.
- invalid_provider_configuration Invalid provider configuration The provider block contains an invalid or missing configuration value, such as a required authentication credential. Check the provider documentation and supply the required configuration or use environment variables.
- invalid_resource_type Invalid resource type The resource type named in the configuration is not provided by the configured provider. Verify the resource type spelling, the provider source, and the provider version.
- invalid_template_interpolation Invalid template interpolation value A template string interpolation (${ }) contains a value that cannot be converted to a string, such as a list or object. Use jsonencode() or a string conversion function to produce a string representation.
- invalid_value Invalid value An argument was given a value that does not satisfy the schema's constraints, such as a string that is not one of the allowed enum values. Refer to the provider documentation for the set of accepted values.
- missing_required_argument Missing required argument A required argument for a resource, data source, provider, or function was not provided. Supply the missing argument or consult the provider documentation for its correct name.
- missing_required_provider Missing required provider A resource or data source requires a provider that is not declared in the required_providers block. Add the provider source and version constraints to the terraform block.
- module_not_installed Module not installed A module block references a module source that has not been downloaded to the .terraform directory. Run terraform init to install all required modules.
- no_configuration_files No configuration files Terraform found no .tf files in the working directory. Ensure you are running Terraform commands from the directory that contains your configuration files.
- output_refers_to_sensitive_value Output refers to sensitive values An output value references one or more sensitive attributes without marking the output itself as sensitive = true. Add sensitive = true to the output block to suppress the value from plan and apply output.
- plan_file_incompatible Saved plan is stale The saved plan file was created with a different version of Terraform or against a different configuration than is currently present. Re-run terraform plan to generate a fresh plan.
- provider_configuration_not_present Provider configuration not present A resource references a provider alias that has no corresponding provider block in the configuration. Add the provider block with the matching alias or remove the provider meta-argument.
- provider_not_found Provider not found Terraform could not locate an installed provider plugin matching the required source address. Run terraform init to download and install the required providers.
- reference_to_undeclared_input_variable Reference to undeclared input variable An expression references a variable (var.*) that has no corresponding variable block in the configuration. Declare the variable or correct the reference name.
- reference_to_undeclared_local_value Reference to undeclared local value An expression references a local value (local.*) that is not defined in a locals block. Add the local value definition or correct the reference name.
- reference_to_undeclared_resource Reference to undeclared resource An expression references a resource or data source that is not declared anywhere in the configuration. Declare the resource or correct the reference address.
- required_providers_not_initialised Required providers not initialised The .terraform.lock.hcl lock file or installed provider binaries are missing or inconsistent with the configuration. Run terraform init to install all required providers and regenerate the lock file.
- resource_already_exists Resource already exists Terraform attempted to create a resource but the provider reports it already exists in the target environment. Import the existing resource into state with terraform import rather than recreating it.
- state_inconsistency Inconsistent result after apply The provider returned a different value for an attribute after apply than the plan predicted, indicating a provider bug or an external change to the resource. The state may need manual reconciliation with terraform refresh or terraform import.
- state_lock_error Error acquiring the state lock Terraform could not obtain an exclusive lock on the state file, because another operation is already holding it. Wait for the other operation to complete, or manually remove a stale lock with terraform force-unlock if the previous process crashed.
- type_mismatch Incorrect attribute value type The value provided for an attribute does not match the type the schema requires, such as supplying a string where a number is expected. Correct the value or use an explicit type-conversion function.
- unsupported_argument Unsupported argument An argument was set on a resource, data source, or module block that the schema does not define. Remove the argument or check that the provider version supports it.
- unsupported_attribute Unsupported attribute An expression accesses an attribute on an object that does not have that attribute, including attributes that do not exist on a resource type's schema. Verify the attribute name against the provider documentation.
- unsupported_block_type Unsupported block type A block of an unrecognised type was used inside a resource, provider, or module body. Check the provider schema for valid nested block types.
- values_not_yet_known Error: ... will be known only after apply An attribute used in a context that requires a known value at plan time (such as count, for_each, or a provider configuration) depends on a resource attribute that is only computed after apply. Restructure the configuration to use a known value, or use a data source.