Skip to content

Commit

Permalink
feat(cicd): add stripe service
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied authored and manekinekko committed Mar 2, 2023
1 parent 805ceb9 commit b9d10f5
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .azdo/pipelines/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ steps:
AZURE_SUBSCRIPTION_ID: ${AZURE_SUBSCRIPTION_ID}
AZURE_ENV_NAME: ${AZURE_ENV_NAME}
AZURE_LOCATION: ${AZURE_LOCATION}
STRIPE_PUBLIC_KEY: ${STRIPE_PUBLIC_KEY}
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}

- task: AzureCLI@2
displayName: Azure Dev Deploy
inputs:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}

- name: Azure Dev Deploy
run: azd deploy --no-prompt
Expand Down
5 changes: 5 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ services:
project: packages/blog
host: containerapp
module: app/blog

stripe:
project: packages/stripe
host: containerapp
module: app/stripe
59 changes: 59 additions & 0 deletions infra/app/stripe.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
param location string = resourceGroup().location
param applicationInsightsName string = ''
param serviceName string = 'stripe'
param apiUrl string
param stripePublicKey string
@secure()
param stripeSecretKey string
@secure()
param stripeWebhookSecret string
param containerAppsEnvironmentName string
param containerRegistryName string
param imageName string = ''
param environmentName string

var abbrs = loadJsonContent('../abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))

module app '../core/host/container-app.bicep' = {
name: '${serviceName}-container-app-module'
params: {
environmentName: environmentName
serviceName: !empty(serviceName) ? serviceName : '${abbrs.appContainerApps}${serviceName}-${resourceToken}'
location: location
containerAppsEnvironmentName: containerAppsEnvironmentName
containerRegistryName: containerRegistryName
env: [
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.properties.ConnectionString
}
{
name: 'API_URL'
value: apiUrl
}
{
name: 'STRIPE_PUBLIC_KEY'
value: stripePublicKey
}
{
name: 'STRIPE_SECRET_KEY'
value: stripeSecretKey
}
{
name: 'STRIPE_WEBHOOK_SECRET'
value: stripeWebhookSecret
}
]
imageName: !empty(imageName) ? imageName : 'nginx:latest'
targetPort: 3000
}
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: applicationInsightsName
}

output SERVICE_STRIPE_NAME string = app.outputs.name
output SERVICE_STRIPE_URI string = app.outputs.uri
output SERVICE_STRIPE_IMAGE_NAME string = app.outputs.imageName
36 changes: 36 additions & 0 deletions infra/app/stripe.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "${AZURE_LOCATION}"
},
"environmentName": {
"value": "${AZURE_ENV_NAME}"
},
"imageName": {
"value": "${SERVICE_BLOG_IMAGE_NAME}"
},
"applicationInsightsName": {
"value": "${APPLICATIONINSIGHTS_NAME}"
},
"containerAppsEnvironmentName": {
"value": "${AZURE_CONTAINER_ENVIRONMENT_NAME}"
},
"containerRegistryName": {
"value": "${AZURE_CONTAINER_REGISTRY_NAME}"
},
"apiUrl": {
"value": "${SERVICE_API_URI}"
},
"stripePublicKey": {
"value": "${STRIPE_PUBLIC_KEY}"
},
"stripeSecretKey": {
"value": "${STRIPE_SECRET_KEY}"
},
"stripeWebhookSecret": {
"value": "${STRIPE_WEBHOOK_SECRET}"
}
}
}
1 change: 1 addition & 0 deletions infra/app/web.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ module web '../core/host/staticwebapps.bicep' = [for name in swaNames: {

output WEB_PORTAL_NAME string = web[0].outputs.name
output WEB_PORTAL_URI string = web[0].outputs.uri
output WEB_API_URI string = web[0].outputs.apiUri
1 change: 1 addition & 0 deletions infra/core/host/staticwebapps.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!(empty(

output name string = web.name
output uri string = 'https://${web.properties.defaultHostname}'
output apiUri string = 'https://${web.properties.defaultHostname}/api'
28 changes: 27 additions & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ param cmsDatabaseServerName string = ''
@secure()
param cmsDatabasePassword string

param stripePublicKey string

@secure()
param stripeSecretKey string

@secure()
param stripeWebhookSecret string

var abbrs = loadJsonContent('./abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var tags = { 'azd-env-name': environmentName }
Expand Down Expand Up @@ -137,7 +145,22 @@ module blog 'app/blog.bicep' = {
applicationInsightsName: monitoring.outputs.applicationInsightsName
location: location
environmentName: environmentName
storageAccountName: storageAccount.outputs.name
}
}

module stripe 'app/stripe.bicep' = {
name: 'stripe'
scope: rg
params: {
apiUrl: web.outputs.WEB_API_URI
stripePublicKey: stripePublicKey
stripeSecretKey: stripeSecretKey
stripeWebhookSecret: stripeWebhookSecret
containerAppsEnvironmentName: !empty(containerAppsEnvironmentName) ? containerAppsEnvironmentName : '${abbrs.appManagedEnvironments}${resourceToken}'
containerRegistryName: !empty(containerRegistryName) ? containerRegistryName : '${abbrs.containerRegistryRegistries}${resourceToken}'
applicationInsightsName: monitoring.outputs.applicationInsightsName
location: location
environmentName: environmentName
}
}

Expand All @@ -149,13 +172,16 @@ output AZURE_KEY_VAULT_ENDPOINT string = keyVault.outputs.keyVaultEndpoint
output AZURE_LOCATION string = location
output AZURE_TENANT_ID string = tenant().tenantId
output WEB_PORTAL_URI string = web.outputs.WEB_PORTAL_URI
output WEB_API_URI string = web.outputs.WEB_API_URI
output WEB_BLOG_URI string = blog.outputs.WEB_BLOG_URI
output WEB_BLOG_NAME string = blog.outputs.WEB_BLOG_NAME
output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.containerAppsEnvironmentName
output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.containerRegistryEndpoint
output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.containerRegistryName
output SERVICE_BLOG_CMS_URL string = cms.outputs.SERVICE_BLOG_CMS_URI
output SERVICE_BLOG_CMS_NAME string = cms.outputs.SERVICE_BLOG_CMS_NAME
output SERVICE_STRIPE_URL string = stripe.outputs.SERVICE_STRIPE_URI
output SERVICE_STRIPE_NAME string = stripe.outputs.SERVICE_STRIPE_NAME
output STORAGE_ACCOUNT_NAME string = storageAccount.outputs.name
output SERVICE_BLOG_CMS_SERVER_HOST string = cms.outputs.SERVICE_BLOG_CMS_SERVER_HOST
output SERVICE_CMS_POSTGRESQL_DATABASE_NAME string = cms.outputs.SERVICE_BLOG_CMS_DATABASE_NAME
9 changes: 9 additions & 0 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
},
"appKeys": {
"value": "$(secretOrRandomPassword)"
},
"stripePublicKey": {
"value": "${STRIPE_PUBLIC_KEY}"
},
"stripeSecretKey": {
"value": "${STRIPE_SECRET_KEY}"
},
"stripeWebhookSecret": {
"value": "${STRIPE_WEBHOOK_SECRET}"
}
}
}

0 comments on commit b9d10f5

Please sign in to comment.