terraform-aws-gitlab-runner
terraform-aws-gitlab-runner copied to clipboard
Can not assign subnets during execution "terraform plan"
Error: Variables not allowed
│
│ on
if to hardcode the value in the variables.tf than error changes to the following:
│ Error: Variables not allowed
│
│ on
Are you using one of the examples?
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.
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.
@kostyanius still having the issues. Our deployment relies also on predefined subnets and we having no issues.
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.
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.
Hey Any updates on this? Thanks.
@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.
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.
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?
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. (

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:
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.
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.
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.
This issue was closed because it has been stalled for 15 days with no activity.