Drodevbar / per-feature-env

MIT License
0 stars 0 forks source link

Sweep: Create a lambda function to update DDB DDB_TABLE_NAME for pk=1 and sk=2 #13

Open Drodevbar opened 1 year ago

Drodevbar commented 1 year ago

Take a look at the implementation of functions/cron-update-dynamodb/handler.ts. The function that you create should be similar to this one. Input for which DDB item to update should be passed from environmental variables from lambda function level

sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/Drodevbar/per-feature-env/pull/15.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left. For more GPT-4 tickets, visit our payment portal.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/Drodevbar/per-feature-env/blob/9812d4e090dc191eee78f6625f9869422053266c/functions/cron-update-dynamodb/handler.ts#L1-L30 https://github.com/Drodevbar/per-feature-env/blob/9812d4e090dc191eee78f6625f9869422053266c/functions/cron-update-dynamodb/function.yml#L1-L11 https://github.com/Drodevbar/per-feature-env/blob/9812d4e090dc191eee78f6625f9869422053266c/serverless.yml#L9-L112 https://github.com/Drodevbar/per-feature-env/blob/9812d4e090dc191eee78f6625f9869422053266c/tasks/task-5.md#L1-L82 https://github.com/Drodevbar/per-feature-env/blob/9812d4e090dc191eee78f6625f9869422053266c/functions/api-hello-world/handler.ts#L1-L27

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
functions/update-dynamodb/handler.ts Create a new file handler.ts in the functions/update-dynamodb/ directory. This file will contain the new lambda function. The function should be similar to the one in functions/cron-update-dynamodb/handler.ts, but it should use environmental variables to get the values for pk and sk.
functions/update-dynamodb/function.yml Create a new file function.yml in the functions/update-dynamodb/ directory. This file will contain the configuration for the new lambda function, including the handler and environmental variables.
serverless.yml Add the new lambda function to the functions section of the serverless.yml file. Also, define the environmental variables for pk and sk in the environment section of the new lambda function.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Create lambda function to update DDB item with pk=1 and sk=2 sweep/feature/update-dynamodb-function

Description

This PR adds a new lambda function to update a DynamoDB item with pk=1 and sk=2. The function is similar to the existing cron-update-dynamodb function, but it uses environmental variables to get the values for pk and sk.

Changes Made

  • Created a new lambda function update-dynamodb in the functions directory.
  • Added a new file handler.ts in the functions/update-dynamodb/ directory, which contains the implementation of the lambda function.
  • Added a new file function.yml in the functions/update-dynamodb/ directory, which contains the configuration for the lambda function, including the handler and environmental variables.
  • Modified the serverless.yml file to include the new lambda function in the functions section and define the environmental variables for pk and sk in the environment section of the new lambda function.

Testing Instructions

  1. Deploy the updated serverless stack.
  2. Trigger the update-dynamodb lambda function manually or through a scheduled event.
  3. Verify that the DynamoDB item with pk=1 and sk=2 has been updated with the current timestamp.

Related Issues

Resolves #13


Step 4: ⌨️ Coding

I have finished coding the issue. I am now reviewing it for completeness.


Step 5: 🔁 Code Review

Success! 🚀


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind! Join Our Discord