Skip to content

GiAnjos/lambda_code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

lambda_code

Here you can find a code for a lambda function that finds the latest file from a folder, moves it to a new folder and starts two workflows inside of AWS Glue.

For the lambda function to work you need to do the proper configurations. First you need to create or find an existing role inside of AWS IAM with the areas of AWS that you need access to change. I will show here step by step of how I created my role and what permissions it has.

To create a role go to the area "roles" inside of IAM and select "Create":

image

Select the first option in the "trusted entity type" area:

image

Select Lambda as an option for the area "use case":

image

After that you will need to select the permissions you need for the project. Just select them all and click next in the end of the page. In this case we are going to use these permissions:

image

In the end create a name for you role, review everything and click create role.

The role is ready so now you need to create the function.

Go to Lambda in AWS and click create function. After that select "author from scratch" in the first area and also create the name of your function:

image

Select the language that you are going to write your function. In this case Pyhton 3.9:

image

For permissions you can search for the role that you created previously:

image

Go to your function and add a trigger so it knows when to start the function. My function was created to be triggered when a file gets posted in a the "OLDEST FOLDER" as you can see on the code. So lets go to the step by step.

To create a trigger select S3 as a source:

image

Put the name of the bucket that you are using for the project and add the prefix or suffix of the folder that you want. I added a prefix "OLDEST FOLDER/" for this project:

image

Don't forget to a acknowledge the following message and click add:

image

Add the code in this area of your function and click test:

image

When you click on test it will open a pop-up with the test configurations. Add a name for your test and select if you want to share the test with others or not:

image

For the test template I used cloudwatch:

image

You can check the results of your test in the execution results tab:

image

Click deploy if you have the approval to do so and all done!!

About

Code for a lambda function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages