Sample architecture to process events asynchronously using API Gateway and Lambda.
A typical workflow looks as following:
/jobs
jobs API endpoint, specifying in the request body the job parameters/jobs/{jobId}
jobs API endpoint, with the job identifier from step 3. as {jobId}
If the event processing fails:
/jobs/{jobId}
jobs API endpointIf the error handling fails:
JobsAPIInvokeRole
will be able to invoke the jobs API: as such, the access control mechanism is binary. If your use case requires a more complex authorization model, evaluate to use a different access control mechanism/jobs
jobs API endpoint, the input data is validated at two different levels: Amazon API Gateway is in charge of the first request validation while the event processing function executes the second one. No validation is performed when the user does an HTTP GET request to the /jobs/{jobId}
jobs API endpoint. If your use case requires additional input validation and an increased level of security, evaluate to use AWS WAF to protect your APIInstall on your workstation the following tools:
2.61.0
20.10.21
18.13.0
0.67.3
3.9.16
You should also own or have access to an AWS account.
Execute the following steps on your workstation:
cd asynchronous-event-processing-api-gateway-api-gateway-lambda-cdk
npx projen
source .env/bin/activate
pre-commit install
pre-commit install --hook-type commit-msg
To run the project tests execute:
npx projen test
To lint the project code execute:
npx projen synth
npx projen lint
To perform a security scan of the project code execute:
npx projen synth
npx projen scan
Execute the following steps on your workstation:
__version__
in .projenrc.py
(follow PEP440 specification):...
__version__ = "0.1.0"
...
npx projen
npx projen release
git push
git push --tags
To bootstrap the AWS CDK in your AWS account execute:
AWS_PROFILE=$YOUR_AWS_PROFILE npx projen bootstrap
To deploy your application in your AWS account execute:
AWS_PROFILE=$YOUR_AWS_PROFILE npx projen deploy
To cleanup your application in your AWS account execute:
AWS_PROFILE=$YOUR_AWS_PROFILE npx projen destroy
To try the sample architecture included in this repository proceed to:
JobsAPIInvokeRole
printed as output from the deploy commandJobsAPI
variables as following:
accessKey
: value of the Credentials.AccessKeyId
attribute from the assume-role
commandbaseUrl
: value of the JobsApiJobsAPIEndpoint
output from the deploy command without trailing slashregion
: value of the AWS Region where you deployed the sample architectureseconds
: the value of the input parameter for the sample job. It must be a positive integersecretKey
: value of the Credentials.SecretAccessKey
attribute from the assume-role
commandsessionToken
: value of the Credentials.SessionToken
attribute from the assume-role
commandSee CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.