Skip to content

terraform-bin state rm ::debug::stdout: #167

@horvatic

Description

@horvatic

When running this code in a GitHub action:

    - name: Terraform Remove Permanent Resources From State
      env:
        TF_ACTION_WORKING_DIR: 'terraform'
        AWS_ACCESS_KEY_ID:  ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY:  ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      run: |
          cd terraform
          cp terraform.tfstate tempstate
          ECSTASKS=$(terraform state list | grep "aws_ecs_task_definition")
          for ECSTASK in $ECSTASKS
          do
            terraform state rm $ECSTASK
          done

I get the following output

terraform-bin state rm aws_ecs_task_definition.task
Removed aws_ecs_task_definition.task
Successfully removed 1 resource instance(s).
terraform-bin state rm ::debug::stdout:

Error: Variable name required
on  line 1:
(source code not available)
Must begin with a variable name.

The removal of aws_ecs_task_definition.task is correct. This code has been tested outside of Github actions and works correctly. When I echo $ECSTASKS, I only get aws_ecs_task_definition.task showing the loop is running once with the correct info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions