terraform-community-providers / terraform-provider-railway

Terraform provider for railway.app
https://registry.terraform.io/providers/terraform-community-providers/railway/latest/docs
Mozilla Public License 2.0
22 stars 1 forks source link

Error Deploying Variable in Railway: Client Error on railway_variable #20

Closed alexraskin closed 6 months ago

alexraskin commented 7 months ago

I'm encountering a client error when attempting to deploy a variable using Terraform with the Railway provider. The goal is to set up a railway_variable resource for a Tailscale authentication key. I've tried two approaches: directly using the output from another resource and hardcoding a test value. Both methods result in the same client error during the apply phase.

Environment

Terraform Version: 1.6.6 Railway Provider Version: 0.3.1 Error encountered in both a direct assignment from another resource and hardcoded value scenarios.

Attempt 1: Using output from another resource

resource "railway_variable" "tailscale_auth_key" {
  name           = "TAILSCALE_AUTHKEY"
  value          = tailscale_tailnet_key.tailscale_auth_key.id
  environment_id = railway_project.tailscale_vpn.id
  service_id     = railway_service.tailscale_vpn.id
  depends_on     = [tailscale_tailnet_key.tailscale_auth_key]
}

Attempt 2: Hardcoding the value

resource "railway_variable" "tailscale_auth_key" {
  name           = "TAILSCALE_AUTHKEY"
  value          = "test"
  environment_id = railway_project.tailscale_vpn.id
  service_id     = railway_service.tailscale_vpn.id
  depends_on     = [tailscale_tailnet_key.tailscale_auth_key]
}

Error Message

│ Error: Client Error
│ 
│   with railway_variable.tailscale_auth_key,
│   on main.tf line 40, in resource "railway_variable" "tailscale_auth_key":
│   40: resource "railway_variable" "tailscale_auth_key" {
│ 
│ Unable to create variable, got error: input: Problem processing request

Steps to Reproduce

Define a railway_variable resource in Terraform configuration. Run terraform apply to deploy the changes. Observe the "Client Error" output during the apply phase.

Expected Behavior

The variable should be created successfully in the Railway environment without errors.

Actual Behavior

Receiving a "Client Error" indicating a problem processing the request, preventing the variable from being created.

Additional Context

I'm unsure if there have been recent changes to the Railway API that might be affecting this functionality. Looking for advice on whether there's a workaround or if a fix is needed on the provider's side. Would appreciate any insights or suggestions on how to resolve this issue. Thank you!

Funding

Fund with Polar

pksunkara commented 7 months ago
  1. I don't see any changes to the API.
  2. I haven't been able to reproduce this because the variable tests are passing.

It could be a one-off error or something related to your settings. Could you try again and let me know?

alexraskin commented 7 months ago

It could be a one-off error or something related to your settings. Could you try again and let me know?

Thanks for getting back to me..

So I tested again and I am getting the same result.

I also tried testing using locals.

locals {
  auth_key = tailscale_tailnet_key.tailscale_auth_key.key
}

I am not sure what else this could be.

Thanks for your help!

pksunkara commented 7 months ago
  1. Do you have permission to create a variable on the UI?
  2. Do you have any feature flags turned on in railway?
  3. I don't think the terraform version should be a problem.
pksunkara commented 6 months ago

@alexraskin Is this still an issue?

alexraskin commented 6 months ago

Hello, yes, I am still getting an error. Sorry I haven't updated lately, been busy.

pksunkara commented 6 months ago

@wertlex Did you encounter this issue in your recent contributions?

wertlex commented 6 months ago

@pksunkara no, not really. I never seen this issue in the wild However, if I'll face something like that I'll at least report it here

wertlex commented 6 months ago

Okay, I figured it out. It seems like a problem of exact HCL. project_id was used as environment_id:

resource "railway_variable" "tailscale_auth_key" {
  name           = "TAILSCALE_AUTHKEY"
  value          = "test"
  # INCORRECT
  # environment_id = railway_project.tailscale_vpn.id 
  # SOMETHING LIKE THIS SHOULD WORK
  environment_id = railway_project.tailscale_vpn.default_environment.id 
  service_id     = railway_service.tailscale_vpn.id
  depends_on     = [tailscale_tailnet_key.tailscale_auth_key]
}
alexraskin commented 6 months ago

Okay, I figured it out. It seems like a problem of exact HCL. project_id was used as environment_id:

resource "railway_variable" "tailscale_auth_key" {
  name           = "TAILSCALE_AUTHKEY"
  value          = "test"
  # INCORRECT
  # environment_id = railway_project.tailscale_vpn.id 
  # SOMETHING LIKE THIS SHOULD WORK
  environment_id = railway_project.tailscale_vpn.default_environment.id 
  service_id     = railway_service.tailscale_vpn.id
  depends_on     = [tailscale_tailnet_key.tailscale_auth_key]
}

Okay, let me give this a go, thank you

pksunkara commented 6 months ago

Yup, that would give error. Sorry, I missed that.

Thanks @wertlex

@alexraskin I am closing this. Feel free to comment here if that doesn't fix your error.