Skip to content

Commit

Permalink
Export secrets only when there's a service to bind to (#4692)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyCA authored Jan 15, 2025
1 parent d55637a commit 7a302d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cli/azd/internal/scaffold/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ func Execute(
func supportingFiles(spec InfraSpec) []string {
files := []string{"/abbreviations.json"}

if spec.DbRedis != nil {
files = append(files, "/modules/set-redis-conn.bicep")
}

if len(spec.Services) > 0 {
if spec.DbRedis != nil {
files = append(files, "/modules/set-redis-conn.bicep")
}
files = append(files, "/modules/fetch-container-image.bicep")
}

Expand Down
4 changes: 4 additions & 0 deletions cli/azd/resources/scaffold/templates/resources.bicept
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ module cosmos 'br/public:avm/res/document-db/database-account:0.8.1' = {
}
]
{{- end}}
{{- if .Services}}
secretsExportConfiguration: {
keyVaultResourceId: keyVault.outputs.resourceId
primaryWriteConnectionStringSecretName: 'MONGODB-URL'
}
{{- end}}
capabilitiesToAdd: [ 'EnableServerless' ]
}
}
Expand Down Expand Up @@ -398,6 +400,7 @@ module redis 'br/public:avm/res/cache/redis:0.3.2' = {
}
}

{{- if .Services}}
module redisConn './modules/set-redis-conn.bicep' = {
name: 'redisConn'
params: {
Expand All @@ -408,6 +411,7 @@ module redisConn './modules/set-redis-conn.bicep' = {
}
}
{{- end}}
{{- end}}

{{- if .Services}}
// Create a keyvault to store secrets
Expand Down

0 comments on commit 7a302d7

Please sign in to comment.