https://garden.io logo
#🌱|help-and-getting-started
Runtime.services.[deploy-action-name].outputs.[output_variable] value not referenceable
# 🌱|help-and-getting-started
m

many-pizza-75746

01/18/2024, 7:33 AM
Hi. I'm having trouble trying to figure out what to use instead of this output variable template as the documentation for 0.13 does not mention what to use instead. This variable is for the purpose of referencing Terraform outputs inside a Kubernetes deployment manifest. The value that comes out of referencing the variable is a literal "${runtime.services.deploy.outputs.environment_name}" instead of "dev" (example).
q

quaint-dress-831

01/18/2024, 8:26 AM
@many-pizza-75746 what happens if you use the variable kapa gave you?
Or if I'm understanding you correctly the variable never interpolates
m

many-pizza-75746

01/18/2024, 8:27 AM
i will still get the template as a string literal
yes
q

quaint-dress-831

01/18/2024, 8:27 AM
Can you please print a sanitized YAML for me?
m

many-pizza-75746

01/18/2024, 8:28 AM
oh Im not at my laptop at the moment but I'll be able to get back to you on that
what commands would I need to run?
q

quaint-dress-831

01/18/2024, 8:28 AM
I just need a look at your relevant Garden config files
m

many-pizza-75746

01/18/2024, 8:29 AM
runtime.services.foo.outputs was usable in 0.12 has this changed in 0.13?
alright I'll grab that for you when available
q

quaint-dress-831

01/18/2024, 8:29 AM
Thank you, happy to take a look!
m

many-pizza-75746

01/18/2024, 8:30 AM
sorry but which command would I need to run?
for the output you are looking for
q

quaint-dress-831

01/18/2024, 8:31 AM
I just need the Garden config files around your Kubernetes manifests
m

many-pizza-75746

01/18/2024, 8:31 AM
alright
q

quaint-dress-831

01/18/2024, 8:31 AM
So any
garden.yml
files you have
m

many-pizza-75746

01/18/2024, 8:59 AM
garden.yml (terraform provider folder)
Copy code
kind: Deploy
description: AWS Shared Product Infrastructure
type: terraform
name: infrastructure-aws

variables:
  use_default_passwords: true
garden.yml (server deploy folder)
Copy code
kind: Deploy
type: kubernetes
name: server
disabled: ${!var.connect.enabled}

include:
  - "*"

spec:  
  files:
    - deployment.yaml
    - service.yaml
    - hpa.yaml
    - ingress.yaml
    - pdb.yaml

variables:
  tls-suffix: "${var.acme.production ? 'prod' : 'staging'}"
  issuer: 'letsencrypt-issuer-staging'

dependencies:
  - deploy.gitlab-registry
  - deploy.letsencrypt-issuer-staging
  - deploy.letsencrypt-issuer-prod
  - deploy.infrastructure-aws
  - deploy.redis
  - run.server-migrate

---
kind: Run
type: kubernetes-pod
name: server-migrate
dependencies:
  - deploy.gitlab-registry
  - deploy.server-pg
  - deploy.keycloak
  - deploy.redis
disabled: ${var.server.migration.action == 'reseed'}
spec:
  resource:
      kind: "Deployment"
      name: server
  files:
    - deployment.yaml
  command: ["yarn"]
  args: ["db:migrate"]
  env:
    DD_SERVICE: "server.migration"
in the deployment.yaml I have something like this
Copy code
- name: ADMIN_PASSWORD
              value: "${runtime.services.infrastructure-aws.outputs.admin_password}"
this runtime.services variable is supposed to reference the terraform output ADMIN_PASSWORD
and what comes out of ADMIN_PASSWORD is not the actual password but a literal string of "${runtime.services.infrastructure-aws.outputs.admin_password}"
q

quaint-dress-831

01/18/2024, 9:03 AM
What if you remove the quotes?
m

many-pizza-75746

