citrix / terraform-provider-citrix

Terraform Provider for Citrix
https://registry.terraform.io/providers/citrix/citrix/latest
Apache License 2.0
45 stars 5 forks source link

[Bug]Create_citrix_stf_roaming_gateway not working #93

Closed dimi4ik closed 1 month ago

dimi4ik commented 1 month ago

Thanks for taking the time to fill out this bug report! Before submitting this issue please check the open bugs to ensure the bug has not already been reported. If it has been reported give it a πŸ‘

If this bug is present when using the Citrix service UI or REST APIs then it is not a bug in the provider but rather a bug in the underlying service or the environment. In some cases there can be an enhancement in the provider to handle the error better. Please open a feature request instead of a bug in this case. For more information see CONTRIBUTING.md#provider-issue-vs-product-issue-vs-configuration-issue.

Describe the bug

Summary of the issue

When I deploy a new StoreFront instance with Terraform and use the examples from the Git documentation "https://registry.terraform.io/providers/citrix/citrix/latest/docs/resources/stf_roaming_gateway", I receive an error:

terraform.exe plan
β•·
β”‚ Error: Incorrect attribute value type
β”‚
β”‚   on main.tf line 182, in resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway":
β”‚  182:     secure_ticket_authority_urls   = [
β”‚  183:         "https://example.sta1.com/",
β”‚  184:         "https://example.sta2.url/"
β”‚  185:     ]
β”‚
β”‚ Inappropriate value for attribute "secure_ticket_authority_urls": element 0: object required.
β•΅

I created the resource "citrix_stf_roaming_gateway" via the GUI and imported it using the import command. When I transfer the configuration from the state to the Terraform file, I receive an error.

Error: Unexpected error in the Citrix provider
β”‚
β”‚   with citrix_stf_roaming_gateway.example-stf-roaming-gateway,
β”‚   on citrix_stf_roaming_gateway.tf line 26, in resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway":
β”‚   26: resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway" {
β”‚
β”‚ An unexpected error occurred in runtime.panicmem.
β”‚
β”‚ runtime error: invalid memory address or nil pointer dereference
β”‚
β”‚ Please report this issue to the project maintainers and include this file if present: C:\Users\ADVMAD~1\AppData\Local\Temp\citrix_provider_crash_stack.240100289.txt

Where do I get the value for sta_validation_secret? Could you please provide a complete StoreFront deployment Terraform script in Git?

Terraform command (import, apply, etc): apply

Resource impacted: citrix_stf_roaming_gateway

Versions

Use the terraform -v command to find the Terraform and Citrix Provider versions. Terraform: citrix/citrix provider: Operation system:

terraform -v Terraform v1.9.3 on windows_amd64

For on-premises customers fill out any that apply with the CU or LTSR version (eg 2402). CVAD (DDC, VDA, etc): 2311 Storefront: 2311

Terraform configuration files

Paste or attach any relevant .tf files with secrets and identifying information removed.

resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway" {
    name                           = "Example Roaming Gateway Name"
    site_id                        = citrix_stf_deployment.stf_deployment_0.site_id
    request_ticket_two_stas        = false
    callback_url                   = "https://ctx-callback.cloud.com/CitrixAuthService/AuthService.asmx"
    gateway_url                    = "https://example.gateway.com/"
    gslb_url                       = ""
    is_cloud_gateway               = false
    logon_type                     = "Domain"

    secure_ticket_authority_urls   = [
        {
            authority_id           = null
            sta_url                = "https://ctx-ddc.cloud.com/scripts/ctxsta.dll"
            sta_validation_enabled = false
            sta_validation_secret  = ""
        },
    ]
    session_reliability            = true
    smart_card_fallback_logon_type = "None"
    stas_bypass_duration           = "0.1:0:0"
    stas_use_load_balancing        = false
    subnet_ip_address              = ""
    version                        = "Version10_0_69_4"
}

Terraform console output

*Paste the output from Terraform CLI including any errors and the transactionIds if present.*

Error: Unexpected error in the Citrix provider
β”‚
β”‚   with citrix_stf_roaming_gateway.example-stf-roaming-gateway,
β”‚   on citrix_stf_roaming_gateway.tf line 26, in resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway":
β”‚   26: resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway" {
β”‚
β”‚ An unexpected error occurred in runtime.panicmem.
β”‚
β”‚ runtime error: invalid memory address or nil pointer dereference
β”‚
β”‚ Please report this issue to the project maintainers and include this file if present: C:\Users\ADVMAD~1\AppData\Local\Temp\citrix_provider_crash_stack.240100289.txt

If the output references a file in the temp directory include it as well.

Terraform log file

If the issue is reproducible enable Terraform debug logging using one of the commands below. Then reproduce the issue and include the resulting log file. More information about Terraform logging is available here.

