Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pattern submission - Finding list of Inactive lambda functions and publish it to SNS topic using Step Functions #2534

Open
sahilk225579 opened this issue Dec 11, 2024 · 0 comments

Comments

@sahilk225579
Copy link

sahilk225579 commented Dec 11, 2024

To submit a template to the Serverless Patterns Collection, submit an issue with the following information.

IMPORTANT
Patterns are intended to be primarily IaC-focused implementations of 2-4 AWS services, with minimum custom code. They should be commonly used combinations that help developers get started quickly. If you have a utility, demo, or application, submit these to the Serverless Repos Collection instead.

ONLY SUBMIT ONE PATTERN CHANGE PER PR. Multiple patterns or files spanning multiple pattern directories will be automatically rejected.

Patterns may take up to 4-6 weeks to review, test, and merge but there is no SLA and can take significantly longer due to other work the team has.

To learn more about submitting a pattern, read the publishing guidelines page.

  1. Use the model template located at https://github.com/aws-samples/serverless-patterns/tree/main/_pattern-model to set up a README, template and any associated code.

  2. THIS PROCESS HAS BEEN SIMPLIFIED. All the information below must be provided in the "example-pattern.json" file cloned from the model **

Note the following information for the model:

  • Description (intro.text) should be a 300-500 word explanation of how the pattern works.

eventbridge

This pattern creates a Step function which is invoked on daily basis using cron pattern defined in Eventbridge scheduler. In the State machine it uses SDK integration for ListFunctions API call to get the list of Lambda functions in a region, each API call returns the list of 50 Functions & NextMarker, which is the pagination token that's included if more results are available and is used to get List of all the functions in the region.

Once all the function's list is retrieved and appended to json array using the custom lambda function, The json array is passed as input to the Map state. Map state uses Inline mode to iterate for each json array element which contains the Lambda function ARN. GetFunction API is called to get function's configuration like Status,LastUpdateStatus,LastModified & append the output to the map's state output.

In the next step 'Filter Inactive Functions', Iist of Inactive functions is filtered out using the below JSONata expression.

{
  "Inactive_Functions": "{% $states.input.FunctionConfig[State='Inactive'] ?  $states.input.FunctionConfig[State='Inactive'] : false %}"
}

List of Inactive functions is sent to next step - SNS Publish where the list of Inactive functions is published to the SNS topic and list is received on subscribed email.

The state machine can be manually invoked as well using the Input as below.

{
        "Function_ARN_List_existing": {
        "lambda_arn_list_combined": []
        },
        "NextMarker": null
}

Email Output

  • Resources should like to AWS documentation and AWS blogs related to the post (1-5 maximum).
  1. Tracking the state of AWS Lambda functions - https://aws.amazon.com/blogs/compute/tracking-the-state-of-lambda-functions/
  2. Lambda function states - https://docs.aws.amazon.com/lambda/latest/dg/functions-states.html
  • Author bio may include a LinkedIn and/or Twitter reference and a 1-sentence bio.

Name: Sahil Kapoor
Photo URL: https://media.licdn.com/dms/image/v2/D5603AQHTVptga3RxcA/profile-displayphoto-shrink_800_800/B56ZO3ZfseHoAc-/0/1733948735068?e=1739404800&v=beta&t=FX6MFZ2JFH17KQc89u4gY6tQXGoMJLiLkB2qT3MtV2g
Twitter handle: n/a
Linkdin : https://www.linkedin.com/in/sahil-kapoor-503391a7/
Description (up to 255 chars): I am a Cloud Support Engineer at AWS

You must ensure that the sections of the model README.md are completed in full.

GitHub PR for template:

#2533

@sahilk225579 sahilk225579 changed the title New pattern submission New pattern submission - Finding list of Inactive lambda functions and publish it to SNS topic using Step Functions Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant