bitter-salesclerk-37287
11/02/2022, 8:10 PMpulumi up
from my laptop, and have the service running with the proper configurations. (?)billowy-army-68599
11/02/2022, 8:12 PMbitter-salesclerk-37287
11/02/2022, 11:15 PMenvironment
property in serverless.yml
from Serverless Framework. That’s what I’m doing right now… it doesn’t seem like what you linked has a place for general environment variables that my service (and dependent utility library) would require… but maybe I’m misreading/misunderstanding.billowy-army-68599
11/02/2022, 11:46 PMbitter-salesclerk-37287
11/03/2022, 12:06 AMprocess.env
or Python as os.environ
etc…
I guess I overlooked this due to all the CLI commands, but on closer read, I see that they’re defined in the Pulumi.*.yaml files. Thanks / sorry for missing that documentation page earlier.billowy-army-68599
11/03/2022, 12:10 AMos.environ
will retrive them as normal because at the end of the day it’s just pythonbitter-salesclerk-37287
11/03/2022, 4:49 PMname: service-name
description: blah...
runtime: nodejs
config:
aws:region: us-east-1
env:
varName: 'whatever'
and I can access it fine using
import { env } from 'node:process';
const config = new pulumi.Config();
const envVars = config.requireObject('env');
Object.entries(envVars as any).forEach(([name, value]) => {
env[name] = String(value);
});
but… like, I’m not sure how to actually see the values when I type `console.debug(process.env)`… How do I get my consuming code, the code that is included as a dependency library within my function deployed in AWS Lambda, that expects certain environment variables to be set, to read these configurations?… At this point, they don’t truly seem to be environment variables in the usual sense, such that they can be accessed via, eg, process.env.varName
.billowy-army-68599
11/03/2022, 4:54 PMprocess.env.varName
in your code
I suggested configuration as a method to pass values to your program that you might needbitter-salesclerk-37287
11/03/2022, 5:00 PMbillowy-army-68599
11/03/2022, 5:19 PMexport MY_VAR="foo"
or inside pulumi? whatever you’d use for your languagebitter-salesclerk-37287
11/03/2022, 5:54 PMimport * as pulumi from '@pulumi/pulumi';
import { fxRateUpdater } from './useCases/cmsUpdater/fxRateUpdater';
const serviceName = 'cms-updater';
const config = new pulumi.Config();
const envVars = config.requireObject('env');
const lambda = new aws.lambda.CallbackFunction(`${serviceName}-lambda`, {
policies: [aws.iam.ManagedPolicies.CloudWatchLogsFullAccess],
environment: {
variables: {
...envVars as any,
},
},
callback: fxRateUpdater,
});
… worked like a charm! Neat way to separate the environment vars from the actual index.ts code, by separating out into a separate Pulumi.*.yaml file, as you’d directed me toward yesterday!