Environment variable of serverless computing

I am trying to test rust compiled wasm on 2 Chinese serverless computing platform, if the language is nodejs, I can get environment variable by

    var value = process.env.myKey

Same as Amazon lambda. According to Amazon rust lambda's doc, I should be able to get it by std::env::var("myKey"), so I tried the same on the 2 platform, both returned error of not exist. Then I tried to list all variables by:

    let mut varsOut:HashMap<String, String> = HashMap::new();
    for (key, value) in env::vars() {
        varsOut.insert(key, value);

There is no problem to compile my code, just got error on console of the 2 platforms like this:
{"errorMessage":"unreachable","errorType":"RuntimeError","stackTrace":["at wasm-function[44]:273","at wasm-function[86]:39","at wasm-function[80]:40","at wasm-function[85]:41","at wasm-function[14]:882","at wasm-function[131]:5","at module.exports.hello (/var/task/wasm.js:184:20)","at Interface.emit (events.js:196:13)"]}

I think I can first get the variable by some nodejs code, then wrap the wasm, but is there any other way to get it by rust?


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.