https://github.com/chinsun9/sam-typescript-practice
https://github.com/chinsun9/sam-typescript-practice
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chinsun9/sam-typescript-practice
- Owner: chinsun9
- Created: 2020-11-09T02:01:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T00:35:31.000Z (about 4 years ago)
- Last Synced: 2025-01-30T08:43:06.855Z (4 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sam-typescript
- sam에서 타입스크립트 쓰기
1. package.json에 추가
```json
"scripts": {
"compile": "tsc"
},
"devDependencies": {
"aws-sdk": "^2.655.0",
"@types/aws-lambda": "^8.10.51",
"@types/node": "^13.13.5",
"typescript": "^3.8.3"
}
```2. package.json과 같은 경로에 tsconfig.json 추가
```json
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2017",
"noImplicitAny": true,
"preserveConstEnums": true,
"outDir": "./built",
"sourceMap": true
},
"include": ["src-ts/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
```3. `npm i` 로 패키지 설치
4. src-ts 밑에 app.ts 작성
5. template.yaml 수정
```yaml
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/built
Handler: app.lambdaHandler
```현재까지 디렉터리 구조
```
├── README.md
├── hello-world
│ ├── package-lock.json
│ ├── package.json
│ ├── src-ts
│ │ └── app.ts
│ └── tsconfig.json
├── samconfig.toml
└── template.yaml
```6. tsc and deploy
```
npm run compile
sam deploy --guided
```