If your company has actually obstructed registry.terraform.io
and has actually rather downloaded the company binaries to Nexus, then you can do the following to still make your Terraform perform properly.
Action 1 – Download the Required Providers
In our example, we require the following suppliers:
- AWS
- Archive
These commands listed below are running straight from the pipeline that carries out the Terraform:
# Download the suppliers from the Nexus repository
- curl -u $ {Nexus_REPO_USER}:$ {Nexus_REPO_PASS} -o terraform-provider-aws4.65.0 linuxamd64.zip https://nexus.example.com/repository/some-local-mirror/registry.terraform.io/hashicorp/aws/terraform-provider-aws_4.65.0_linux_amd64.zip
- curl -u $ {Nexus_REPO_USER}:$ {Nexus_REPO_PASS} -o terraform-provider-archive_2.3.0 _ linux_amd64. zip https://nexus.example.com/repository/local-mirror/registry.terraform.io/hashicorp/archive/terraform-provider-archive_2.3.0_linux_amd64.zip
# Make a regional directory site to keep these suppliers
- mkdir -p $HOUSE/. terraform.d/ plugins/registry. terraform.io/ hashicorp/aws/.
- mkdir -p $HOUSE/. terraform.d/ plugins/registry. terraform.io/ hashicorp/archive/.
# Move the downloaded zip files to these directory sites.
- mv terraform-provider-aws_4.65.0 _ linux_amd64. zip $HOUSE/. terraform.d/ plugins/registry. terraform.io/ hashicorp/aws/.
- mv terraform-provider-archive_2.3.0 _ linux_amd64. zip $HOUSE/. terraform.d/ plugins/registry. terraform.io/ hashicorp/archive/.
# Provide the consents (not constantly needed).
- chmod 777 -R $HOUSE/. terraform.d/ plugins/.
Action 2 – Run the Terraform code with a Plugin Directory Site
The following code continues the pipeline from above where we ended:
# Include the "- plugin-dir" to utilize the very same place as above.
- terraform init -plugin-dir=$ HOUSE/. terraform.d/ plugins/ -backend-config= env/dev/backend. conf -reconfigure-force-copy.
Step 3 – Update the terraform
block to the very same variations as above
Now we require to customize or include the following code into our Terraform code:
terraform {
required_providers {
aws = {
source="hashicorp/aws".
variation="4.65.0".
}
archive = {
source="hashicorp/archive".
variation="2.3.0".
}
}
# Include other functions you require here ... e.g.
# backend "s3" {
# ...
#}
}