024-07-29T13:48:13.716Z [DEBUG] Starting graph walk: walkApply
2024-07-29T13:48:13.716Z [DEBUG] created provider logger: level=debug
2024-07-29T13:48:13.717Z [INFO]  provider: configuring client automatic mTLS
2024-07-29T13:48:13.722Z [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/citrix/citrix/0.6.3/windows_amd64/terraform-provider-citrix_v0.6.3.exe args=[".terraform/providers/registry.terraform.io/citrix/citrix/0.6.3/windows_amd64/terraform-provider-citrix_v0.6.3.exe"]
2024-07-29T13:48:13.724Z [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/citrix/citrix/0.6.3/windows_amd64/terraform-provider-citrix_v0.6.3.exe pid=6988
2024-07-29T13:48:13.724Z [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/citrix/citrix/0.6.3/windows_amd64/terraform-provider-citrix_v0.6.3.exe
2024-07-29T13:48:13.763Z [INFO]  provider.terraform-provider-citrix_v0.6.3.exe: configuring server automatic mTLS: timestamp=2024-07-29T13:48:13.735Z
2024-07-29T13:48:13.777Z [DEBUG] provider: using plugin: version=6
2024-07-29T13:48:13.777Z [DEBUG] provider.terraform-provider-citrix_v0.6.3.exe: plugin address: address=127.0.0.1:10000 network=tcp timestamp=2024-07-29T13:48:13.777Z
2024-07-29T13:48:13.787Z [DEBUG] skipping FixUpBlockAttrs
2024-07-29T13:48:13.790Z [INFO]  provider.terraform-provider-citrix_v0.6.3.exe: Configuring Citrix Cloud client: tf_provider_addr=registry.terraform.io/citrix/citrix tf_req_id=a7f3953c-e50f-f238-6f77-8836fd87953c tf_rpc=ConfigureProvider @caller=github.com/citrix/terraform-provider-citrix/internal/provider/provider.go:325 @module=citrix timestamp=2024-07-29T13:48:13.790Z
2024-07-29T13:48:13.790Z [INFO]  provider.terraform-provider-citrix_v0.6.3.exe: Configured Citrix API client: tf_rpc=ConfigureProvider @caller=github.com/citrix/terraform-provider-citrix/internal/provider/provider.go:698 success=true tf_provider_addr=registry.terraform.io/citrix/citrix tf_req_id=a7f3953c-e50f-f238-6f77-8836fd87953c @module=citrix timestamp=2024-07-29T13:48:13.790Z
2024-07-29T13:48:13.791Z [DEBUG] skipping FixUpBlockAttrs
2024-07-29T13:48:13.796Z [DEBUG] provider.terraform-provider-citrix_v0.6.3.exe: Marking Computed attributes with null configuration values as unknown (known after apply) in the plan to prevent potential Terraform errors: tf_req_id=50d02ce2-1dae-1c50-17fa-d96c885660fe tf_resource_type=citrix_stf_roaming_gateway @caller=github.com/hashicorp/terraform-plugin-framework@v1.10.0/internal/fwserver/server_planresourcechange.go:217 @module=sdk.framework tf_provider_addr=registry.terraform.io/citrix/citrix tf_rpc=PlanResourceChange timestamp=2024-07-29T13:48:13.795Z
2024-07-29T13:48:13.796Z [DEBUG] provider.terraform-provider-citrix_v0.6.3.exe: marking computed attribute that is null in the config as unknown: @module=sdk.framework tf_req_id=50d02ce2-1dae-1c50-17fa-d96c885660fe tf_rpc=PlanResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.10.0/internal/fwserver/server_planresourcechange.go:467 tf_attribute_path="AttributeName(\"deployment\")" tf_provider_addr=registry.terraform.io/citrix/citrix tf_resource_type=citrix_stf_roaming_gateway timestamp=2024-07-29T13:48:13.796Z
2024-07-29T13:48:13.796Z [DEBUG] provider.terraform-provider-citrix_v0.6.3.exe: marking computed attribute that is null in the config as unknown: tf_attribute_path="AttributeName(\"secure_ticket_authority_urls\").ElementKeyInt(0).AttributeName(\"authority_id\")" tf_req_id=50d02ce2-1dae-1c50-17fa-d96c885660fe tf_resource_type=citrix_stf_roaming_gateway @caller=github.com/hashicorp/terraform-plugin-framework@v1.10.0/internal/fwserver/server_planresourcechange.go:467 tf_provider_addr=registry.terraform.io/citrix/citrix tf_rpc=PlanResourceChange @module=sdk.framework timestamp=2024-07-29T13:48:13.796Z
2024-07-29T13:48:13.796Z [DEBUG] provider.terraform-provider-citrix_v0.6.3.exe: marking computed attribute that is null in the config as unknown: tf_attribute_path="AttributeName(\"edition\")" tf_req_id=50d02ce2-1dae-1c50-17fa-d96c885660fe tf_resource_type=citrix_stf_roaming_gateway tf_rpc=PlanResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.10.0/internal/fwserver/server_planresourcechange.go:467 @module=sdk.framework tf_provider_addr=registry.terraform.io/citrix/citrix timestamp=2024-07-29T13:48:13.796Z
2024-07-29T13:48:13.798Z [INFO]  Starting apply for citrix_stf_roaming_gateway.example-stf-roaming-gateway
2024-07-29T13:48:13.798Z [DEBUG] skipping FixUpBlockAttrs
2024-07-29T13:48:13.798Z [DEBUG] citrix_stf_roaming_gateway.example-stf-roaming-gateway: applying the planned Create change
2024-07-29T13:48:13.801Z [ERROR] provider.terraform-provider-citrix_v0.6.3.exe: Response contains error diagnostic: tf_provider_addr=registry.terraform.io/citrix/citrix tf_req_id=bbde51a2-c83f-f5b9-4573-fdedcb0daa55 @module=sdk.proto
  diagnostic_detail=
  | An unexpected error occurred in runtime.panicmem.
  | 
  | runtime error: invalid memory address or nil pointer dereference
  | 
  | Please report this issue to the project maintainers and include this file if present: C:\Users\ADVMAD~1\AppData\Local\Temp\citrix_provider_crash_stack.1004430499.txt
   diagnostic_severity=ERROR diagnostic_summary="Unexpected error in the Citrix provider" tf_proto_version=6.6 tf_resource_type=citrix_stf_roaming_gateway @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/diag/diagnostics.go:58 tf_rpc=ApplyResourceChange timestamp=2024-07-29T13:48:13.801Z
2024-07-29T13:48:13.811Z [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-07-29T13:48:13.811Z [ERROR] vertex "citrix_stf_roaming_gateway.example-stf-roaming-gateway" error: Unexpected error in the Citrix provider
2024-07-29T13:48:13.820Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-07-29T13:48:13.823Z [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/citrix/citrix/0.6.3/windows_amd64/terraform-provider-citrix_v0.6.3.exe id=6988
2024-07-29T13:48:13.823Z [DEBUG] provider: plugin exited

cmd:

set TF_LOG="DEBUG"
set TF_LOG_PATH="./citrix-provider-issue.txt"
terraform <command>

Powershell:

$env:TF_LOG="DEBUG"
$env:TF_LOG_PATH="./citrix-provider-issue.txt"
terraform <command>

bash:

export TF_LOG="DEBUG"
export TF_LOG_PATH="./citrix-provider-issue.txt"
terraform <command>
aneeshk-citrix commented 1 month ago

Hi @dimi4ik,

It seems that the example is incorrect. secure_ticket_authority_urls needs to be a list of objects, the schema for which can be found here - https://registry.terraform.io/providers/citrix/citrix/latest/docs/resources/stf_roaming_gateway#nested-schema-for-secure_ticket_authority_urls

Please let us know if you are able to get it working with this change.

We'll work on fixing the documentation example and also look into the issue you're facing with import.

Thanks for trying out and reporting this issue!

Aneesh

dimi4ik commented 1 month ago

Hi @aneeshk-citrix

Thank you for the quick response πŸ‘

When I enter secure_ticket_authority_urls as a list of objects in the Terraform file, I get the following error:

β”‚ Error: Invalid Attribute Value Length β”‚ β”‚ with citrix_stf_roaming_gateway.example-stf-roaming-gateway, β”‚ on main.tf line 166, in resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway": β”‚ 166: resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway" { β”‚ β”‚ Attribute secure_ticket_authority_urls[0].sta_validation_secret string length must be at least 1, got: 0

Where do I get the value for sta_validation_secret?

Terraform configuration files

resource "citrix_stf_roaming_gateway" "example-stf-roaming-gateway" {
  site_id                        = citrix_stf_deployment.stf_deployment_0.site_id
  name                           = "Example Roaming Gateway Name"
  logon_type                     = "Domain"
  smart_card_fallback_logon_type = "None"
  gateway_url                    = "https://example.gateway.com/"
  #callback_url                   = "https://exampleremote.callback.com/"
  version              = "Version10_0_69_4"
  subnet_ip_address    = "10.0.0.1"
  stas_bypass_duration = "0.1:0:0"
  #gslb_url                       = "https://example.gslb.url"
  session_reliability     = false
  request_ticket_two_stas = false
  stas_use_load_balancing = false
  is_cloud_gateway        = false

  secure_ticket_authority_urls   = [
        {
            authority_id           = null
            sta_url                = "https://ctx-ddc.cloud.com/scripts/ctxsta.dll"
            sta_validation_enabled = false
            sta_validation_secret  = ""
        }
    ]
}
aneeshk-citrix commented 1 month ago

Hi @dimi4ik,

Looks like sta_validation_secret can be optional but if we have it set to Required. We're working on a fix for this and should have all of these issue fixed in the next release.

Thanks, Aneesh