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

Help with set variables via gitlab-ci #3081

Open
masbolgankezderim opened this issue Apr 22, 2024 · 0 comments
Open

Help with set variables via gitlab-ci #3081

masbolgankezderim opened this issue Apr 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@masbolgankezderim
Copy link

Describe the bug
I cannot set variables via gitlab-ci

deploy:
  stage: deploy-test
  image: 
    name: alpine/terragrunt:1.8.1
  before_script:
    - terragrunt plan -var="function_name=${PROJECT_NAME}" -var="image_uri=123456789.dkr.ecr.${ECR_REGION}.amazonaws.com/${CI_PROJECT_NAME}:${PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}"
  script:
    - terragrunt apply -var="function_name=${PROJECT_NAME}" -var="image_uri=123456789.dkr.ecr.${ECR_REGION}.amazonaws.com/${CI_PROJECT_NAME}:${PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}" --auto-approve

terragrunt.hcl

include "root" {
  path = find_in_parent_folders()
}

terraform {
  source = "https://github.com/terraform-aws-modules/terraform-aws-lambda.git"
}

inputs = {
  function_name   = "var.function_name"
  description     = "My awesome lambda function 5555555"
  create_package  = false
  image_uri       = "var.image_uri"
  package_type    = "Image"
}

terragrunt.hcl in root folder

remote_state {
  backend = "s3"
  generate = {
    path      = "backend.tf"
    if_exists = "overwrite"
  }
  config = {
    bucket         = "test-bucket"
    key            = "${path_relative_to_include()}/terraform.tfstate"
    region         = "eu-north-1"
    encrypt        = true
  }
}

Nice to have

╷
│ Error: Value for undeclared variable
│ 
│ A variable named "function_name" was assigned on the command line, but the
│ root module does not declare a variable of that name. To use this value,
│ add a "variable" block to the configuration.
╵
╷
│ Error: Value for undeclared variable
│ 
│ A variable named "image_uri" was assigned on the command line, but the root
│ module does not declare a variable of that name. To use this value, add a
│ "variable" block to the configuration.
╵
time=2024-04-18T09:26:[30](https://gitlab-test.dev/test-ops/-/jobs/127566#L30)Z level=error
time=2024-04-18T09:26:30Z level=error 
ERROR: Job failed: exit code 1

Screenshot
Screenshot 2024-04-22 at 13 14 54

Versions

  • Terragrunt version: 0.57.2
  • Terraform version: v1.2.5
@masbolgankezderim masbolgankezderim added the bug Something isn't working label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant