Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider manually checks if Terraform is available #909

Open
ttakaha1 opened this issue Jul 16, 2024 · 4 comments
Open

Provider manually checks if Terraform is available #909

ttakaha1 opened this issue Jul 16, 2024 · 4 comments

Comments

@ttakaha1
Copy link

func getTFStateSnapshot() (*tfStateSnapshot, error) {
ctx := context.Background()
installer := install.NewInstaller()
defer installer.Remove(ctx)
tfVersionConstrain := ">= 1.0.6"
execPath, err := installer.Ensure(ctx, []src.Source{
&fs.Version{
Product: product.Terraform,
Constraints: version.MustConstraints(version.NewConstraint(tfVersionConstrain)),
},
})
if err != nil {
isTFVersionUnavailableError := strings.Contains(err.Error(), "terraform: executable file not found in $PATH")
if !isTFVersionUnavailableError {
return nil, err
}
return nil, fmt.Errorf("terraform binary version %q not found in $PATH", tfVersionConstrain)
}
workingDir, err := os.Getwd()
if err != nil {
return nil, err
}
tf, err := tfexec.NewTerraform(workingDir, execPath)
if err != nil {
return nil, err
}
stateSnapshot := &tfStateSnapshot{}
stateSnapshot.mu.Lock()
defer stateSnapshot.mu.Unlock()
state, err := tf.Show(context.Background())
if err != nil {
return nil, err
}
stateSnapshot.State = state
return stateSnapshot, nil
}

The PagerDuty provider is manually checking that terraform is available, which is not something it should be doing. We ran into multiple errors in our CI/CD pipeline because of this. Could someone look into this bug? Thank you.

@gdborton
Copy link
Contributor

I believe that we're being bitten by this now. Our plan succeeds, but the apply fails.

We get this message:
│ Error: terraform binary version ">= 1.0.6" not found in $PATH

@gdborton
Copy link
Contributor

Tried rolling back to a version lower than 3.10, where the provider will fetch it's own version of TF, but then it fails on this:

╷
│ Error: exit status 1
│ 
│ Error: Unsupported block type
│ 
│   on zzz_backend_override.tf line 3, in terraform:
│    3: 	cloud {
│ 
│ Blocks of type "cloud" are not expected here.

@jstoja
Copy link

jstoja commented Nov 7, 2024

Same here, we're using opentofu and I don't understand why this check is required.
Does someone know why this is needed and if this can be removed?

@thqx
Copy link

thqx commented Nov 7, 2024

we're also running in this issue using OpenTofu, after debugging, we could workaround by manually removing the schedule which was supposed to be deleted from pagerduty and the state. will this be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants