Skip to content

Commit

Permalink
Merge pull request #190 from nitrictech/feature/deployment-fixes
Browse files Browse the repository at this point in the history
Deployment fixes
  • Loading branch information
tjholm authored Sep 27, 2021
2 parents 1d2cd25 + d554914 commit 3ef7e69
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
36 changes: 25 additions & 11 deletions packages/plugins/azure/src/resources/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export class NitricApiAzureApiManagement extends pulumi.ComponentResource {
name,
{
resourceGroupName: resourceGroup.name,
// TODO: Extract from API doc?
serviceName: `${api.name}-service`,
publisherEmail: adminEmail,
publisherName: orgName,
// TODO: Add configuration for this
Expand All @@ -67,10 +65,13 @@ export class NitricApiAzureApiManagement extends pulumi.ComponentResource {
this.api = new apimanagement.Api(
`${name}-api`,
{
displayName: openapi.info?.title || `${name}-api`,
protocols: ['https'],
apiId: name,
format: 'openapi-json',
format: 'openapi+json',
path: '/',
resourceGroupName: resourceGroup.name,
subscriptionRequired: false,
serviceName: this.service.name,
// XXX: Do we need to stringify this?
// Not need to transform the original spec,
Expand All @@ -97,18 +98,31 @@ export class NitricApiAzureApiManagement extends pulumi.ComponentResource {
`${name}-api-${pathMethod.operationId}`,
{
resourceGroupName: resourceGroup.name,
apiId: this.api.id,
// this.api.id returns a URL path, which is the incorrect value here.
// We instead need the value passed to apiId in the api creation above.
// However, we want to maintain the pulumi dependency, so we need to keep the 'apply' call.
apiId: this.api.id.apply(() => name),
serviceName: this.service.name,
// TODO: Need to figure out how this is mapped to a real api operation entity
operationId: pathMethod.operationId!,
policyId: pulumi.interpolate`${pathMethod.operationId!}Policy`,
// policyId must always be set to the static string 'policy' or Azure returns an error.
policyId: 'policy',
format: 'xml',
value: pulumi.interpolate`
<policies>
<inbound />
<backend>
<set-backend-service base-url="https://${func.webapp.defaultHostName}" />
</backend>
<outbound />
<policies>
<inbound>
<base />
<set-backend-service base-url="https://${func.webapp.defaultHostName}" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
`,
},
Expand Down
16 changes: 8 additions & 8 deletions packages/plugins/azure/src/tasks/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ export class Deploy extends Task<void> {

// Create a stack level keyvault if secrets are enabled
// At the moment secrets have no config level setting
const kvault = new keyvault.Vault(`${stack.getName()}-key-vault`, {
vaultName: `${stack.getName()}`.substring(0, 24),
const kvault = new keyvault.Vault(`${stack.getName()}`.substring(0, 13), {
resourceGroupName: resourceGroup.name,
properties: {
enableSoftDelete: false,
Expand All @@ -129,10 +128,8 @@ export class Deploy extends Task<void> {
// DEPLOY STORAGE BASED ASSETS
let deployedSites: NitricAzureStorageSite[] = [];
if (Object.keys(buckets).length || Object.keys(queues).length || stack.getSites().length) {
const account = new storage.StorageAccount(`${stack.getName()}-storage-account`, {
const account = new storage.StorageAccount(`${stack.getName()}`.replace(/-/g, '').substring(0, 13), {
resourceGroupName: resourceGroup.name,
// 24 character limit
accountName: `${stack.getName().replace(/-/g, '')}`,
kind: storage.Kind.StorageV2,
sku: {
name: storage.SkuName.Standard_LRS,
Expand Down Expand Up @@ -192,9 +189,12 @@ export class Deploy extends Task<void> {

if (Object.keys(collections).length) {
// CREATE DB ACCOUNT
const { account } = new NitricDatabaseAccountMongoDB(stack.getName(), {
resourceGroup,
});
const { account } = new NitricDatabaseAccountMongoDB(
`${stack.getName()}`.replace(/-/g, '').substring(0, 13),
{
resourceGroup,
},
);

// CREATE DB
const { database } = new NitricDatabaseCosmosMongo(stack.getName(), {
Expand Down

0 comments on commit 3ef7e69

Please sign in to comment.