https://pulumi.com logo
#esc
Title
# esc
s

square-winter-77440

01/21/2024, 8:41 AM
🧵 For help integrating IaC and ESC with a Go project...
Hello! I'm having a difficult time migrating over some GCP IaC config into ESC.. currently we have a stack with a simple config defintion.. here's a snippet of that with identifying bits redacted (DM me if you need more/defining info)...
Copy code
name: project-xxxx-staging
secretsprovider: xxxx
encryptedkey: xxxx
environment:
  - staging
config:
  gcp:project: xxxx-staging
  project-xxxx:API_KEY:
    secure: xxxx
I created an environment in our org called
staging
and have set the following, note that I've removed the
gcp
configuration for readability purposes, but I don't suspect that to be the issue as
esc open xxxx/staging
works with no issue.
Copy code
❯ esc open xxxx/staging -f yaml
config:
   API_BASE_URL: xxxx
   project-xxxx-staging:API_BASE_URL: xxxx
   project-xxxx:API_BASE_URL: xxxx
In our IaC Go code we have the following function (simplified for triaging)...
Copy code
func (i *Infra) baseEnvVars() pulumi.StringMap { // *Infra is a custom type that has a config field of *config.Config (not exported)
  return pulumi.StringMap{
    // Backend API
    "API_BASE_URL": i.config.RequireSecret("API_BASE_URL"),
  }
}
Now when I run
Copy code
esc run xxxx/staging -- pulumi preview -s staging
I get a panic with the following message...
Copy code
Diagnostics:
  pulumi:pulumi:Stack (project-xxxx-staging):
    panic: Missing required configuration variable 'project-xxxx:API_BASE_URL'
      please set a value using the command `pulumi config set project-xxxx:API_BASE_URL <value>`
What is unclear to me is how we're supposed to set/reference config values from ESC... the docs don't see to cover this from what I've been able to find. I've tried the Pulumi AI route, it wasn't very helpful.. Can anyone help point me in the right direction, be it code or docs? I am probably misunderstanding something simple. :) Thank you!
r

red-match-15116

01/21/2024, 7:49 PM
What does your environment look like? You’ll want anything that you want as pulumi configuration to be under the values.pulumiConfig key in your environment definition.
You also don’t need to use esc run when running your pulumi preview, just running the pulumi command will automatically open the environment defined in the stack configuration file
Looks like maybe your environment has a “config” key. That should be “pulumiConfig”.
s

square-winter-77440

01/21/2024, 9:47 PM
@red-match-15116 Thank you, I'll give that a shot! 🙂
@red-match-15116 That was it! Thank you so much!
r

red-match-15116

01/21/2024, 10:20 PM
Np! Happy to help 🙂