microsoft / azure-pipelines-terraform

Azure Pipelines tasks for installing Terraform and running Terraform commands in a build or release pipeline.
MIT License
95 stars 59 forks source link

state command not working #207

Open abhiramani-git opened 5 months ago

abhiramani-git commented 5 months ago

this is the task i am running. i keep getting this error:State management commands require a state file. Run this commandto point the command to a specific state location.

steps:

mericstam commented 5 months ago

Hi, first of all what are you trying to accomplish? And is your state file called devtest.tfvars? please provide the steps of your pipeline.

br Manuel

abhiramani-git commented 5 months ago
Screen Shot 2024-01-23 at 5 02 44 PM

@mericstam i am trying to list state file content and then i need to delete some resources from state file if list works successfully

yes its called devtest.tfvars. i have just kept that extension instead of .tfstate.

mericstam commented 5 months ago

Do you use SAS token to access blob store? or how do you authenticate?

/Manuel

abhiramani-git commented 5 months ago

Hi i am running pipeline using service principal and it has contributor access to storage account. and other steps like terraform init/plan/apply all work fine. just state commands like list/rm not working

mericstam commented 5 months ago

as far as I understand the option -state=path is ignored when using remote state.

https://developer.hashicorp.com/terraform/cli/commands/state/list So perhaps as a test you can change to default name?

br Manuel

abhiramani-git commented 5 months ago

Just terraform state list fails with not much info. my state is already successfully initialized in "terraform init state"

Screen Shot 2024-01-29 at 8 28 07 PM
abhiramani-git commented 4 months ago

Any update?

mericstam commented 4 months ago

Can you run the terraform state command locally?

abhiramani-git commented 4 months ago

Yes I can