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

Lazy Loading Vars #1575

Open
pixie79 opened this issue Apr 3, 2024 · 0 comments
Open

Lazy Loading Vars #1575

pixie79 opened this issue Apr 3, 2024 · 0 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@pixie79
Copy link

pixie79 commented Apr 3, 2024

Given the task file below I would love to be able to run task list-prepared-statements and have it first run the department of list-work-groups before it trys to evaluate the output into the var WORK_GROUPS. Either that or better still a way to capture the output of the first task as a var for future use.

Thanks

version: 3

dotenv: [".env", "{{.ENV}}/.env.", "{{.HOME}}/.env"]

tasks:
  start-json-file:
    vars:
      FILE_NAME: '{{default "file_name.json" .FILE_NAME}}'
    cmds:
      - echo "[" > {{.FILE_NAME}}
    

  end-json-file:
    vars:
      FILE_NAME: '{{default "file_name.json" .FILE_NAME}}'
    cmds:
      - sed -i 's/}/},/' {{.FILE_NAME}}
      - sed -i '$ s/.$//' {{.FILE_NAME}}
      - echo "]" >> {{.FILE_NAME}}
      - cat {{.FILE_NAME}} | jq '.' > temp.json && mv temp.json {{.FILE_NAME}}

  list-work-groups:
    preconditions:
      - test {{.AWS_REGION}}
      - test {{.AWS_PROFILE}}
    cmds:
      - aws athena list-work-groups | jq -rc '.WorkGroups | .[].Name' > work-groups

  list-prepared-statements:
    preconditions:
      - test {{.AWS_REGION}}
      - test {{.AWS_PROFILE}}
    deps: [list-work-groups]
    vars:
      FILE_NAME: "prepared-statements.json"
      WORK_GROUPS: 
        sh: cat work-groups
    cmds:
      - task: start-json-file
        vars: {FILE_NAME: "{{.FILE_NAME}}"}
      - for: { var: WORK_GROUPS}
        cmd: echo "checking work group {{.ITEM}}"; aws athena list-prepared-statements --work-group $x >> {{.ITEM}}
      - task: end-json-file
        vars: {FILE_NAME: "{{.FILE_NAME}}"}
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

2 participants