Skip to content

Commit

Permalink
Move Bicep into snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronCrawfis committed Aug 11, 2023
1 parent 27e121c commit 9d94b1c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
26 changes: 3 additions & 23 deletions docs/content/operations/custom-recipes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9d94b1c

Please sign in to comment.