Skip to content

Error parsing list of instance when empty response #52

@chrisdemers

Description

@chrisdemers

I have the error 'jq: error (at :1): Cannot index boolean with string "instance_name"' when get instances request returns empty list

list_response=$(curl -X GET \
            -H "ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}" \
            -H "content-type: application/json" \
            https://api.localstack.cloud/v1/compute/instances)

instance_exists=$(echo "$list_response" | jq --arg NAME "$previewName" '.[] | select(.instance_name == $NAME)')

Action call:

          uses: LocalStack/setup-localstack@v0.2.4
          with:
            github-token: ${{ secrets.GITHUB_TOKEN }}
            use-pro: true
            install-awslocal: true
            include-preview: false
            skip-ephemeral-stop: true
            state-backend: ephemeral
            state-action: start
            preview-cmd: awslocal s3api create-bucket --bucket test-devops-local
          env:
            LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}      

It works when I manually create an ephemeral instance manually before triggering my workflow

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