diff options
| -rw-r--r-- | DEVNOTES.md | 55 | ||||
| -rw-r--r-- | events.tf | 52 |
2 files changed, 107 insertions, 0 deletions
diff --git a/DEVNOTES.md b/DEVNOTES.md new file mode 100644 index 0000000..00f06ec --- /dev/null +++ b/DEVNOTES.md @@ -0,0 +1,55 @@ +# Workflow + +## Commits + +### Make small and focused commits +- Please avoid mixing unrelated changes in a single commit +- Commit at regular points to revert changes easily if needed + +### Write clear commit messages +- Limit subject line to 50 characters +- Provide more detailed explainations in the commit body (if required) +- Use the imperative mood in the subject line (e.g. 'add' instead of 'added') + +``` +$ ~ git commit +``` + +``` +[Type]: [Short Subject] +---[Blank Line]--- +[Body, Limit to 72 Characters] +``` +- Types: feat, fix, docs, style, refactor, test, chore, ci, perf + - See [here](https://eagerworks.com/blog/conventional-commits) for more information + +## Branches + +### Naming Conventions + +- Use lowercase with hyphens +- Include type and change with small description + +``` +[type]/[brief-description] :: e.g. feature/api +``` +### Base Branch + +- Branch from `develop` for features and non-urgent fixes +- Branch off from `main` for urgent changes (project deadline) - this should be rarely used + +### Keep branches updated + +- Regularly merge and also delete branches when stale + +## PRs + +1. Create a pull request for each feature or fix (link to related issues) +2. Write a clear description which... + 1. Summarises the changes + 2. Explains the reasoning behind the changes + 3. Lists any areas of concerns (i.e. breaking changes) +3. Keep PRs focused - split changes into multiple PRs if needed +4. Assign someone to review +5. Merge ONLY after team approval - resolve conflicts & ensure CI checks pass +6. Use [squash and merge](https://learn.microsoft.com/en-us/azure/devops/repos/git/merging-with-squash?view=azure-devops) when needed to keep main branch history clean
\ No newline at end of file diff --git a/events.tf b/events.tf new file mode 100644 index 0000000..25fb35b --- /dev/null +++ b/events.tf @@ -0,0 +1,52 @@ +resource "aws_cloudwatch_event_rule" "lambda_trigger" { + name = "lambda-scheduled-trigger" + description = "Schedule to trigger the Lambda function" + schedule_expression = "rate(30 minutes)" + +# event_pattern = jsonencode({ +# detail-type = [ +# "AWS Console Sign In via CloudTrail" +# ] +# }) +} + + +resource "aws_cloudwatch_event_target" "lambda" { + rule = aws_cloudwatch_event_rule.lambda_trigger.name + target_id = "TargetFunctionV1" + arn = aws_lambda_function.my_lambda_function.arn +} + + + +resource "aws_lambda_permission" "allow_eventbridge" { + statement_id = "AllowExecutionFromEventBridge" + action = "lambda:InvokeFunction" + function_name = aws_lambda_function.my_lambda_function.function_name + principal = "events.amazonaws.com" + source_arn = aws_cloudwatch_event_rule.lambda_trigger.arn +} + + +# below is step function 1 +resource "aws_lambda_permission" "allow_s3_ingestion" { + statement_id = "AllowS3InvokeLambdaTransform" + action = "lambda:InvokeFunction" + function_name = aws_lambda_function.lambda_transform.function_name + principal = "s3.amazonaws.com" + source_arn = aws_s3_bucket.extract.arn +} + + +resource "aws_s3_bucket_notification" "extract_bucket_notification" { + bucket = aws_s3_bucket.extract.id + + lambda_function { + events = ["s3:ObjectCreated:*"] + lambda_function_arn = aws_lambda_function.lambda_transform.arn + } + + depends_on = [aws_lambda_permission.allow_s3_ingestion] +} + +# need to duplicate and replace "2" with "3"
\ No newline at end of file |
