Optional fields are considered manadatory
Closed this issue · 12 comments
it appears the optional fields are mandatory there is no flexibility to control the behaviour. i have requirement on few items like to have execution environment golobally available along with that few creentials but while testing it appears for creating credential organization has been made mandatory but as per documentation it says optional. Similar problems observed with settings all are listed as optional but have to fill everthing there is no flexibility on these items.
https://registry.terraform.io/providers/ilijamt/awx/latest/docs/resources/credential
https://registry.terraform.io/providers/ilijamt/awx/latest/docs/resources/settings_auth_saml
![image](https://private-user-images.githubusercontent.com/141311017/320188473-133e9864-59df-4346-99c0-5ee1bdc89f66.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzODM2MjAsIm5iZiI6MTcyMjM4MzMyMCwicGF0aCI6Ii8xNDEzMTEwMTcvMzIwMTg4NDczLTEzM2U5ODY0LTU5ZGYtNDM0Ni05OWMwLTVlZTFiZGM4OWY2Ni5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDczMFQyMzQ4NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mOTk2NTQyNTkwOGZlZGQ1NWJjY2E5ZGRiYzZkMDk1ZTYyMjNiZjM0Nzg3YmNhOWRkOTQ0NjJiNzY2ZTZiMTc2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.7wD8_ok9mUMdEMqA6hZp02HBLUpHZ9leleMKJOtRIGI)
Error:
╷
│ Error: Unable to create resource for Credential on /api/v2/credentials/
│
│ with awx_credential.credentials["CONTAINER REGISTRY CREDENTIALS"],
│ on credentials.tf line 1, in resource "awx_credential" "credentials":
│ 1: resource "awx_credential" "credentials" {
│
│ invalid status code: 400, on /api/v2/credentials/ with {"detail":["Missing
│ 'user', 'team', or 'organization'."]}
╵
ERRO[0005] terraform invocation failed in /ansible-awx-terraform-dev/NewFormat/dev/.terragrunt-cach
e/5zNg_T0822Q-K3ro8mGOQU_7QqA/XjsNBCAXFo1RIqhnaDcs2IGepw4 prefix=[/ansible-awx-terraform-dev/NewFormat/dev]
ERRO[0005] 1 error occurred:
* [/ansible-awx
-terraform-dev/NewFormat/dev/.terragrunt-cache/5zNg_T0822Q-K3ro8mGOQU_7QqA/XjsNBCAXFo1RIqhnaDcs2IGepw4] exit status 1
Yeah, according to their API they are optional, but one of them is required.
But let me check, the write only fields
from the API are missing in the provider, which shouldn't be happening. There are special write_only
fields which can only be provided during initial creation of the credential, after that it's not possible to change and/or update them. Looks like I disabled them when I moved to the terraform framework plugin
from the legacy sdk. And if you create from the UI without an organization
it assigns the credential
to the user it created it.
The definition below is provided by the API of AWX.
terraform-provider-awx/resources/api/23.8.1/payload/resource_credential.json
Lines 102 to 161 in ba48f28
any plans for getting "write_only": true back.
https://github.com/ilijamt/terraform-provider-awx/blob/ba48f288c33b75e44e872379f51f818306a012cd/resources/api/23.8.1/payload/resource_settingsauthsaml.json
https://registry.terraform.io/providers/ilijamt/awx/latest/docs/resources/settings_auth_saml
saml auth has everthing optional but when i try subset POST call it kind of overwrites the existing ones
Yes that's normal. Because when you do it from the UI, writes back everything. When you do it from terraform you only send partially what you have defined. So when you update you have to send all of them.
thanks for making me understand i was thinking api wont be any different the user does operations normally.
There is a new version, it's building now v23.8.1-1 can you try it out it has the fields back and let me know.
yes thanks it works :)
i hit one more error/bug with schedules. I follow this example
https://github.com/ilijamt/terraform-provider-awx/blob/main/examples/preload_data/main.tf#L152-L157
╷
│ Error: Unable to create resource for Schedule on /api/v2/schedules/
│
│ with awx_schedule.schedules["abc Nautobot Inventory"],
│ on schedules.tf line 29, in resource "awx_schedule" "schedules":
│ 29: resource "awx_schedule" "schedules" {
│
│ invalid status code: 400, on /api/v2/schedules/ with {"diff_mode":["Field
│ is not allowed on launch."]}
resource "awx_schedule" "schedules" {
for_each = {for schedule in data.awx_inventory_source.source_inventories : schedule.name => schedule}
name = each.value.name
enabled = true
# everday time 2359 time zone ist from 2024 to 2050
rrule = "DTSTART;TZID=Europe/Amsterdam:20221111T103000 RRULE:INTERVAL=1;FREQ=MONTHLY;BYMONTHDAY=1"
unified_job_template = each.value.id
}
The API is complaining about diff mode set. Try removing prompt for diff mode from the template.
terraform-provider-awx/examples/preload_data/main.tf
Lines 152 to 156 in d6d362b
I just ran the whole preload folder on 24.1.0 and there is no issue with the schedule, you need to see the choices you have on are conflicting with the schedule creation