beelit94 / python-terraform

MIT License
472 stars 172 forks source link

Plugin reinitialization required, Please run "terraform init" #126

Open akash05-sams opened 1 year ago

akash05-sams commented 1 year ago

I am trying to utilize the python-terraform to create an AWS resource. I was trying to create SQS with it, and for it, I have provided the provider as "aws" and tried to initialize the terraform. But, I am facing an error that I have attached below.

Please find the code I used for destroying the instance:

from python_terraform import * enter = int(input('Enter the re-use period of the Queue: ')) tf = Terraform(working_dir='./terraform', variables={'re_use_period':enter}) tf.init('provider') tf.plan(no_color=IsFlagged, refresh=False, capture_output=True) approve = {"auto-approve":True}`

provider.tf file we have,

provider "aws" { access_key = var.access_key secret_key = var.secret_key region = var.region }

Error:

(1, '', '\nError: Could not satisfy plugin requirements\n\n\nPlugin reinitialization required. Please run "terraform init".\n\nPlugins are external binaries that Terraform uses to access and manipulate\nresources. The configuration provided requires plugins which can\'t be located,\ndon\'t satisfy the version constraints, or are otherwise incompatible.\n\nTerraform automatically discovers provider requirements from your\nconfiguration, including providers used in child modules. To see the\nrequirements and constraints from each module, run "terraform providers".\n\n\n\nError: provider.aws: no suitable version installed\n version requirements: "(any version)"\n versions installed: none\n\n\n')

Am I doing anything wrong, can anyone please help me in this?

Shyamalenduojha17 commented 1 year ago

You facing this type of issue due to Terraform cannot find a suitable version of the provider that matches the version requirements specified in your configuration. To solve this problem.