Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for amiFilters is wrong #4345

Open
mattgodbolt opened this issue Jan 9, 2025 · 2 comments
Open

Documentation for amiFilters is wrong #4345

mattgodbolt opened this issue Jan 9, 2025 · 2 comments

Comments

@mattgodbolt
Copy link

mattgodbolt commented Jan 9, 2025

EDIT: this is a documentation issue, see the end.


was

Hi all - I'm not sure if this is a terraform bug, a GH runner bug or a me bug. We've been using this project for years (thank you!) and accumulating AMIs.

I turned on the cleaner (dryRun = true) and saw it wanted to delete a bunch of AMIs it didn't create (and I need), so I added a filter. But... when I add the filters = [...] stanza, and terraform apply - I get:

No changes. Your infrastructure matches the configuration.

which ... makes me wonder if I'm doing something wrong! Or if somehow the filters are being dropped and thus there's no change to apply.

We're using the multi-runner. Full config here:

locals {
  environment = "ce-ci"
  aws_region  = "us-east-1"

  # Load runner configurations from Yaml files
  multi_runner_config = { for c in fileset("${path.module}/templates/runner-configs", "*.yaml") : trimsuffix(c, ".yaml") => yamldecode(file("${path.module}/templates/runner-configs/${c}")) }
}

resource "random_password" "random" {
  length = 28
}

resource "random_id" "random" {
  byte_length = 20
}

module "multi-runner" {
  # The double-slash is needed: https://developer.hashicorp.com/terraform/language/modules/sources#modules-in-package-sub-directories
  source              = "philips-labs/github-runner/aws//modules/multi-runner"
  version             = "v6.0.1"
  multi_runner_config = local.multi_runner_config
  aws_region          = local.aws_region
  vpc_id              = "vpc-17209172"
  subnet_ids = [
    "subnet-690ed81e",
    "subnet-1bed1d42",
    "subnet-1df1e135",
    "subnet-0b7ecd0395d5f2cc9",
    "subnet-00fe4d85550ee828d"
  ]
  enable_ami_housekeeper = true
  ami_housekeeper_cleanup_config = {
    dryRun = true
    filters = [
      {
        Name   = "tag:Subsystem"
        Values = ["CI2"]
      }
    ]
  }
  runners_scale_up_lambda_timeout   = 60
  runners_scale_down_lambda_timeout = 60
  prefix                            = local.environment
  tags = {
    Site      = "CompilerExplorer"
    Subsystem = "CI"
  }
  github_app = {
    key_base64     = jsondecode(data.aws_secretsmanager_secret_version.ce_ci.secret_string)["github_app_key_base64"]
    id             = var.github_app_id
    webhook_secret = random_password.random.result
  }

  webhook_lambda_zip                = "lambdas-download/webhook.zip"
  runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
  runners_lambda_zip                = "lambdas-download/runners.zip"
  ami_housekeeper_lambda_zip        = "lambdas-download/ami-housekeeper.zip"
}

Thankfully the dryRun = true DOES work and changes the config.

Any ideas what I'm doing wrong?

@mattgodbolt
Copy link
Author

(here the thing I'm editing is the Values = ["CI2"] line (the 2 here was me mutating it just to see if anything changed. It did not.

I disabled , applied and re-enabled and noticed:

      + environment {
          + variables = {
              + "AMI_CLEANUP_OPTIONS"                      = jsonencode(
                    {
                      + amiFilters          = [
                          + {
                              + Name   = "state"
                              + Values = [
                                  + "available",
                                ]
                            },
                          + {
                              + Name   = "image-type"
                              + Values = [
                                  + "machine",
                                ]
                            },
                        ]
                      + dryRun              = true
                      + launchTemplateNames = null
                      + maxItems            = null
                      + minimumDaysOld      = 30
                      + ssmParameterNames   = null
                    }
                )
              + "LOG_LEVEL"                                = "info"
              + "POWERTOOLS_LOGGER_LOG_EVENT"              = "false"
              + "POWERTOOLS_SERVICE_NAME"                  = "ami-housekeeper"
              + "POWERTOOLS_TRACER_CAPTURE_ERROR"          = "false"
              + "POWERTOOLS_TRACER_CAPTURE_HTTPS_REQUESTS" = "false"
              + "POWERTOOLS_TRACE_ENABLED"                 = "false"
            }

in the terraform application the amiFilters don't seem to invlude the filters

@mattgodbolt
Copy link
Author

AH!!!

It should be amiFilters!!!

The docs are wrong: https://philips-labs.github.io/terraform-aws-github-runner/modules/public/ami-housekeeper/ says to use filters = !!

@mattgodbolt mattgodbolt changed the title ami_housekeeper_cleanup_config issue Documentation for amiFilters is wrong Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant