Skip to content

Commit

Permalink
Support serverless deployments with @search pragma
Browse files Browse the repository at this point in the history
We're going to add some more configs to the `@search` pragma to
adjust sandbox settings, so we can no longer use the presence or
absence of the pragma itself to determine whether to deploy to
service mode or serverless mode.

Instead, check whether we are in service or serverless mode by
looking for one of the config keys that is required for service
mode.
  • Loading branch information
lpsinger committed Nov 28, 2023
1 parent 8ce2349 commit 7803d00
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@ function toCollectionName(name: string) {
.slice(0, 32)
}

function getConfig(arc: {
search?: string[][]
}): Record<string, string | undefined> {
if (arc.search) return Object.fromEntries(arc.search)
else return {}
}

export const deploy = {
// @ts-expect-error: The Architect plugins API has no type definitions.
start({ cloudformation, inventory, arc, stage }) {
let resources
if (arc.search) {
resources = serviceCloudformationResources(Object.fromEntries(arc.search))
const config = getConfig(arc)
if (config.availabilityZoneCount) {
resources = serviceCloudformationResources(config)
} else {
const { app } = inventory.inv
const collectionName = toCollectionName(`${app}-${stage}`)
Expand Down

0 comments on commit 7803d00

Please sign in to comment.