adventurous-camera-87788
07/08/2021, 6:48 PMcache.Redis (v20201201)
& I am trying to get the following statement to produce a string:
const REDIS_CONNECTION_STRING = pulumi.interpolate `rediss://:${redis.accessKeys.primaryKey}@${redis.hostName}${redis.sslPort}`;
I am getting the following error:
"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 pulumi.apply
as well & had no luck. Can someone please point me in the right direction?billowy-army-68599
07/08/2021, 6:50 PMREDIS_CONNECTION_STRING
to? can you share more of your code?adventurous-camera-87788
07/08/2021, 6:52 PMbillowy-army-68599
07/08/2021, 7:44 PMcrooked-parrot-53351
07/12/2021, 3:04 PMconst 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(
azureFunctionName,
{
name: azureFunctionName,
kind: 'functionapp',
location: resourceGroup.location,
resourceGroupName: resourceGroup.name,
serverFarmId: appServicePlan.id,
storageAccountName: storageAccount.name,
storageAccountAccessKey: storageAccount.primaryAccessKey,
siteConfig: {
appSettings: [
...
{name: 'REDIS_CONNETION_STRING', value: REDIS_CONNECTION_STRING},
...
],
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 output<string>
as the value of REDIS_CONNECTION_STRING
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.billowy-army-68599
07/12/2021, 3:45 PMcrooked-parrot-53351
07/12/2021, 3:54 PMconst 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:
{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?accessKeys
portion and build the string w/just hostname and port, all works as expected. Are there good practices for nested keys like accessKeys.primaryKey
?billowy-army-68599
07/12/2021, 4:27 PMcrooked-parrot-53351
07/12/2021, 5:31 PM@pulumi/azure-native/cache/v20201201
as our dependency version though.accessKeys
and the type in the TS files distributed with the SDK, I'm just not sure why they're not resolving 😞billowy-army-68599
07/12/2021, 6:06 PMcrooked-parrot-53351
07/12/2021, 6:08 PMbillowy-army-68599
07/12/2021, 6:08 PMcrooked-parrot-53351
07/14/2021, 2:37 AMpulumi 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 listRedisKeys
function from the cache
namespace to explicitly query for the keys needed to build the connection string.