3 months ago
    Hey, I am having some trouble deploying a compute@edge service on Fastly. The services requires a dictionary with two items. In order to add items to a dictionary i need a dictionaryID i have the following code to get this id.
    const dict = service.dictionaries.apply(d => d?.[0].dictionaryId || '1234') // <--- This always returns undefined, so default to 1234
    however because of the comment above whenever i run
    pulumi up
    i get the following error.
      fastly:index:ServiceDictionaryItems (CredentialsDict):
        error: 1 error occurred:
        	* Error creating dictionary items: service 6JGsFBzFbONzfbcXDyfRP3, dictionary 1234, 400 - Bad Request:
            Title:  Bad request
            Detail: Couldn't find Dictionary '{ dictionary_id => 1234, service_id => 6JGsFBzFbONzfbcXDyfRP3 }'
      pulumi:pulumi:Stack (fastly-shell-dev):
        error: update failed
    Is it possible to retrieve this ID during the deployment process? If not how can I query this after the service is deployed and still able to deploy the dictionary at the same time?
    UPDATE: So the creation of the DictionaryID is only done when the resource is actually deployed and will not be available like this during
    pulumi up
    . I fixed this issue by using
    dependsOn: [service]
    when defining my dictionaryItems.
    const MyComputeService = new ServiceCompute(...)
    new fastly.ServiceDictionaryItems('MyDictionary', {
        serviceId: service.id,
        dictionaryId: MyComputeService.dictionaries.apply(d => d?.[0].dictionaryId || '1234'),
        items: {
            'item1': config.require('item1').toString(),
            'item2': config.require('item2').toString()
    }, {dependsOn: [MyComputeService]})