terraform-aws-gitlab-runner icon indicating copy to clipboard operation
terraform-aws-gitlab-runner copied to clipboard

Can not assign subnets during execution "terraform plan"

Open kostyanius opened this issue 3 years ago • 13 comments
trafficstars

Error: Variables not allowed │ │ on line 1: │ (source code not available) │ │ Variables may not be used here. ╵ ╷ │ Error: No value for required variable │ │ on variables.tf line 27: │ 27: variable "subnet_ids_gitlab_runner" { │ │ The root module input variable "subnet_ids_gitlab_runner" is not set, and has no default value. Use a -var or │ -var-file command line argument to provide a value for this variable.

if to hardcode the value in the variables.tf than error changes to the following:

│ Error: Variables not allowed │ │ on line 1: │ (source code not available) │ │ Variables may not be used here. ╵ ╷ │ Error: No value for required variable │ │ on variables.tf line 28: │ 28: variable "subnet_ids_gitlab_runner" { │ │ The root module input variable "subnet_ids_gitlab_runner" is not set, and has no default value. Use a -var or │ -var-file command line argument to provide a value for this variable. ╵

kostyanius avatar Nov 24 '21 08:11 kostyanius

Are you using one of the examples?

npalm avatar Dec 01 '21 23:12 npalm

i tried to do it from scratch and also checked examples. both cases do not work for me. so looks like there is an issue with subnets.

kostyanius avatar Dec 02 '21 00:12 kostyanius

Do you have step by step instructions to reproduce the problem? Like: git clone something && run something? Hard to say what's going wrong without seeing your console.

kayman-mk avatar Dec 09 '21 13:12 kayman-mk

@kostyanius still having the issues. Our deployment relies also on predefined subnets and we having no issues.

npalm avatar Dec 09 '21 22:12 npalm

Hello folks. Thanks for your updates. I will record the video tomorrow for you all to show the issue i am facing with during this setup. Sorry for delay in my response. Was busy.

kostyanius avatar Dec 09 '21 22:12 kostyanius

image I actually do not understand the difference in this: subnet_ids_gitlab_runner = module.vpc.private_subnets subnet_id_runners = element(module.vpc.private_subnets, 0) could it be the same subnet in both cases? only private allowed or public as well (with internet gateway)? and subnet-id or subnet-name should be provided? i am using sublet_id only in both cases, but anyway it fails. and no matter if to use the list with the [ ] or without the brackets. should each subnet be separated with whitespace after comma or not? please advise cause i have stuck here.

kostyanius avatar Dec 13 '21 15:12 kostyanius

Hey Any updates on this? Thanks.

kostyanius avatar Dec 22 '21 10:12 kostyanius

@kostyanius Variable names and descriptions can be improved, yes.

variable "subnet_id_runners" {
  description = "List of subnets used for hosting the gitlab-runners."
  type        = string
}

variable "subnet_ids_gitlab_runner" {
  description = "Subnet used for hosting the GitLab runner."
  type        = list(string)
}

So the subnet_id_runners is a single subnet, no list. subnet_ids_gitlab_runner is a list of subnets.

kayman-mk avatar Dec 28 '21 15:12 kayman-mk

Thanks but it is excess configuration anyway and in my case does not work for one subnet or for many of them. Why do we need such duplicate subnet or subnets? Only one of them is enough i believe. I have tried all the examples and only managed to run it for the new vpc and subnet. But it does not work for the existing vpc and subnets.

kostyanius avatar Dec 28 '21 16:12 kostyanius

Good point. And looking at my configuration I am using the same subnet for both, thus making sure that the runner agent (manager) is placed in the same subnet as the the runners (workers). Anything else doesn't make sense from my point of view.

You definitely have to provide both. As far as I can see, subnet_ids_gitlab_runner refers to the agent and subnet_id_runners to the workers.

It does work for existing VPCs and subnets. May be the aws_region, vpc_id, subnet_ids_gitlab_runners and subnet_id_runners are from different VPCs? Any subtle error or so?

kayman-mk avatar Dec 28 '21 16:12 kayman-mk

Hello @kayman-mk No, aws region, vpn and subnets are correct. Subnets corresponds with vpc and vice versa. I have tried on two different vpc and subnets. I even tried to type vpn and subnets name but got the same error as for typing vpc and subnets id as it was initially. Looks strange. I even tried to run it with sudo, but it didn`t help. So, still do not know where is an issue may be. ( image

kostyanius avatar Jan 03 '22 11:01 kostyanius

i tried to change list(string) to string type for subnet_ids_gitlab_runners and managed to pass to another step, but then also failed with the next error: image Thereby i believe the problem is in subnet_ids gitlab runners section. Please advise how to type in correctly, what format should be? with comma as separators or with comma and whitespaces or just with whitespaces or another symbols or with "" or with [ .. ], e.t.c.

kostyanius avatar Jan 03 '22 11:01 kostyanius

I think it would be a good idea to place the variables in a file so it becomes easier to test with different setups and running terraform plan -var-file my-vars.tfvars

aws_region = "eu-west-2"
vpc_id = "vpc-1234"
subnet_id_runners = "subnet-2345"
subnet_ids_gitlab_runner = ["subnet-2345"]
...

subnet_ids_gitlab_runner is a list of strings and not a string.

kayman-mk avatar Jan 05 '22 12:01 kayman-mk

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Jan 01 '23 03:01 github-actions[bot]

This issue was closed because it has been stalled for 15 days with no activity.

github-actions[bot] avatar Jan 17 '23 02:01 github-actions[bot]