diff --git a/docs/content/operations/custom-recipes/index.md b/docs/content/operations/custom-recipes/index.md index eeb314d64..2013e6437 100644 --- a/docs/content/operations/custom-recipes/index.md +++ b/docs/content/operations/custom-recipes/index.md @@ -66,29 +66,9 @@ Linking is done automatically for any new Azure or AWS resource ([_Kubernetes co [Bicep `existing`](https://learn.microsoft.com/azure/azure-resource-manager/bicep/existing-resource) resources are not currently linked as part of Recipe-enabled resources, meaning you won't see them in the definition of the resource and they aren't [deleted later on](#infrastructure-lifecycle), unlike new resources. -You can also manually link resources via the `values` output of a Recipe. This can be used for Kubernetes resources, [which aren't currently linked automatically]({{< ref "faq#why-do-i-need-to-manually-output-a-kubernetes-ucp-id-as-part-of-my-bicep-recipe" >}}). To link a resource to a Recipe-enabled resource, add its ID to an array of resource IDs: - -```bicep -// ....resources defined above - -output result object = { - resources: [ - // ID via reference (Azure/AWS) - resource1.id - // ID via manual entry (Kubernetes) - '/planes/kubernetes/local/namespaces/${deployment.metadata.namespace}/providers/apps/Deployment/${deployment.metadata.name}' - ] - values: { - host: azureCache.properties.hostName - port: azureCache.properties.port - } - secrets: { - connectionString: 'redis://${azureCache.properties.hostName}:${azureCache.properties.port}' - #disable-next-line outputs-should-not-contain-secrets - password: azureCache.listKeys().primaryKey - } -} -``` +You can also manually link resources via the `result` output of a Recipe. This can be used for Kubernetes resources, [which aren't currently linked automatically]({{< ref "faq#why-do-i-need-to-manually-output-a-kubernetes-ucp-id-as-part-of-my-bicep-recipe" >}}). To link a resource to a Recipe-enabled resource, add its ID to an array of resource IDs: + +{{< rad file="snippets/recipe-outputs.bicep" embed=true marker="//OUTVALUES" >}} ### Step 5: Store your template in a Bicep registry diff --git a/docs/content/operations/custom-recipes/snippets/recipe-outputs.bicep b/docs/content/operations/custom-recipes/snippets/recipe-outputs.bicep new file mode 100644 index 000000000..2e7d8da6e --- /dev/null +++ b/docs/content/operations/custom-recipes/snippets/recipe-outputs.bicep @@ -0,0 +1,19 @@ +resource azureResource 'Microsoft.Cache/redis@2022-06-01' existing = { + name: 'mycache' +} + +param svc object +param deployment object + +//OUTVALUES +output result object = { + resources: [ + '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' + '/planes/kubernetes/local/namespaces/${deployment.metadata.namespace}/providers/apps/Deployment/${deployment.metadata.name}' + ] + values: { + host: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' + port: 6379 + } +} +//OUTVALUES