Can UPLOAD_URL be invalid after few times or it is static?

HI All,

I was trying to automate from terraform workspace creation to running plans. First I created TFC workspace with ENV variables >> configuration versions create >> upload config files.

1.So while I execute “upload config” script, I can see planning is running, but it’s not getting ended. Can anyone help me what else to be done ?

  1. Also I tried to execute “upload config” once again few hours later, then I am getting “Bad Request” error. Here what I wanted to know is whether uplod_url gets invalid after few times or what ?

Please find below code:

import os
import json
import requests

# Fetch the valiables:

WORKSPACE_ID = os.environ['WORKSPACE_ID']
ENV = os.environ["ENV"]
HEADERS = {"Content-Type": "application/octet-stream"}
TFC_URL = 'app.terraform.io'
ORGANIZATION = os.environ['ORGANIZATION']
UPLOAD_FILE_NAME = os.environ['UPLOAD_FILE_NAME']
UPLOAD_URL = ""

# Load credentials :
def load_api_credentials():
    path = '/home/gitlab-runner/creds/cred.json'
    with open(path, 'r') as f:
        read_data = f.read()
        load_data = json.loads(read_data)
        if ENV == 'prod':
            TFC_API_TOKEN = load_data["TFC_API_TOKEN_PROD"]
        elif ENV == 'test':
            TFC_API_TOKEN = load_data["TFC_API_TOKEN_TEST"]
        else:
            print("Not Found")

        if not TFC_API_TOKEN:
            raise RuntimeError(f"Unable to load credentials at {path}")
        else:
            HEADERS["Authorization"] = f"Bearer {TFC_API_TOKEN}"
load_api_credentials()

def uploadconfig():
    put_req = requests.request("PUT", UPLOAD_URL, data=UPLOAD_FILE_NAME)
    print(put_req.text)
uploadconfig()