Intro
When a new organization is created through API requests, attributes can be set that define settings in a organization upon creation of the organization within Terraform Enterprise.
Problem
The assessments-enforced attribute setting is not respected when defined in a API request to create a new organization.
To set the value of the attribute to true, a second API request is required to update the value of the attribute to true.
To reproduce the behavior
Set the TOKEN variable using a Admin token:
export TOKEN=<token_value>
Create the payload.json file:
vi payload.json
Add the following content
{
"data": {
"type": "organizations",
"attributes": {
"name": “<“ORGANIZATION_NAME>,
"email": “<“USER_EMAIL@DOMAIN.EXT>,
"assessments-enforced": true
}
}
}
Perform the API call to create a organization
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://<TFE_FQDN>/api/v2/organizations
The response shows the value is not respected:
"assessments-enforced":false,
The attribute does not respect the definition as defined in the payload.json file.
Solution
Update the attribute using a second API request
Create a update.json payload file
vi update.json
Add the following content:
{
"data": {
"type": "organizations",
"attributes": {
"name": “<ORGANIZATIION_NAME”>,
"email": “<“USER_EMAIL@DOMAIN.EXT>,
"assessments-enforced": true
}
}
}
Perform the API call to update the organization's "assessments-enforced" attribute
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data @update.json \
https://<TFE_FQDN>/api/v2/organizations/<ORGANIZATION_NAME>
Response shows the attribute is respected:
"assessments-enforced":true,
{
"data": {
"type": "organizations",
"attributes": {
"name": “<ORGANIZATION_NAME>”,
"email": “<“USER_EMAIL@DOMAIN.EXT”>,
"assessments-enforced": true
}
}
}