ancient-eve-13947
07/30/2021, 12:39 PMpulumi preview
on a clean slate, ie with no resources up yet and I get the following error:
Diagnostics:
pulumi:pulumi:Stack (Cloud-dev):
error: Running program 'C:\Projects\Deon\infrastructure\azureresources' failed with an unhandled exception:
Error: invocation of azure-native:cache:listRedisKeys returned an error: request failed /subscriptions/25110286-d288-4e46-851b-4e2bc880672f/resourceGroups/rgDEV/providers/Microsoft.Cache/redis/redis2f94d61f/listKeys: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Cache/Redis/redis2f94d61f' under resource group 'rgDEV' was not found. For more details please go to <https://aka.ms/ARMResourceNotFoundFix>"
at Object.callback (C:\Projects\Deon\infrastructure\azureresources\node_modules\@pulumi\pulumi\runtime\invoke.js:139:33)
at Object.onReceiveStatus (C:\Projects\Deon\infrastructure\azureresources\node_modules\@grpc\grpc-js\src\client.ts:338:26)
at Object.onReceiveStatus (C:\Projects\Deon\infrastructure\azureresources\node_modules\@grpc\grpc-js\src\client-interceptors.ts:426:34)
at Object.onReceiveStatus (C:\Projects\Deon\infrastructure\azureresources\node_modules\@grpc\grpc-js\src\client-interceptors.ts:389:48)
at C:\Projects\Deon\infrastructure\azureresources\node_modules\@grpc\grpc-js\src\call-stream.ts:276:24
at processTicksAndRejections (internal/process/task_queues.js:79:11)
The code for that passage is
function createRedis() : azure.types.input.web.NameValuePairArgs[]{
var cache= new redis.Redis("redis", {
resourceGroupName,
enableNonSslPort: true,
minimumTlsVersion: redis.TlsVersion.TlsVersion_1_2,
sku: {
name: "Basic",
family: "C",
capacity: cfg.requireNumber("Redis.Size")
}
});
const keys= pulumi.all([resourceGroupName, cache.name])
.apply(([resourceGroupName, name])=>redis.listRedisKeys({resourceGroupName, name}))
const connectionString= pulumi.interpolate `${cache.hostName}:6380,password=${keys.primaryKey},ssl=True,abortConnect=False`;
return [
{
name: "Redis:ConnectionString",
value: connectionString
},
];
}
Now what I don't get is: of course when doing preview, the redis instance isn't there yet. But I kinda expected that Pulumi somehow deals with this in the background, maybe not calling apply if cache.Name is not available yet.
Also, I think I didn't have the problem before - but that might just be because I called it incrementally, never on a completely clean slate.
Note the same thing happens when I execute pulumi up
when it's in the preview stage. So this is currently a big blocker for me.
Any ideas, anyone?tall-librarian-49374
07/30/2021, 12:44 PMnative:cache:listRedisKeys
call inside an apply, similar to https://github.com/pulumi/templates/blob/master/azure-typescript/index.ts#L18-L19ancient-eve-13947
07/30/2021, 12:45 PMtall-librarian-49374
07/30/2021, 12:46 PMancient-eve-13947
07/30/2021, 12:47 PMtall-librarian-49374
07/30/2021, 12:50 PMimport * as pulumi from "@pulumi/pulumi";
import * as resources from "@pulumi/azure-native/resources";
import * as redis from "@pulumi/azure-native/cache";
const resourceGroup = new resources.ResourceGroup("rg");
var cache= new redis.Redis("redis", {
resourceGroupName: resourceGroup.name,
enableNonSslPort: true,
minimumTlsVersion: redis.TlsVersion.TlsVersion_1_2,
sku: {
name: "Basic",
family: "C",
capacity: 1
}
});
const keys= pulumi.all([resourceGroup.name, cache.name])
.apply(([resourceGroupName, name])=>redis.listRedisKeys({resourceGroupName, name}))
export const connectionString= pulumi.interpolate `${cache.hostName}:6380,password=${keys.primaryKey},ssl=True,abortConnect=False`;
ancient-eve-13947
07/30/2021, 12:50 PMtall-librarian-49374
07/30/2021, 12:50 PMancient-eve-13947
07/30/2021, 12:52 PMtall-librarian-49374
07/30/2021, 12:53 PMancient-eve-13947
07/30/2021, 12:53 PMtall-librarian-49374
07/30/2021, 12:54 PMancient-eve-13947
07/30/2021, 12:55 PMtall-librarian-49374
07/30/2021, 12:55 PMall
to this:
const keys= pulumi.all([resourceGroup.name, cache.name, cache.id])
cache.id
won’t resolve until redis exists. But it may be worth filing an issue for your original code.ancient-eve-13947
07/30/2021, 12:56 PMtall-librarian-49374
07/30/2021, 12:57 PMancient-eve-13947
07/30/2021, 12:57 PMtall-librarian-49374
07/30/2021, 12:57 PMancient-eve-13947
07/30/2021, 1:43 PMconst resourceGroup= new resources.ResourceGroup(resourceGroupName);
for preview that looked fine, but when I run it, it leads to the creation of a new resourcegroup.
on the other hand, when I do
const resourceGroup= resources.getResourceGroup({resourceGroupName});
then the result is a `Promise<GetResourceGroupResult>`and I get compile-time errors.
when I try
const resourceGroup= await resources.getResourceGroup({resourceGroupName});
I get another error saying that top-level await is not allowed.
So what do I do?tall-librarian-49374
07/30/2021, 2:38 PM