diff --git a/.github/config/en-custom.txt b/.github/config/en-custom.txt index e17688da1..a9781bb81 100644 --- a/.github/config/en-custom.txt +++ b/.github/config/en-custom.txt @@ -1249,3 +1249,7 @@ azwi Entra ServiceAccounts pluggable +cyrilgdn +secretStore +postgreSQL +postgres 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 49f7822a0..74c16a5fa 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 @@ -1,18 +1,25 @@ //SECRETSTORE import radius as radius -@description('Required value, refers to the personal access token or password of the git platform') +@description('username for postgres db') @secure() -param pat string +param username string -resource secretStoreGit 'Applications.Core/secretStores@2023-10-01-preview' = { - name: 'my-git-secret-store' +@description('password for postgres db') +@secure() +param password string + +resource pgsSecretStore 'Applications.Core/secretStores@2023-10-01-preview' = { + name: 'my-secret-store' properties: { - resource: 'my-secret-namespace/github' + resource: 'my-secret-namespace/my-secret-store' type: 'generic' data: { - pat: { - value: pat + username: { + value: username + } + password: { + value: password } } } @@ -25,27 +32,37 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { properties: { compute: { kind: 'kubernetes' + resourceId: 'self' namespace: 'my-namespace' } recipeConfig: { - terraform: { - authentication: { - git: { - pat: { - // The hostname of your git platform, such as 'dev.azure.com' or 'github.com' - 'github.com':{ - secret: secretStoreGit.id + terraform:{ + providers:{ + postgresql:[{ + sslmode: 'disable' + port: 5432 + secrets: { + username: { + source: pgsSecretStore.id + key: username + } + password: { + source: pgsSecretStore.id + key: password } } - } + }] } } + env: { + PGHOST: 'postgres.corerp-resources-terraform-pg-app.svc.cluster.local' + } } recipes: { - 'Applications.Datastores/redisCaches': { - default: { + 'Applications.Core/extenders': { + defaultpostgres: { templateKind: 'terraform' - // Git template path + // Recipe template path templatePath:'git::https://github.com/my-org/my-repo' } } 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 000e05f4d..74f1c3b01 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 @@ -1,11 +1,11 @@ //SECRETSTORE import radius as radius -@description('username for postgres db') +@description('username for PostgreSQL db') @secure() param username string -@description('password for postgres db') +@description('password for PostgreSQL db') @secure() param password string @@ -27,30 +27,6 @@ resource pgsSecretStore 'Applications.Core/secretStores@2023-10-01-preview' = { //SECRETSTORE //ENV -resource env 'Applications.Core/environments@2023-10-01-preview' = { - name: 'my-env' - properties: { - compute: { - kind: 'kubernetes' - namespace: 'my-namespace' - } - recipeConfig: { - terraform: { - authentication: { - git: { - pat: { - // The hostname of your git platform, such as 'dev.azure.com' or 'github.com' - 'github.com':{ - secret: secretStoreGit.id - } - } - } - } - } - } - } -} - resource env 'Applications.Core/environments@2023-10-01-preview' = { name: 'my-env' properties: { @@ -82,14 +58,6 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { PGHOST: 'postgres.corerp-resources-terraform-pg-app.svc.cluster.local' } } - recipes: { - 'Applications.Core/extenders': { - defaultpostgres: { - templateKind: 'terraform' - templatePath: 'git::https://github.com/lakshmimsft/lak-temp-public//postgres2' - } - } - } } } //ENV diff --git a/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/postgres.tf b/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/postgres.tf index e69de29bb..527eaae05 100644 --- a/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/postgres.tf +++ b/docs/content/guides/recipes/terraform/howto-custom-provider/snippets/postgres.tf @@ -0,0 +1,89 @@ +terraform { + required_providers { + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.0" + } + postgresql = { + source = "cyrilgdn/postgresql" + version = "1.16.0" + } + } +} + +variable "context" { + description = "This variable contains Radius recipe context." + type = any +} + +variable "password" { + description = "The password for the PostgreSQL database" + type = string +} + +resource "kubernetes_deployment" "postgres" { + metadata { + name = "postgres" + namespace = var.context.runtime.kubernetes.namespace + } + + spec { + selector { + match_labels = { + app = "postgres" + } + } + + template { + metadata { + labels = { + app = "postgres" + } + } + + spec { + container { + image = "postgres:latest" + name = "postgres" + + env { + name = "POSTGRES_PASSWORD" + value = var.password + } + + port { + container_port = 5432 + } + } + } + } + } +} + +resource "kubernetes_service" "postgres" { + metadata { + name = "postgres" + namespace = var.context.runtime.kubernetes.namespace + } + + spec { + selector = { + app = "postgres" + } + + port { + port = 5432 + target_port = 5432 + } + } +} + +resource "time_sleep" "wait_20_seconds" { + depends_on = [kubernetes_service.postgres] + create_duration = "20s" +} + +resource postgresql_database "pg_db_test" { + depends_on = [time_sleep.wait_20_seconds] + name = "pg_db_test" +} \ No newline at end of file