but I'm getting an undefined error at runtime
# general
b
but I'm getting an undefined error at runtime
w
I would have expected this to work too. If you
console.log(process.env[“ARM_TENANT_ID”]])
what do you see?
b
Copy code
$ env | grep TENANT
ARM_TENANT_ID=11111111-1111-1111-111111111111

$ cat index.ts | grep -i tenant
console.log(process.env["ARM_TENANT_ID"]);
        tenantId: azure_conf.tenantId,

$ pulumi up
... 

Diagnostics:
  pulumi:pulumi:Stack: core-vault-core-vault-prod
    error: Running program 'core-vault' failed with an unhandled exception:
 
    error: TSError: ⨯ Unable to compile TypeScript:
    index.ts(37,9): error TS2322: Type 'string | undefined' is not assignable to type 'Input<string>'.
      Type 'undefined' is not assignable to type 'Input<string>'.
if i remove the read from the config, then it shows up in the info:
Copy code
pulumi:pulumi:Stack: core-vault-core-vault-prod
    info: 11111111-1111-1111-111111111111
import * as azure_conf from "@pulumi/azure/config/vars";
so it's there as an env var, i guess that's good enough
hmm.. weird if I do this:
Copy code
console.log(process.env["ARM_TENANT_ID"])
    var kv = new azure.keyvault.KeyVault(vault_name, {
        resourceGroupName: resource_group_name,
        location: region_map[vault.region]['name'],
        name: vault_name,
        tenantId: azure_config.require('tenantId'),
        sku: {
            name: 'standard'
        }
    });
i see the tenantID in the output, if i do this, it breaks
Copy code
var kv = new azure.keyvault.KeyVault(vault_name, {
        resourceGroupName: resource_group_name,
        location: region_map[vault.region]['name'],
        name: vault_name,
        tenantId: process.env["ARM_TENANT_ID"],
        sku: {
            name: 'standard'
        }
    });
Copy code
Diagnostics:
  pulumi:pulumi:Stack: core-vault-core-vault-prod
    error: Running program '~/core-vault' failed with an unhandled exception:
 
    error: TSError: ⨯ Unable to compile TypeScript:
    index.ts(34,9): error TS2322: Type 'string | undefined' is not assignable to type 'Input<string>'.
      Type 'undefined' is not assignable to type 'Input<string>'.
    
        at createTSError (~/core-vault/node_modules/ts-node/src/index.ts:261:12)
        at getOutput (~/core-vault/node_modules/ts-node/src/index.ts:367:40)
        at Object.compile (~/core-vault/node_modules/ts-node/src/index.ts:558:11)
        at Module.m._compile (~/core-vault/node_modules/ts-node/src/index.ts:439:43)
        at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Object.require.extensions.(anonymous function) [as .ts] (~/core-vault/node_modules/ts-node/src/index.ts:442:12)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Module.require (internal/modules/cjs/loader.js:637:17)
 
    error: an unhandled error occurred: Program exited with non-zero exit code: 1
 
error: an error occurred while advancing the preview
likewise this works:
Copy code
import * as azure_conf from "@pulumi/azure/config/vars";
console.log(azure_conf.tenantId)
so it's just the passing of the thing into tenantId on the keyvault that causes an error, maybe only the
azure_config.require('tenantId')
is typed properly? im new to TS so all this type stuff is a bit hard for me to decipher yet
this works:
Copy code
var kv = new azure.keyvault.KeyVault(vault_name, {
        resourceGroupName: resource_group_name,
        location: region_map[vault.region]['name'],
        name: vault_name,
        tenantId: String(azure_conf.tenantId),
        sku: {
            name: 'standard'
        }
    });