Git Product home page Git Product logo

aws-cost-function's Introduction

aws-cost-function

This is the unpackaged version of this function for further development.

To package

Create a Virtual Environment:

  • Run python3 -m venv mylambdaenv to create a virtual environment.
  • Activate the environment: On Linux/macOS: source mylambdaenv/bin/activate On Windows: mylambdaenv\Scripts\activate

Install Dependencies:

Inside the virtual environment, install the required libraries: pip install boto3 requests. Prepare Your Package:

  • Deactivate the virtual environment (deactivate).
  • Navigate to the virtual environment's lib directory (mylambdaenv/lib/python3.x/site-packages/).
  • Copy all the contents from this folder (except your script) to a new folder, e.g., lambda_package.
  • Place your main.py script inside the lambda_package folder.

Create a ZIP Archive:

  • Zip the contents of lambda_package, not the folder itself.
    • On Linux/macOS: zip -r ../my_lambda_function.zip . (run inside lambda_package folder).

Upload the ZIP to AWS Lambda

Open AWS Management Console:

Create a New Lambda Function:

  • Click on "Create function".
  • Choose "Author from scratch".
  • Enter the function name.
  • Choose the runtime as Python 3.x.
  • Set the role with the necessary permissions (for AWS Cost Explorer and Secrets Manager).
  • Upload Your ZIP File:

In the "Function code" section, choose "Upload a .zip file" from the "Code entry type" dropdown. Upload the ZIP file you created.

Set the Handler:

Make sure the handler is set to main.lambda_handler (assuming your function is named lambda_handler in main.py).

Test the Lambda Function

Configure a Test Event:

  • In the AWS Lambda console, navigate to your function.

  • Click on "Test" near the top of the page.

  • Configure a new test event โ€“ you can use the default template since your script does not rely on the event object.

  • Invoke the Function:

  • Click "Test" to invoke your Lambda function with the test event.

  • Review the Results:

After the function execution, you will see the execution result and the function logs. Check for any errors and ensure that the function is executing as expected.

aws-cost-function's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.