How to install terraform providers locally?

I’m executing all the terraform commands from a private instance which does not have internet. So, I have downloaded the plugins and placed inside a specific directory (/opt/providers/terraform-provider-aws_v3.30.0_x5) and initializing with terraform init -plugin-dir="/opt/providers" flag. But I’m getting the below error

Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/aws...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws:
provider registry.terraform.io/hashicorp/aws was not found in any of the
search locations

  - /opt/providers

Once I create a new directory structure like /opt/providers/registry.terraform.io/hashicorp/aws/3.30.0/linuxamd64/ I got a different error as below

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/aws...

Error: Incompatible provider version

Provider registry.terraform.io/hashicorp/aws v3.30.0 does not have a package
available for your current platform, linux_amd64.

Provider releases are separate from Terraform CLI releases, so not all
providers are available for all platforms. Other versions of this provider may
have different platforms supported.

I need two things as below

  1. Provide me the solution for this issue
  2. On other hand, how to configure the provider_installation Explicit Installation Method Configuration?

Versions:

  • Terraform Core - 0.14.7 (latest)
  • Terraform AWS Provider - 3.30.0 (latest)