citrix / terraform-provider-citrixadc

Part of NetScaler Automation Toolkit | https://github.com/netscaler/automation-toolkit
https://registry.terraform.io/providers/citrix/citrixadc
Apache License 2.0
119 stars 59 forks source link

[FEATURE REQUEST] citrixadc_systemfile support overwrite #1119

Open ravager-dk opened 9 months ago

ravager-dk commented 9 months ago

Contact us

For any immediate issues or help , reach out to us at NetScaler-AutomationToolkit@cloud.com !

Feature Request

Is your feature request related to a problem? Please describe. I am trying to use citrixadc_systemfile to upload a custom sshd_config file to /etc/sshd_config after initial vpx deployment. However since the file already exists I get error: Error: [0m Error: [ERROR] nitro-go: Failed to create resource of type systemfile, name=, err=failed: 409 Conflict ({ "errorcode": 1642, "message": "Cannot create output file. File already exists", "severity": "ERROR" })

Describe the solution you'd like A simple bool argument called overwrite_existing allowing overwriting the existing file. I am not sure if the NITRO api allows for this, since I have not tested it. But look at the following link it seems there is an override query that could be what would work: https://developer-docs.netscaler.com/en-us/adc-nitro-api/current-release/configuration/system/systemfile.html#add Alternatively it could be wrapped in a delete call (continuing on error if the file does NOT exist) and an add call.

Describe alternatives you've considered Tried importing the file first, but first of all this gives an error (I will create a separate issue for that), and secondly this does not work well in a fully automated solution. I should not have to break the workflow up after deployment, import the file into state and then run the rest of the config workflow.

Additional context Code for reproducing. Just add any text to a sshd_config file in the workspace: resource "citrixadc_systemfile" "sshd_config" { filename = "sshd_config" filelocation = "/etc" filecontent = file("${path.module}/sshd_config") }