Skip to content

Commit ec67cb4

Browse files
committed
try using a layer
1 parent 99aca27 commit ec67cb4

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

.github/workflows/cdk_package_code.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ jobs:
6363
run: |
6464
poetry export --without-hashes --format=requirements.txt --with slackBotFunction > requirements_slackBotFunction
6565
poetry export --without-hashes --format=requirements.txt --with syncKnowledgeBaseFunction > requirements_syncKnowledgeBaseFunction
66-
pip3 install -r requirements_slackBotFunction -t packages/slackBotFunction
67-
pip3 install -r requirements_syncKnowledgeBaseFunction -t packages/syncKnowledgeBaseFunction
66+
pip3 install -r requirements_slackBotFunction -t packages/slackBotFunction/.dependencies
67+
pip3 install -r requirements_syncKnowledgeBaseFunction -t packages/syncKnowledgeBaseFunction/.dependencies
6868
6969
- name: 'Tar files'
7070
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ cdk.out
3333
.requirements_slackBotFunction
3434
.requirements_syncKnowledgeBaseFunction
3535
.local_config/
36+
packages/slackBotFunction/.dependencies/
37+
packages/syncKnowledgeBaseFunction/.dependencies/

Makefile

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,18 @@ cdk-deploy: guard-STACK_NAME
9898
--context slackBotToken=$$SLACK_BOT_TOKEN \
9999
--context slackSigningSecret=$$SLACK_SIGNING_SECRET
100100
cdk-synth:
101-
npx cdk synth \
101+
mkdir -p .local_config
102+
STACK_NAME=epsam \
103+
COMMIT_ID=undefined \
104+
VERSION_NUMBER=undefined \
105+
SLACK_BOT_TOKEN=dummy_token \
106+
SLACK_SIGNING_SECRET=dummy_secret \
107+
LOG_RETENTION_IN_DAYS=30 \
108+
LOG_LEVEL=debug \
109+
./.github/scripts/fix_cdk_json.sh .local_config/epsam.config.json
110+
CONFIG_FILE_NAME=.local_config/epsam.config.json npx cdk synth \
102111
--quiet \
103-
--app "npx ts-node --prefer-ts-exts packages/cdk/bin/EpsAssistMeApp.ts" \
104-
--context accountId=123456789012 \
105-
--context stackName=epsam \
106-
--context versionNumber=undefined \
107-
--context commitId=undefined \
108-
--context logRetentionInDays=30 \
109-
--context slackBotToken=dummy \
110-
--context slackSigningSecret=dummy \
111-
--context cfnDriftDetectionGroup=dummy
112+
--app "npx ts-node --prefer-ts-exts packages/cdk/bin/EpsAssistMeApp.ts"
112113

113114
cdk-diff:
114115
npx cdk diff \
@@ -119,23 +120,8 @@ cdk-diff:
119120
--context commitId=$$COMMIT_ID \
120121
--context logRetentionInDays=$$LOG_RETENTION_IN_DAYS
121122

122-
cdk-watch: guard-STACK_NAME
123-
REQUIRE_APPROVAL="$${REQUIRE_APPROVAL:-any-change}" && \
124-
VERSION_NUMBER="$${VERSION_NUMBER:-undefined}" && \
125-
COMMIT_ID="$${COMMIT_ID:-undefined}" && \
126-
npx cdk deploy \
127-
--app "npx ts-node --prefer-ts-exts packages/cdk/bin/EpsAssistMeApp.ts" \
128-
--watch \
129-
--all \
130-
--ci true \
131-
--require-approval $${REQUIRE_APPROVAL} \
132-
--context accountId=$$ACCOUNT_ID \
133-
--context stackName=$$STACK_NAME \
134-
--context versionNumber=$$VERSION_NUMBER \
135-
--context commitId=$$COMMIT_ID \
136-
--context logRetentionInDays=$$LOG_RETENTION_IN_DAYS \
137-
--context slackBotToken=$$SLACK_BOT_TOKEN \
138-
--context slackSigningSecret=$$SLACK_SIGNING_SECRET
123+
cdk-watch:
124+
./scripts/run_sync.sh
139125

140126
sync-docs:
141127
./scripts/sync_docs.sh

cdk.context.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"acknowledged-issue-numbers": [
3+
34892
4+
]
5+
}

packages/cdk/constructs/LambdaFunction.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
Code
1919
} from "aws-cdk-lib/aws-lambda"
2020
import {CfnLogGroup, CfnSubscriptionFilter, LogGroup} from "aws-cdk-lib/aws-logs"
21+
import path from "path"
2122

2223
export interface LambdaFunctionProps {
2324
readonly stackName: string
@@ -115,6 +116,12 @@ export class LambdaFunction extends Construct {
115116
managedPolicies: requiredPolicies
116117
})
117118

119+
const dependencyLayer = new LayerVersion(this, "DependencyLayer", {
120+
removalPolicy: RemovalPolicy.DESTROY,
121+
code: Code.fromAsset(path.join(props.packageBasePath, ".dependencies")),
122+
compatibleArchitectures: [Architecture.X86_64]
123+
})
124+
118125
// Create Lambda function with Python runtime and monitoring
119126
const lambdaFunction = new LambdaFunctionResource(this, props.functionName, {
120127
runtime: Runtime.PYTHON_3_13,
@@ -129,7 +136,7 @@ export class LambdaFunction extends Construct {
129136
POWERTOOLS_LOG_LEVEL: props.logLevel
130137
},
131138
logGroup,
132-
layers: [insightsLambdaLayer]
139+
layers: [insightsLambdaLayer, dependencyLayer]
133140
})
134141

135142
// Suppress CFN guard rules for Lambda function

scripts/run_sync.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ echo "Generating config for ${EPSAM_CONFIG}"
6565
echo "Installing dependencies locally"
6666
poetry export --without-hashes --format=requirements.txt --with slackBotFunction > .requirements_slackBotFunction
6767
poetry export --without-hashes --format=requirements.txt --with syncKnowledgeBaseFunction > .requirements_syncKnowledgeBaseFunction
68-
pip3 install -r .requirements_slackBotFunction -t packages/slackBotFunction
69-
pip3 install -r .requirements_syncKnowledgeBaseFunction -t packages/syncKnowledgeBaseFunction
68+
pip3 install -r .requirements_slackBotFunction -t packages/slackBotFunction/.dependencies
69+
pip3 install -r .requirements_syncKnowledgeBaseFunction -t packages/syncKnowledgeBaseFunction/.dependencies
7070

7171
sync_epsam_app() {
7272
echo "Starting sync epsam CDK app"
@@ -82,4 +82,4 @@ sync_epsam_app() {
8282
}
8383

8484

85-
(trap 'kill 0' SIGINT; sync_epsam_app)
85+
# (trap 'kill 0' SIGINT; sync_epsam_app)

0 commit comments

Comments
 (0)