From 1f8f1be92fce51481a2e2407ca74d9def9398ef4 Mon Sep 17 00:00:00 2001 From: Pavel Denisjuk Date: Sat, 26 Oct 2019 18:16:40 +0200 Subject: [PATCH] fix: update sls templates. --- packages/cli/create/index.js | 14 +++++++------ .../cli/create/template/api/serverless.yml | 20 ++++++++++--------- .../cli/create/template/apps/serverless.yml | 3 ++- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/cli/create/index.js b/packages/cli/create/index.js index 235ef9d3696..e9d6b6c2a12 100644 --- a/packages/cli/create/index.js +++ b/packages/cli/create/index.js @@ -68,18 +68,20 @@ module.exports = async ({ name }) => { fs.renameSync(envExample, "api/.env.json"); } - // Update .env.json - let envFile = getFileContents("api/.env.json"); - envFile = envFile.replace("[JWT_SECRET]", jwtSecret); - writeFileContents("api/.env.json", envFile); - - // Generate and inject project ID + // Update API serverless.yml const apiId = getUniqueId(); let apiYaml = getFileContents("api/serverless.yml"); apiYaml = apiYaml.replace(/\[PROJECT_ID\]/g, apiId); writeFileContents("api/serverless.yml", apiYaml); writeJsonFile.sync(resolve("api/.serverless/_.json"), { id: apiId }); + // Update .env.json + let envFile = getFileContents("api/.env.json"); + envFile = envFile.replace("[JWT_SECRET]", jwtSecret); + envFile = envFile.replace("[BUCKET]", `webiny-files-${apiId}`); + writeFileContents("api/.env.json", envFile); + + // Update apps serverless.yml let appsYaml = getFileContents("apps/serverless.yml"); const appsId = getUniqueId(); appsYaml = appsYaml.replace(/\[PROJECT_ID\]/g, appsId); diff --git a/packages/cli/create/template/api/serverless.yml b/packages/cli/create/template/api/serverless.yml index 54ae5c167f5..1cc610c3f67 100644 --- a/packages/cli/create/template/api/serverless.yml +++ b/packages/cli/create/template/api/serverless.yml @@ -2,6 +2,7 @@ name: webiny-api-[PROJECT_ID] vars: region: ${env.AWS_REGION} + bucket: ${env.S3_BUCKET} env: JWT_SECRET: ${env.JWT_SECRET} GRAPHQL_INTROSPECTION: ${env.GRAPHQL_INTROSPECTION} @@ -13,9 +14,9 @@ vars: gateway: component: "@webiny/serverless-apollo-gateway" inputs: - region: ${vars.region} - name: gateway + name: Apollo Gateway env: ${vars.env} + region: ${vars.region} memory: 512 timeout: 30 services: @@ -31,16 +32,16 @@ gateway: cognito: component: "@webiny/serverless-aws-cognito-user-pool" inputs: + name: "webiny-pool-[PROJECT_ID]" region: ${vars.region} - name: webiny-pool-[PROJECT_ID] appClients: - name: "react-app-[PROJECT_ID]" security: component: "@webiny/serverless-apollo-service" inputs: + name: "Security" region: ${vars.region} - name: security memory: 512 database: ${vars.database} env: ${vars.env} @@ -54,9 +55,9 @@ security: files: component: "@webiny/serverless-files" inputs: + name: "Files" region: ${vars.region} - bucket: "webiny-files-[PROJECT_ID]" - name: files + bucket: ${vars.bucket} memory: 512 database: ${vars.database} env: ${vars.env} @@ -65,8 +66,8 @@ files: i18n: component: "@webiny/serverless-apollo-service" inputs: + name: "I18N" region: ${vars.region} - name: i18n memory: 512 database: ${vars.database} env: ${vars.env} @@ -76,8 +77,8 @@ i18n: pageBuilder: component: "@webiny/serverless-page-builder" inputs: + name: "Page Builder" region: ${vars.region} - name: pageBuilder memory: 512 database: ${vars.database} env: ${vars.env} @@ -89,8 +90,9 @@ pageBuilder: api: component: "@webiny/serverless-api-gateway" inputs: + name: "API Gateway" region: ${vars.region} - description: "Main GraphQL API" + description: "Main API Gateway" endpoints: - path: /graphql method: ANY diff --git a/packages/cli/create/template/apps/serverless.yml b/packages/cli/create/template/apps/serverless.yml index 765b00cafc2..1be4221cd96 100644 --- a/packages/cli/create/template/apps/serverless.yml +++ b/packages/cli/create/template/apps/serverless.yml @@ -17,7 +17,8 @@ admin: api: component: "@webiny/serverless-api-gateway" inputs: - description: Serverless Site + name: Apps Gateway + description: Serverless React Apps endpoints: - path: /admin/{key+} method: GET