Wip backend (#4)

* feat: Add new API handlers for user, project, and task management; update package dependencies

* feat: Update .gitignore, add Lambda layer configuration, and refactor DynamoDB handlers to use AWS SDK v3

* feat: Update serverless configuration and refactor API handlers to improve error handling and response structure

* feat: Add Cognito user pool name parameter and update API handlers to include CORS headers

* feat: Update task and project ID formats, add populateSeedData function, and enhance user ID handling

* feat: Update image source paths to use S3 public URL for profile and task attachments
This commit was merged in pull request #4.
This commit is contained in:
2024-11-23 18:17:00 +02:00
committed by GitHub
parent ac8455ab3a
commit 11e61829f1
39 changed files with 5438 additions and 100 deletions

View File

@@ -76,6 +76,20 @@ resource "aws_ssm_parameter" "user_pool_id" {
value = aws_cognito_user_pool.tasker_cognito_user_pool.id
}
resource "aws_ssm_parameter" "user_pool_arn" {
name = "/tasker/cognito/user-pool-arn"
description = "Tasker Cognito User Pool ARN"
type = "String"
value = aws_cognito_user_pool.tasker_cognito_user_pool.arn
}
resource "aws_ssm_parameter" "user_pool_name" {
name = "/tasker/cognito/user-pool-name"
description = "Tasker Cognito User Pool Name"
type = "String"
value = aws_cognito_user_pool.tasker_cognito_user_pool.name
}
resource "aws_ssm_parameter" "client_id" {
name = "/tasker/cognito/client-id"
description = "Tasker Cognito Client ID"

View File

@@ -1,11 +1,11 @@
resource "aws_dynamodb_table" "tasker_project_table" {
name = "tasker-project-table"
billing_mode = "PAY_PER_REQUEST"
hash_key = "type"
hash_key = "category"
range_key = "projectId"
attribute {
name = "type"
name = "category"
type = "S"
}
@@ -30,11 +30,11 @@ resource "aws_ssm_parameter" "tasker_project_table_arn" {
resource "aws_dynamodb_table" "tasker_user_table" {
name = "tasker-user-table"
billing_mode = "PAY_PER_REQUEST"
hash_key = "type"
hash_key = "category"
range_key = "cognitoId"
attribute {
name = "type"
name = "category"
type = "S"
}
@@ -50,7 +50,7 @@ resource "aws_dynamodb_table" "tasker_user_table" {
global_secondary_index {
name = "GSI-user-id"
hash_key = "type"
hash_key = "category"
range_key = "userId"
projection_type = "ALL"
}
@@ -71,11 +71,11 @@ resource "aws_ssm_parameter" "tasker_user_table_arn" {
resource "aws_dynamodb_table" "tasker_team_table" {
name = "tasker-team-table"
billing_mode = "PAY_PER_REQUEST"
hash_key = "type"
hash_key = "category"
range_key = "teamId"
attribute {
name = "type"
name = "category"
type = "S"
}
@@ -100,11 +100,11 @@ resource "aws_ssm_parameter" "tasker_team_table_arn" {
resource "aws_dynamodb_table" "tasker_task_table" {
name = "tasker-task-table"
billing_mode = "PAY_PER_REQUEST"
hash_key = "type"
hash_key = "category"
range_key = "taskId"
attribute {
name = "type"
name = "category"
type = "S"
}
@@ -130,21 +130,21 @@ resource "aws_dynamodb_table" "tasker_task_table" {
global_secondary_index {
name = "GSI-project-id"
hash_key = "type"
hash_key = "category"
range_key = "projectId"
projection_type = "ALL"
}
global_secondary_index {
name = "GSI-author-user-id"
hash_key = "type"
hash_key = "category"
range_key = "authorUserId"
projection_type = "ALL"
}
global_secondary_index {
name = "GSI-assigned-user-id"
hash_key = "type"
hash_key = "category"
range_key = "assignedUserId"
projection_type = "ALL"
}
@@ -165,11 +165,11 @@ resource "aws_ssm_parameter" "tasker_task_table_arn" {
resource "aws_dynamodb_table" "tasker_task_extra_table" {
name = "tasker-task-extra-table"
billing_mode = "PAY_PER_REQUEST"
hash_key = "type"
hash_key = "category"
range_key = "id"
attribute {
name = "type"
name = "category"
type = "S"
}
@@ -185,7 +185,7 @@ resource "aws_dynamodb_table" "tasker_task_extra_table" {
global_secondary_index {
name = "GSI-task-id"
hash_key = "type"
hash_key = "category"
range_key = "taskId"
projection_type = "ALL"
}

View File

@@ -0,0 +1,24 @@
resource "aws_s3_bucket" "tasker_lambda_layer" {
bucket = "tasker-lambda-layer"
}
resource "aws_s3_object" "tasker_lambda_layer_zip" {
bucket = aws_s3_bucket.tasker_lambda_layer.id
key = "layers/tasker-layer.zip"
source = "../layers/tasker-layer.zip"
}
resource "aws_lambda_layer_version" "tasker_layer" {
layer_name = "tasker-layer"
s3_bucket = aws_s3_object.tasker_lambda_layer_zip.bucket
s3_key = aws_s3_object.tasker_lambda_layer_zip.key
compatible_runtimes = ["nodejs20.x"]
description = "Tasker Lambda Layer with shared dependencies"
}
resource "aws_ssm_parameter" "tasker_layer_arn" {
name = "/tasker/layers/tasker-layer-arn"
type = "String"
value = aws_lambda_layer_version.tasker_layer.arn
}

View File

@@ -1,11 +1,22 @@
resource "aws_s3_bucket" "tasker_public_images" {
bucket = "tasker-public-images"
tags = {
Environment = "Dev"
}
}
resource "aws_s3_bucket_policy" "public_read_policy" {
bucket = aws_s3_bucket.tasker_public_images.id
policy = data.aws_iam_policy_document.public_read_policy.json
}
data "aws_iam_policy_document" "public_read_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.tasker_public_images.arn}/*"]
principals {
type = "AWS"
identifiers = ["*"]
}
}
}
resource "aws_s3_bucket_ownership_controls" "tasker_public_images_ownership_controls" {
bucket = aws_s3_bucket.tasker_public_images.id