https://github.com/trustcruit/tc-sam-cli
https://github.com/trustcruit/tc-sam-cli
aws-lambda aws-sam-cli python3 python37
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/trustcruit/tc-sam-cli
- Owner: trustcruit
- License: mit
- Created: 2019-04-30T07:26:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T06:13:08.000Z (over 3 years ago)
- Last Synced: 2025-03-12T14:20:11.320Z (about 1 year ago)
- Topics: aws-lambda, aws-sam-cli, python3, python37
- Language: Python
- Homepage: https://pypi.org/project/tc-sam-cli/
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**DO NOT USE, THIS IS PRE-ALPHA, HAS NO TESTS**
# tc-sam-cli
A very simplified tool wrapped around aws-sam-cli to deploy aws lambda.
Works together with [tclambda](https://pypi.org/project/tclambda/)
## Configuration
```toml
[Default]
StackName = "tc-sam-playground"
S3CodeBucket = "tc-sam-bucket"
[[ExtraPolicies]]
Effect = "Allow"
Action = ["dynamodb:*"]
Resource = "arn:aws:dynamodb:eu-west-1:1234:table/myTable"
[Functions.MyLambda]
CodeUri = "mylambda/"
Handler = "app.handler"
Runtime = "python3.7"
MemorySize = 256
Timeout = 60
ReservedConcurrentExecutions = 1
BatchSize = 10
[Functions.MyLambda.Environment]
MY_KEY = "my value"
[Functions.TcLambda.Events.Ping]
Schedule = "rate(1 minute)"
Function = "ping"
# More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
[Functions.TcLambda.Api.Webhook]
Path = "/hello"
Method = "post"
[Functions.Numpy]
CodeUri = "numpy/"
Handler = "app.handler"
Runtime = "python3.7"
MemorySize = 256
Timeout = 60
Tracing = true
```
### Generate AWS SAM template
After every change in `tc-sam.toml` the template must be regenerated.
```sh
$ tc-sam generatetemplate > template.json
```
It's recommended to have `template.json` under source control.
Every Lambda has given access to each other's SQS Queue, and all Lambdas share the same S3 bucket for results.
### Deploy
Deploy is very straightforward, it builds the sam package and deploys the cloudformation stack.
```sh
$ tc-sam deploy
```
### Environmental export
```sh
$ tc-sam env_export
TC_NUMPY_QUEUE="https://sqs.eu-west-1.amazonaws.com/123/tc-sam-playground-NumpySqs-ABC"
TC_NUMPY_BUCKET="tc-sam-playground-resultbucket-123456"
TC_MYLAMBDA_QUEUE="https://sqs.eu-west-1.amazonaws.com/123/tc-sam-playground-TcLambdaSqs-ABC"
TC_MYLAMBDA_BUCKET="tc-sam-playground-resultbucket-123456"
```
These settings can be copied to other projects that will use the aws lambdas.
### Ping all lambdas
The tclambda handler comes with a `ping` command to test if both permissions to SQS and S3 are allowed.
```sh
$ tc-sam ping
Ping NUMPY
Ping MYLAMBDA
Pong NUMPY
Pong MYLAMBDA
```