Hey guys, I have another interpolation question. I...
# getting-started
Hey guys, I have another interpolation question. I have an instance of
cache.Redis (v20201201)
& I am trying to get the following statement to produce a string:
Copy code
const REDIS_CONNECTION_STRING = pulumi.interpolate `rediss://:${redis.accessKeys.primaryKey}@${redis.hostName}${redis.sslPort}`;
I am getting the following error:
Copy code
"Calling [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi."
I’ve tried doing this with
as well & had no luck. Can someone please point me in the right direction?
what are you passing
to? can you share more of your code?
we are passing it to a constructor for a new instance of an azure function app for the app settings.
i'll need to see more code to see what's throwing the error
hi @billowy-army-68599 Thanks for helping take a look at our question. Here is a more detailed example of what we're running into:
Copy code
const redis = new cache.Redis(redisInstanceName, {
        name: redisInstanceName,
        redisVersion: `${redisInstanceVersion}`,
        enableNonSslPort: false,
        location: resourceGroup.location,
        minimumTlsVersion: `${redisInstanceMinTlsVersion}`,
        resourceGroupName: resourceGroup.name,
        sku: {
            capacity: parseInt(redisInstanceSKUCapacity),
            family: `${redisInstanceSKUFamily}`,
            name: `${redisInstanceSKUName}`

const redisHostName = redis.hostName.apply(t => t);
const redisPrimaryKey = redis.accessKeys.apply(accessKeys => accessKeys.primaryKey);
const redisSslPort = redis.sslPort.apply(t => t);

const REDIS_CONNECTION_STRING = pulumi.interpolate`rediss://:${redisPrimaryKey}@${redisHostName}:${redisSslPort}`;

const azfInstance = new azure_native.web.WebApp(
        name: azureFunctionName,
        kind: 'functionapp',
        location: resourceGroup.location,
        resourceGroupName: resourceGroup.name,
        serverFarmId: appServicePlan.id,
        storageAccountName: storageAccount.name,
        storageAccountAccessKey: storageAccount.primaryAccessKey,
        siteConfig: {
            appSettings: [
            nodeVersion: `${WEBSITE_NODE_DEFAULT_VERSION}`
We're using the Typescript SDK. You can see we moved past the error above, but we're now getting
as the value of
when looking at the diff from a dry run of
pulumi up
. I've tried attaching the Node debugger and stepping through the code, but navigating the Proxy relationships have proved complicated for us.
take a look at this exzample: https://github.com/pulumi/examples/blob/258d3bad0a00020704743e37911c51be63c06bb4/azure-ts-appservice-docker/index.ts#L86 - you'll need to use .All instead of interpolate there
Hi @billowy-army-68599 Just tried
Copy code
const REDIS_CONNECTION_STRING = pulumi.all([redis.hostName, redis.accessKeys.primaryKey, redis.sslPort]).apply(([hostName, primaryKey, sslPort])=> {
        return `rediss://:${primaryKey}@${hostName}:${sslPort}`;
and updated the section to use interpolate as the link showed:
Copy code
{name: 'REDIS_CONNECTION_STRING', value: pulumi.interpolate`${REDIS_CONNECTION_STRING}`},
and I ran into the same issue. Is this along the lines of your suggestion?
I'm noticing that when I omit the
portion and build the string w/just hostname and port, all works as expected. Are there good practices for nested keys like
that should definitely work, is it a valid value?
@billowy-army-68599 according to the docs @ https://www.pulumi.com/docs/reference/pkg/azure-native/cache/redis/#redisaccesskeysresponse I think it's correct. We're using
as our dependency version though.
I can see
and the type in the TS files distributed with the SDK, I'm just not sure why they're not resolving 😞
can you open an issue?
i'll try repro this when I get a few minutes
Sure, I've not opened one with this project thus far, any tips for how y'all like things structured?
just drop an issue with your code repro here: https://github.com/pulumi/pulumi-azure-native/issues
@billowy-army-68599 I messed around on this further and it turns out the issue with the keys simply not being available on the Redis instance because
pulumi up
didn't need to update the Redis service due to no changes being needed. For those searching, the solution here was to use the
function from the
namespace to explicitly query for the keys needed to build the connection string.