Giter Site home page Giter Site logo

selimcse98 / aws-lambda-sap-odp-extractor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/aws-lambda-sap-odp-extractor

0.0 1.0 0.0 903 KB

Extract data from SAP applications using Operational Data Provisioning

License: MIT No Attribution

Python 100.00%

aws-lambda-sap-odp-extractor's Introduction

aws-sap-odp-auth

This is a sample serverless application (based on AWS Serverless Application Model - AWS SAM) for extracting data from SAP applications (SAP S/4HANA, SAP ECC and SAP BW) using Operational Data Provisioning (ODP). You can find more information on ODP here. Operational Data Provisioning can expose the full load and delta data using OData services. This application package contains a Lambda layer to connect with SAP and consume the OData services as a REST API. Extracted data is saved to S3 Bucket. A DynamoDB table is also created to store the metadata for extracts. The package also contains a sample Lambda function to demonstrate usage of the lamdba layer

Requirements

Setup Process

Installation

  1. Clone this repo to a folder of your choice

  2. Navigate to the root folder of the cloned repo and then perform the preparation steps.

cd aws-lambda-sap-odp-extractor

Preparation

  1. Create parameter store entry for storing the SAP user ID and password details. Make sure to change the value field with your user name and password
aws ssm put-parameter \
    --name sap-odp-extract-auth \
    --description "Parameter to store SAP auth information" \
    --value "{\"user\":\"MYUSERNAME\",\"password\":\"MYPASSWORD\"}" \
    --type "SecureString" \
    --overwrite \
  1. Create S3 bucket where extracted data can be stored. Make sure to change the bucket name and your region as required.
aws s3 mb s3://sap-odp-data-extracts --region us-east-1

Local Testing

Invoking function locally using a local sample payload

  1. Create a file with name environment.json. Use the following format
{
    "SAPODPExtractorTestFunction": {
        "sapHostName" :  "<your sap host name> for e.g. mysap.com (without https://)",
        "sapPort" :  "<your sap https port>",
        "sapAuthParameterStore": "<SSM Parameter created in step 1 above> for e.g. saponaws-odp-sap-odp-extract-auth",
        "metaDataDDBName" : "sap-odp-extract-metadata",
        "odpServiceName" : "<your ODP service name> for e.g. Z_ODP_EXTRACTORS_DEMO_SRV",
        "odpEntitySetName" : "<your ODP entity set name> for e.g. ZKK_SALES_ORDERS",
        "dataChunkSize" : "300",
        "dataS3Bucket": "<bucket creted in step 2 above> for e.g. saponaws-odp-sap-odp-data-extracts"
     }
}
  1. Start the Lambda function locally. Note down the end point url where Lambda is running. Usually http://127.0.0.1:3001
sam local start-lambda \
    --env-vars environment.json \
    --template ../template.yaml \
    --parameter-overrides \
        'ParameterKey=Environment,ParameterValue=saponaws-odp ParameterKey=DynamoDBTableName ParameterValue=sap-odp-extract-metadata'
  1. Open another terminal window and run the following command to invoke the lambda function. Validate the local endpoint url for Lambda
aws lambda invoke \
    --function-name "SAPODPExtractorTestFunction" \
    --endpoint-url "http://127.0.0.1:3001" \
    --no-verify-ssl \
    out.txt
  1. Once run, check out.txt which should have the output of the lambda function

Error Handling

In case of errors, check the values in the response body. 'success' will have a value of false. 'message' should provide you the reason for the failure and 'traceback' provides the stack trace of the exception. Go through the documentation of the extractor.py layer below to understand how the code works

Deployment

  1. Create a S3 bucket for storing latest version of your SAM app. If you are using an existing bucket, proceeed to step 2
aws s3 mb s3://<your account id>-sap-odp-extractor-sam-app>
  1. Package the SAM app
sam package \
    --output-template-file packaged.yaml \
    --s3-bucket <<Your S3 bucket for SAM apps created above>>
  1. Deploy the SAM app
aws cloudformation deploy \
    --template-file packaged.yaml \
    --stack-name saponaws-odp \
    --capabilities CAPABILITY_NAMED_IAM \
    --parameter-overrides \
    Environment=saponaws-odp \
    SAPAuthParameterStore="Parameter store name from perparation step 1" \
    S3BucketForData="Bucket name from perparation step 2"  \
    DynamoDBTableName=sap-odp-extract-metadata

Cleanup

In order to delete our Serverless Application recently deployed you can use the following AWS CLI Command:

aws cloudformation delete-stack --stack-name saponaws-odp

aws-lambda-sap-odp-extractor's People

Watchers

James Cloos 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.