From 938a5e6554a747482b3ec4460cf28ec93069815f Mon Sep 17 00:00:00 2001 From: Lakshmi Javadekar <103459615+lakshmimsft@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:37:12 -0700 Subject: [PATCH] Add envSecrets block to HowTo Custom Provider tutorial (#1166) * adding envSecrets * updated per suggestion Signed-off-by: sk593 --- .../recipes/terraform/howto-custom-provider/index.md | 4 ++-- .../snippets/env-complete.bicep | 12 ++++++++++-- .../howto-custom-provider/snippets/env.bicep | 11 ++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/content/guides/recipes/terraform/howto-custom-provider/index.md b/docs/content/guides/recipes/terraform/howto-custom-provider/index.md index bcfc35c7a..2835a24f4 100644 --- a/docs/content/guides/recipes/terraform/howto-custom-provider/index.md +++ b/docs/content/guides/recipes/terraform/howto-custom-provider/index.md @@ -43,7 +43,7 @@ Create a Bicep file `env.bicep` with the secretStore resource: `recipeConfig/terraform/providers` allows you to setup configurations for one or multiple Terraform Providers. For more information refer to the [Radius Environment schema]({{< ref environment-schema >}}) page. -In your `env.bicep` file add an Environment resource, along with Recipe configuration which leverages properties from the previously defined secret store. In this example you're also passing in `host` as an environment variable to highlight use cases where, depending on provider configuration requirements, users can pass environment variables to the Terraform recipes runtime. +In your `env.bicep` file add an Environment resource, along with Recipe configuration which leverages properties from the previously defined secret store. In this example you're also passing in `host` and `port` as environment variables to highlight use cases where, depending on provider configuration requirements, users can pass environment variables as plain text and as secret values in `envSecrets` block to the Terraform recipes runtime. {{< rad file="snippets/env.bicep" embed=true marker="//ENV" >}} @@ -57,7 +57,7 @@ Create a Terraform recipe which deploys a PostgreSQL database instance using cus Update your Environment with the Terraform Recipe. -{{< rad file="snippets/env-complete.bicep" embed=true marker="//ENV" markdownConfig="{linenos=table,hl_lines=[\"32-40\"],linenostart=30,lineNos=false}" >}} +{{< rad file="snippets/env-complete.bicep" embed=true marker="//ENV" markdownConfig="{linenos=table,hl_lines=[\"37-45\"],linenostart=30,lineNos=false}" >}} ## Step 5: Deploy your Radius Environment diff --git a/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env-complete.bicep b/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env-complete.bicep index d66f62bd2..5d163c92c 100644 --- a/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env-complete.bicep +++ b/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env-complete.bicep @@ -21,6 +21,9 @@ resource pgsSecretStore 'Applications.Core/secretStores@2023-10-01-preview' = { password: { value: password } + host: { + value: 'my-postgres-host' + } } } } @@ -40,7 +43,6 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { providers: { postgresql: [ { sslmode: 'disable' - port: 5432 secrets: { username: { source: pgsSecretStore.id @@ -55,7 +57,13 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { } } env: { - PGHOST: 'postgres.corerp-resources-terraform-pg-app.svc.cluster.local' + PGPORT: '5432' + } + envSecrets: { + PGHOST: { + source: pgsSecretStore.id + key: 'host' + } } } recipes: { diff --git a/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env.bicep b/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env.bicep index bfc672312..85c999efe 100644 --- a/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env.bicep +++ b/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/env.bicep @@ -21,6 +21,9 @@ resource pgsSecretStore 'Applications.Core/secretStores@2023-10-01-preview' = { password: { value: password } + host: { + value: 'my-postgres-host' + } } } } @@ -55,7 +58,13 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { } } env: { - PGHOST: 'postgres.corerp-resources-terraform-pg-app.svc.cluster.local' + PGPORT: '5432' + } + envSecrets: { + PGHOST: { + source: pgsSecretStore.id + key: 'host' + } } } }