From 218dae40fadc0dd1f4d9da03a9867af60fcf9ed2 Mon Sep 17 00:00:00 2001 From: seven Date: Sun, 12 Jan 2025 23:26:14 +0800 Subject: [PATCH] fix: deploy sls but not apply it ot lambda when first create Signed-off-by: seven --- package-lock.json | 19 +++++++----- package.json | 2 +- src/stack/rosStack/function.ts | 54 ++++++++++++++++----------------- tests/fixtures/deployFixture.ts | 36 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e34abf..4563e3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@geek-fun/serverlessinsight", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@geek-fun/serverlessinsight", - "version": "0.2.0", + "version": "0.2.1", "license": "Apache-2.0", "dependencies": { "@alicloud/ims20190815": "^2.1.4", @@ -11693,7 +11693,8 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-walk": { "version": "8.3.2", @@ -12213,7 +12214,8 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", - "dev": true + "dev": true, + "requires": {} }, "deep-is": { "version": "0.1.4", @@ -12444,7 +12446,8 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", - "dev": true + "dev": true, + "requires": {} }, "eslint-plugin-prettier": { "version": "5.2.1", @@ -13477,7 +13480,8 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "dev": true + "dev": true, + "requires": {} }, "jest-regex-util": { "version": "29.6.3", @@ -14864,7 +14868,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", - "dev": true + "dev": true, + "requires": {} }, "ts-jest": { "version": "29.2.5", diff --git a/package.json b/package.json index d72a246..656236a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@geek-fun/serverlessinsight", - "version": "0.2.0", + "version": "0.2.1", "description": "Full life cycle cross providers serverless application management for your fast-growing business.", "homepage": "https://serverlessinsight.geekfun.club", "main": "dist/src/index.js", diff --git a/src/stack/rosStack/function.ts b/src/stack/rosStack/function.ts index 067c3f2..aa57dc1 100644 --- a/src/stack/rosStack/function.ts +++ b/src/stack/rosStack/function.ts @@ -26,35 +26,35 @@ export const resolveFunctions = ( let logConfig: RosFunction.LogConfigProperty | undefined = undefined; const enableLog = functions?.some(({ log }) => log); - if (enableLog) { - const slsService = new sls.Project( - scope, - `${service}_sls`, - { name: `${service}-sls`, tags: replaceReference(tags, context) }, - true, - ); + const slsService = new sls.Project( + scope, + `${service}_sls`, + { name: `${service}-sls`, tags: replaceReference(tags, context) }, + true, + ); - const slsLogstore = new sls.Logstore( - scope, - `${service}_sls_logstore`, - { - logstoreName: `${service}-sls-logstore`, - projectName: slsService.attrName, - ttl: 7, - }, - true, - ); + const slsLogstore = new sls.Logstore( + scope, + `${service}_sls_logstore`, + { + logstoreName: `${service}-sls-logstore`, + projectName: slsService.attrName, + ttl: 7, + }, + true, + ); - new sls.Index( - scope, - `${service}_sls_index`, - { - projectName: slsService.attrName, - logstoreName: slsLogstore.attrLogstoreName, - fullTextIndex: { enable: true }, - }, - true, - ); + new sls.Index( + scope, + `${service}_sls_index`, + { + projectName: slsService.attrName, + logstoreName: slsLogstore.attrLogstoreName, + fullTextIndex: { enable: true }, + }, + true, + ); + if (enableLog) { logConfig = { project: slsLogstore.attrProjectName, logstore: slsLogstore.attrLogstoreName, diff --git a/tests/fixtures/deployFixture.ts b/tests/fixtures/deployFixture.ts index ea4cfdc..fba944d 100644 --- a/tests/fixtures/deployFixture.ts +++ b/tests/fixtures/deployFixture.ts @@ -473,6 +473,42 @@ export const minimumRos = { Metadata: { 'ALIYUN::ROS::Interface': { TemplateTags: ['Create by ROS CDK'] } }, ROSTemplateFormatVersion: '2015-09-01', Resources: { + 'my-demo-minimum-service_sls': { + Properties: { + Name: 'my-demo-minimum-service-sls', + }, + Type: 'ALIYUN::SLS::Project', + }, + 'my-demo-minimum-service_sls_index': { + Properties: { + FullTextIndex: { + Enable: true, + }, + LogReduce: false, + LogstoreName: { + 'Fn::GetAtt': ['my-demo-minimum-service_sls_logstore', 'LogstoreName'], + }, + ProjectName: { + 'Fn::GetAtt': ['my-demo-minimum-service_sls', 'Name'], + }, + }, + Type: 'ALIYUN::SLS::Index', + }, + 'my-demo-minimum-service_sls_logstore': { + Properties: { + AppendMeta: false, + AutoSplit: false, + EnableTracking: false, + LogstoreName: 'my-demo-minimum-service-sls-logstore', + PreserveStorage: false, + ProjectName: { + 'Fn::GetAtt': ['my-demo-minimum-service_sls', 'Name'], + }, + ShardCount: 2, + TTL: 7, + }, + Type: 'ALIYUN::SLS::Logstore', + }, hello_fn: { Properties: { Code: {