aws-sqs-jobs-processer

所属分类:FaaS/Serverless
开发工具:HCL
文件大小:204KB
下载次数:0
上传日期:2023-05-21 08:22:46
上 传 者sh-1993
说明:  AWS上的无服务器作业处理器
(Serverless jobs processor on AWS)

文件列表:
deploy (0, 2023-05-21)
deploy\.terraform.lock.hcl (1377, 2023-05-21)
deploy\00-variables.tf (80, 2023-05-21)
tf (213, 2023-05-21)
deploy\02-api-gateway.tf (1166, 2023-05-21)
deploy\03-api-gateway-role.tf (1139, 2023-05-21)
deploy\04-sqs.tf (252, 2023-05-21)
deploy\05-lambda-process-queue.tf (2843, 2023-05-21)
deploy\06-dynamodb.tf (278, 2023-05-21)
deploy\07-cloudwatch.tf (526, 2023-05-21)
deploy\08-sns.tf (945, 2023-05-21)
deploy\api (0, 2023-05-21)
deploy\api\openapi.yaml (2790, 2023-05-21)
deploy\lambdas (0, 2023-05-21)
deploy\lambdas\archive (0, 2023-05-21)
deploy\lambdas\archive\AWS_SDK_V2_Reference.js (817, 2023-05-21)
deploy\lambdas\archive\AWS_SDK_V3_Reference.js (576, 2023-05-21)
deploy\lambdas\layer (0, 2023-05-21)
deploy\lambdas\layer\package-lock.json (651475, 2023-05-21)
deploy\lambdas\layer\package.json (330, 2023-05-21)
deploy\lambdas\layer\updateLayer.sh (89, 2023-05-21)
deploy\lambdas\processQueue.js (974, 2023-05-21)
deploy\lambdas\processQueue (0, 2023-05-21)
deploy\lambdas\processQueue\index.js (1517, 2023-05-21)
deploy\lambdas\processQueue\package-lock.json (1669, 2023-05-21)
deploy\lambdas\processQueue\package.json (51, 2023-05-21)
deploy\lambdas\processQueue\updateFunction.sh (314, 2023-05-21)
deploy\local.tf (83, 2023-05-21)
deploy\output.tf (79, 2023-05-21)
deploy\templates (0, 2023-05-21)
deploy\templates\getJobByIdRequestMappingTemplate.json (99, 2023-05-21)
deploy\templates\getJobByIdResponseMappingTemplate.json (358, 2023-05-21)
deploy\templates\getJobsRequestMappingTemplate.json (26, 2023-05-21)
deploy\templates\getJobsResponseMappingTemplate.json (435, 2023-05-21)
deploy\templates\postJobsResponseMappingTemplate.json (113, 2023-05-21)
deploy\terraform.tfvars (97, 2023-05-21)
img (0, 2023-05-21)
... ...

# AWS SQS Jobs Processor A reference project to deploy a serverless jobs processor on AWS with Terraform An over-engineered todo app :sweat_smile: App URL here: [`https://8nalvgvzrl.execute-api.us-east-1.amazonaws.com/production/api/v1/jobs`](https://8nalvgvzrl.execute-api.us-east-1.amazonaws.com/production/api/v1/jobs) ![AWS Architecture](img/aws-sqs.JPG) ## Pre-requisite - Make sure you have installed [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli), [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html#cliv2-mac-prereq), and configured a `default` AWS CLI profile (see doc [here](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-profiles)) ```bash terraform -help # prints Terraform options which aws # prints /usr/local/bin/aws aws --version # prints aws-cli/2.0.36 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0 aws configure # configure your AWS CLI profile ``` ## Configuration - Create an [S3 bucket](https://www.terraform.io/docs/language/settings/backends/s3.html) to store Terraform state. Populate bucket name in `01-main.tf` - Create another S3 bucket to store Lambda functions build artifacts: ```bash aws s3api create-bucket --bucket= --region= ``` - Populate `terraform.tfvars`: ```bash default_region = "" app_name = "" environment = "" ``` ## Deploy Lambda package - Navigate to `/deploy/lambdas/` - Create a `.zip` file: ```bash zip -r .zip . ``` - Uploads Lambda artifact to S3 bucket: ```bash aws s3 cp .zip s3:///v1.0.0/.zip ``` ## Deploy Lambda layer ```bash cd deploy/lambdas/layer # change to lambda layer directory sh updateLayer.sh # uploads lambda layer to S3 bucket ``` ## Deploy AWS stack ```bash cd deploy # change to deploy directory terraform init # initialises Terraform terraform apply # deploys AWS stack. See output for API url terraform destroy # destroys AWS stack ``` ## Usages - Make a `POST` request to `/api/v1/jobs` to trigger a job which creates todos. Each item in the `data` array creates a todo: ```json { "data": ["foo", "bar"] } ``` - Make a `GET` request to `/api/v1/jobs` to retrieve all jobs - Make a `GET` request to `/api/v1/jobs/` to retrieve a specific job ## Update Lambda package - Update the `deploy/lambdas/processQueue/updateFunction.sh` shell script with correct values i.e. Amazon S3 bucket name, and key. See documentation on AWS CLI `update-function-code` [here](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/update-function-code.html) - Run the script: ```bash cd deploy/lambdas/processQueue # change to lambda directory chmod +x updateFunction.sh # set permission to run script ./updateFunction.sh # run the script ``` ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate. If you find this project helpful, please give a :star: or even better buy me a coffee :coffee: :point_down: because I'm a caffeine addict :sweat_smile: Buy Me A Coffee ## License [MIT](https://choosealicense.com/licenses/mit/)

近期下载者

相关文件


收藏者