Skip to content

Instantly share code, notes, and snippets.

@nomaster
Created April 13, 2021 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomaster/8d8981c55d61c7106ac87c30ebbb3a89 to your computer and use it in GitHub Desktop.
Save nomaster/8d8981c55d61c7106ac87c30ebbb3a89 to your computer and use it in GitHub Desktop.
Run all Terraform workspaces matching name by string
#!/usr/bin/env python3
import pyterprise
import os
tfe_token = os.environ.get('TFE_TOKEN')
tfe_org = os.environ.get('TFE_ORG')
client = pyterprise.Client()
client.init(token=tfe_token, url="https://app.terraform.io")
org = client.set_organization(id=tfe_org)
for workspace in org.search_workspaces('dns-netbox'):
workspace.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment