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

Using random generator with null provider giving "no state file was found" #291

Open
ssid334 opened this issue Oct 9, 2024 · 3 comments
Labels
bug Something isn't working needs:triage

Comments

@ssid334
Copy link

ssid334 commented Oct 9, 2024

What happened?

I am trying to use the example of random-generator to create secret with random content, but since I don't need TF for any other resources I am using null provider. Yet TF complains about local state file not present.

How can we reproduce it?

Provider Config:

apiVersion: tf.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  configuration: |
    terraform {
      backend "local" {}
    }
    provider "null" {
    }

When applying the example of random generator I'm getting the result:

Name:         example-random-generator
Namespace:
Labels:       <none>
Annotations:  crossplane.io/external-name: random
              meta.upbound.io/example-id: tf/v1beta1/workspace
API Version:  tf.upbound.io/v1beta1
Kind:         Workspace
Metadata:
  Creation Timestamp:  2024-10-09T10:44:12Z
  Generation:          1
  Resource Version:    51253448
  UID:                 95636143-3c98-4b20-8c28-ab47de1f2c31
Spec:
  Deletion Policy:  Delete
  For Provider:
    Entrypoint:
    Module:      resource "random_password" "password" {
  length = 16
  special = true
}
output "random_password" {
  value = random_password.password
  sensitive = true
}

    Source:  Inline
  Management Policies:
    *
  Provider Config Ref:
    Name:  default
  Write Connection Secret To Ref:
    Name:       terraform-workspace-example-random-generator
    Namespace:  tftest
Status:
  At Provider:
  Conditions:
    Last Transition Time:  2024-10-09T10:44:17Z
    Message:               observe failed: cannot list Terraform resources: Terraform encountered an error. Summary: . To see the full error run: echo "H4sIAAAAAAAA/0yOMU7FQAxE+73Cb4YD8AXiHhRAl8psvFlLWTt4vYq4PUoUpF+48cy8mdv09treDT0oGEVWxk4dxYbOTyl9nu9GSgs31kC21kjnDuefIc6gh+gdH0MRVfq/L4mCMItzDvNf7JWd8cXuVMwbKnV8Myt8KMwxOiMq4/mCrrSkMGwmGqdwcRF2NG+cpUi+JqyWKcT0fpte2nHpDwAA//8BAAD//yMXozveAAAA" | base64 -d | gunzip
    Reason:                ReconcileError
    Status:                False
    Type:                  Synced
Events:
  Type     Reason                         Age                 From                             Message
  ----     ------                         ----                ----                             -------
  Warning  CannotObserveExternalResource  37s (x25 over 21m)  managed/workspace.tf.upbound.io  cannot list Terraform resources: Terraform encountered an error. Summary: . To see the full error run: echo "H4sIAAAAAAAA/0yOMU7FQAxE+73Cb4YD8AXiHhRAl8psvFlLWTt4vYq4PUoUpF+48cy8mdv09treDT0oGEVWxk4dxYbOTyl9nu9GSgs31kC21kjnDuefIc6gh+gdH0MRVfq/L4mCMItzDvNf7JWd8cXuVMwbKnV8Myt8KMwxOiMq4/mCrrSkMGwmGqdwcRF2NG+cpUi+JqyWKcT0fpte2nHpDwAA//8BAAD//yMXozveAAAA" | base64 -d | gunzip
k8s-control-plane1 ~/r> echo "H4sIAAAAAAAA/0yOMU7FQAxE+73Cb4YD8AXiHhRAl8psvFlLWTt4vYq4PUoUpF+48cy8mdv09treDT0oGEVWxk4dxYbOTyl9nu9GSgs31kC21kjnDuefIc6gh+gdH0MRVfq/L4mCMItzDvNf7JWd8cXuVMwbKnV8Myt8KMwxOiMq4/mCrrSkMGwmGqdwcRF2NG+cpUi+JqyWKcT0fpte2nHpDwAA//8BAAD//yMXozveAAAA" | base64 -d | gunzip
No state file was found!

State management commands require a state file. Run this command
in a directory where Terraform has been run or use the -state flag
to point the command to a specific state location.

What environment did it happen in?

  • Crossplane Version: 1.15.0
  • Provider Version: v0.18.0
  • Kubernetes Version: v1.29.5
  • Kubernetes Distribution: kubeadmin
@ssid334 ssid334 added bug Something isn't working needs:triage labels Oct 9, 2024
@ssid334 ssid334 changed the title Using random generator with null provider Using random generator with null provider giving "no state file was found" Oct 9, 2024
@bobh66
Copy link
Collaborator

bobh66 commented Oct 9, 2024

Have you tried using the kubernetes backend as suggested here: https://github.com/upbound/provider-terraform?tab=readme-ov-file#known-limitations

@ssid334
Copy link
Author

ssid334 commented Oct 9, 2024

Just checked, k8s provider seems to work. But the null provider seems to be better candidate for this as it should be volatile.

@bobh66
Copy link
Collaborator

bobh66 commented Oct 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage
Projects
None yet
Development

No branches or pull requests

2 participants