from terrasnek.api import TFC
import os
TOKEN = os.getenv("TOKEN", None)
TFC_URL = "https://app.terraform.io"
if __name__ == "__main__":
api = TFC(TOKEN, url=TFC_URL)
api.set_org("mytestorg")
create_workspace_payload = {
"data": {
"attributes": {
"name": "testws"
},
"type": "workspaces"
}
}
created_workspace = api.workspaces.create(create_workspace_payload)
create_variable_payload = {
"data": {
"type":"vars",
"attributes": {
"key":"MY_ACCESS_KEYS",
"value":"some_value",
"description":"some description",
"category":"terraform",
"hcl":"false",
"sensitive":"true"
},
"relationships": {
"workspace": {
"data": {
"id":created_workspace['data']['id'],
"type":"workspaces"
}
}
}
}
}
api.vars.create(create_variable_payload)
create_notification_configuration = {
"data": {
"type": "notification-configuration",
"attributes": {
"destination-type": "generic",
"name": "Webhook server test",
"url": "https://httpstat.us/200",
"triggers": [
"run:created"
]
}
}
}
api.notification_configs.create(payload=create_notification_configuration, workspace_id=created_workspace['data']['id'])
{'errors': [{'status': '404', 'title': 'not found'}]}
The Terraform API documentation is misleading, it says in the description that type must be notification-configuraton
while samples are plural. I've tried both to no avail and different permutations of the json payload.
astroid==2.4.2
awscli==1.18.115
beautifulsoup4==4.9.1
boto3==1.14.38
botocore==1.17.38
certifi==2020.6.20
cffi==1.14.1
chardet==3.0.4
click==7.1.2
colorama==0.4.3
configparser==3.8.1
cryptography==3.0
dnspython==2.0.0
docutils==0.15.2
email-validator==1.1.1
fido2==0.8.1
gimme-aws-creds==2.3.4
idna==2.10
inflection==0.5.1
isort==5.5.3
jmespath==0.10.0
keyring==21.3.0
lazy-object-proxy==1.4.3
mccabe==0.6.1
okta==0.0.4
pep8==1.7.1
pyasn1==0.4.8
pycodestyle==2.6.0
pycparser==2.20
pydantic==1.6.1
pylint==2.6.0
pyterprise==0.0.15
python-dateutil==2.8.0
PyYAML==5.3.1
requests==2.24.0
rsa==4.5
s3transfer==0.3.3
six==1.15.0
soupsieve==2.0.1
terrasnek==0.0.8
tfc-client==0.7.2
toml==0.10.1
urllib3==1.25.10
wrapt==1.12.1