reviewdog / action-tflint

Run tflint with reviewdog on pull requests to enforce best practices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: No valid credential sources found

cmhrpr opened this issue · comments

When trying to set up a new repo containing a few Terraform files, I'm getting the following output at the tflint stage:

Run reviewdog/action-tflint@master
/usr/bin/docker run --name  --label 430c1a --workdir /github/workspace --rm -e INPUT_GITHUB_TOKEN -e INPUT_WORKING_DIRECTORY -e INPUT_FLAGS -e INPUT_LEVEL -e INPUT_REPORTER -e INPUT_FILTER_MODE -e INPUT_FAIL_ON_ERROR -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_URL -e GITHUB_API_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "":"/github/workspace" 
Failed to initialize a runner. An error occurred:

Error: No valid credential sources found

2020/05/18 18:29:14 [tflint] reported:  (conclusion=success)

Hey!

Hm... that may actually be a GitHub issue? Could you share the yaml definition for the job?

Hey @Vlaaaaaaad !

of course:

name: reviewdog
on: [pull_request]
jobs:
  tflint:
    name: runner / tflint
    runs-on: ubuntu-latest

    steps:
      - name: Clone repo
        uses: actions/checkout@master

      # Install latest Terraform manually as
      #  Docker-based GitHub Actions are
      #  slow due to lack of caching
      # Note: Terraform is not neede for tflint
      - name: Install Terraform
        run: |
          curl -LO https://raw.github.com/robertpeteuil/terraform-installer/master/terraform-install.sh
          chmod +x terraform-install.sh
          ./terraform-install.sh -a

      # Run init to get module code to be able to use `--deep`
      - name: Terraform init
        run: |
          terraform init

      - name: tflint
        uses: reviewdog/action-tflint@master
        with:
          github_token: ${{ secrets.github_token }}
          working_directory: "." # Change working directory
          flags: "--deep" # Add custom flags

Basically just the example code

Oh... the --deep flag for tflint requires AWS Credentials to be set and available to the tflint runner.

I'll be honest, I never used --deep so I have no idea how to send AWS credentials to the tflint runner.

If you really need --deep, I'd try the following or something along these lines:

# No idea if this will work or not
- name: tflint
  uses: reviewdog/action-tflint@master
  env:
    AWS_ACCESS_KEY_ID: ${{ secrets.WHATEVER_ACCESS_KEY_NAME}}
    AWS_SECRET_ACCESS_KEY: ${{ secrets.WHATEVER_SECRET_KEY_NAME }}
    AWS_DEFAULT_REGION: "us-east-1"
  with:
    github_token: ${{ secrets.github_token }}
    flags: "--deep"

Amazing, thanks for the help. That's it running successfully now!

🎉 wooo! I'll clean up the example a bit and make it clearer so other people don't experience the same issues.