Skip to content

Commit

Permalink
fix: update sls templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Oct 26, 2019
1 parent 42f8da0 commit 1f8f1be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
14 changes: 8 additions & 6 deletions packages/cli/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 11 additions & 9 deletions packages/cli/create/template/api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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:
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/create/template/apps/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f8f1be

Please sign in to comment.