01/18/2024, 9:04 AM
doesnt change anything
im not able to work on this right now but I just grabbed the files so that you can take a look
q

quaint-dress-831

01/18/2024, 9:05 AM
Can we try and swap out the entire variable for one just for testing say ${var.issuer} ?
m

many-pizza-75746

01/18/2024, 9:06 AM
I have tried that and it works but when I reran the deploy command it did not reference that value from the terraform outputs
I also tried to reference with provider.outputs on the project file but that didn't work as I believe it's a syntax error
q

quaint-dress-831

01/18/2024, 9:08 AM
So you tried with ${providers.terraform.outputs.infrastructure-aws.admin-password} ?
Ah I see the issue (I think)
m

many-pizza-75746

01/18/2024, 9:11 AM
yup
q

quaint-dress-831

01/18/2024, 9:11 AM
This is using a Deploy action. There's two types of Terraform providers
One at the provider level and one at the action level
m

many-pizza-75746

01/18/2024, 9:12 AM
and it would appear as "${providers.terraform.outputs.infrastructure-aws.admin-password}"
would this mean that it would have to be a module instead?
that was not stated clearly in the docs
q

quaint-dress-831

01/18/2024, 9:13 AM
Actions can only reference other action variables
So for example publishId: ${actions.deploy.my-terraform.outputs.gcp_repository_url}/api
m

mammoth-flag-56137

01/18/2024, 9:14 AM
then you get weird stuff happening with special characters
q

quaint-dress-831

01/18/2024, 9:14 AM
Is a valid variable
m

many-pizza-75746

01/18/2024, 9:14 AM
hmm
how would I be able to reference terraform outputs in this case?
q

quaint-dress-831

01/18/2024, 9:14 AM
You just do it as I formatted it above for the publishId
Is it your kubernetes-pod action using the variable? It's unclear the way it came through
If so, you should be free to reference the terraform action
m

mammoth-flag-56137

01/18/2024, 9:16 AM
server-migrate isnt listing infrastructure-aws in dependencies in your code block above
q

quaint-dress-831

01/18/2024, 9:17 AM
actions.deploy.infrastructure-aws.outputs
m

many-pizza-75746

01/18/2024, 9:17 AM
Oh I didn't realise that yea that's a really good point
I'll need to check that out tomorrow and try that out
m

mammoth-flag-56137

01/18/2024, 9:17 AM
now stop doing work outside work hours
m

many-pizza-75746

01/18/2024, 9:17 AM
Haha lol
ok thanks for the help guys
q

quaint-dress-831

01/18/2024, 9:18 AM
Any time! Let us know how it goes when you get back to work
m

many-pizza-75746

01/19/2024, 12:54 AM
Morning @quaint-dress-831 I tried changing the variable to that on my deployment.yaml file and it still appeared as the string literal
in this case it's "${actions.deploy.infrastructure-aws.admin_password}"
q

quaint-dress-831

01/19/2024, 6:59 AM
Try "${actions.deploy.infrastructure-aws.outputs.admin_password}"
that's the password field for the database
and it's still showing up as a string literal
q

quaint-dress-831

01/19/2024, 9:23 AM
Can you patch them using the patchResources directive in your garden.yml ?
That's the recommended way of patching in variables. Option 2: using Garden template variables inside Kubernetes manifests may be broken and we'll need to file a bug
m

many-pizza-75746

01/22/2024, 1:02 AM
Hi @quaint-dress-831 it seems like that way allows the variable to be read now so the problem is solved. Just some feedback regarding this feature though, this way feels a lot less flexible than before as in 0.12 it was possible to just list the variables on manifest files and it would allow the terraform outputs to be read on there without needing to add changes to the garden.yaml files. I hope that there is a consideration to return that previous feature in some shape or form as trying to use patchresources in this way can make setting this up cumbersome rather than just applying the variable onto the manifest files. The documentation also needs to be updated with this information as there was no indication for setting up Terraform for garden that the variables need to be set up in this way for the outputs to be readable. Thanks