cattle-ops / terraform-aws-gitlab-runner

Terraform module for AWS GitLab runners on ec2 (spot) instances
https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws
MIT License
581 stars 328 forks source link

Error: no matching EC2 Subnet found on terraform or terragrunt plan command #505

Closed BehbudSh closed 1 year ago

BehbudSh commented 2 years ago

Hi. First of all thanks for this great module.

I've faced an issue when running terragrunt plan command

Error: no matching EC2 Subnet found │ │ with data.aws_subnet.runners, │ on main.tf line 3, in data "aws_subnet" "runners": │ 3: data "aws_subnet" "runners" {

It's because of the resource data "aws_subnet" "runners" { id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners }

I've other dependent resources from subnet_id but they are working as expected with the "mock_outputs" function of the Terragrunt. I have managed to fix it with some changes in the source module. Could you please fix this issue?

My changes: deleted these data resources from the main.tf file

data "aws_subnet" "runners" { id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners } data "aws_availability_zone" "runners" { name = data.aws_subnet.runners.availability_zone }

and assigned variable "subnet _id" directly in the main.tf file as well. Lines 78,79

template_runner_config = templatefile("${path.module}/template/runner-config.tpl", { aws_region = var.aws_region gitlab_url = var.runners_gitlab_url runners_vpc_id = var.vpc_id runners_subnet_id = var.subnet_id runners_aws_zone = 'us-east-1a' ommited ... hardcoded the value of the "runners_aws_zone" for testing purposes :)

Thanks!

kayman-mk commented 2 years ago

Hi @BehbudSh,

not sure if I understand this correctly. Deleting the resources seems to be easy, but how do you know the availability zone of the subnet?

Note: subnet_id_runners and some other variables are deprecated and shouldn't be used anymore. They were removed with #420 to clean up the variable section.

github-actions[bot] commented 1 year ago

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] commented 1 year ago

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