José Ribeiro
06/04/2021, 10:11 PMbucketName from the CDK script to the lambda function. However, when that’s executed locally, the environment definition in function.environment doesn’t get applied (only when this is deployed) and thus I’m stuck with my env vars defined locally. Therefore, my questions are 1) should SST be defining those env vars instead? 2) if not, would you guys have any suggestions on how to make the stack output available to my python code?José Ribeiro
06/04/2021, 11:00 PMMike McCall
06/07/2021, 5:12 AMRiccardo Giorato
06/07/2021, 12:17 PMDennis Dang
06/07/2021, 7:02 PM.env that we use. it's a Nodejs module that reads from the file and adds it to our environment variables. and likewise, when we deploy, i make sure our CI pipeline (Seed) has their own corresponding set of env variables.Dennis Dang
06/07/2021, 7:03 PMJosé Ribeiro
06/07/2021, 7:09 PMDennis Dang
06/07/2021, 8:33 PMFrank
CDK script and local runtime refer to. This is what I think you meant, please correct me if i’m wrong. Imagine this is ur setup:
const bucket = new sst.Bucket(this, "MyBucket");
const fn = new sst.Function(this, "MyFunction", {
handler: "src/lambda.main",
environment: {
BUCKET_NAME: bucket.bucketName,
}
});
And are you saying that on sst deploy, BUCKET_NAME gets resolved correctly. But on sst start, BUCKET_NAME shows as a token value in ur local function?José Ribeiro
06/07/2021, 8:39 PMsst start , `BUCKET_NAME`is not picked up by my local function. It doesn’t show as a token value, it’s just missing altogetherFrank
Frank
BUCKET_NAME should resolve to the actual value even locally, this is likely what @Dennis Dang is seeing with Node runtime.José Ribeiro
06/07/2021, 8:43 PMFrank
José Ribeiro
06/07/2021, 8:45 PMFrank
os.environ['BUCKET_NAME']José Ribeiro
06/07/2021, 8:51 PMos.environFrank
Frank
// MyStack.js
const api = new sst.Api(this, "Api", {
defaultFunctionProps: {
srcPath: "src",
runtime: lambda.Runtime.PYTHON_3_8,
environment: {
TABLE_NAME: table.tableName,
},
},
routes: {
"GET /": "handler.main"
},
});
// handler.py
import os
def helloA(event, context):
return {
"statusCode": 200,
"body": os.environ["TABLE_NAME"]
}Frank
sst startFrank
José Ribeiro
06/08/2021, 1:59 AMcache.bucketName instead of cache.s3Bucket.bucketNameJosé Ribeiro
06/08/2021, 2:00 AMFrank
cache.bucketName should work.. that was put in a couple of releases backJosé Ribeiro
06/08/2021, 2:03 AMv0.24.0 . But I could also have done something else wrong.Frank
cache.bucketName isn’t there. I’m going to add it into the release today.José Ribeiro
06/08/2021, 6:48 PMFrank
cache.bucketName and cache.bucketArn in v0.25.1