<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vineet k on Medium]]></title>
        <description><![CDATA[Stories by Vineet k on Medium]]></description>
        <link>https://medium.com/@vineetkarandikar?source=rss-72a7114648d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QelqHfii1tFLcm05i6qVhg.jpeg</url>
            <title>Stories by Vineet k on Medium</title>
            <link>https://medium.com/@vineetkarandikar?source=rss-72a7114648d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:49:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vineetkarandikar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python FASTAPI-decorator-for RBAC(Role based access control)]]></title>
            <link>https://vineetkarandikar.medium.com/python-fastapi-decorator-for-rbac-role-based-access-control-cceb5e042956?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/cceb5e042956</guid>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[decorators]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[role-based-access-control]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Thu, 27 May 2021 09:19:11 GMT</pubDate>
            <atom:updated>2021-05-27T09:19:11.118Z</atom:updated>
            <content:encoded><![CDATA[<p>Create RBACK decorator in fast Api to intercept the JWT Token, extract the user_id and get the roles and match it with the roles defined for that particular REST API.</p><p><a href="https://github.com/vineetkarandikar/aws-samples/blob/main/auth.py">https://github.com/vineetkarandikar/aws-samples/blob/main/auth.py</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cceb5e042956" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQLALCHEMY-Reverse engineer-Python]]></title>
            <link>https://vineetkarandikar.medium.com/sqlalchemy-reverse-engineer-python-725938af3326?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/725938af3326</guid>
            <category><![CDATA[sqlalchemy]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Thu, 27 May 2021 09:11:30 GMT</pubDate>
            <atom:updated>2021-05-27T09:11:30.212Z</atom:updated>
            <content:encoded><![CDATA[<p>Below is the command to generate models from database directly in quick fashion.</p><p><strong>$ pip install sqlacodegen</strong></p><p><strong>$ pip install pymysql</strong></p><p>Create your db schema.</p><p>now issue the following command</p><p><strong>$ sqlacodegen mysql+pymysql://Nich:Bossdk#@localhost/dev</strong></p><p>the output will be like given below</p><p>class User(Base):<br> __tablename__ = ‘user’</p><p>user_id = Column(Integer, primary_key=True)<br> first_name = Column(String(255), nullable=False)<br> last_name = Column(String(255))<br> email_id = Column(String(255), unique=True)<br> phone_no = Column(BigInteger)<br> country = Column(String(50))<br> _pass = Column(‘pass’, String(255))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=725938af3326" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[S3-Object Listing-filter by date]]></title>
            <link>https://vineetkarandikar.medium.com/s3-object-listing-filter-by-date-3feea42a9857?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3feea42a9857</guid>
            <category><![CDATA[aws-s3-bucket]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Thu, 27 May 2021 09:05:31 GMT</pubDate>
            <atom:updated>2021-05-27T09:05:31.858Z</atom:updated>
            <content:encoded><![CDATA[<p>S3-Object Listing-filter by date</p><h3>S3-Object Listing-filter by date</h3><p><a href="https://github.com/vineetkarandikar/aws-samples/blob/main/s3_object_list_filter_by_date.py">https://github.com/vineetkarandikar/aws-samples/blob/main/s3_object_list_filter_by_date.py</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3feea42a9857" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MACRO SERVER-LESS REPOSITORY CI-CD GIT-FOR LAB AWS LAMBDA]]></title>
            <link>https://vineetkarandikar.medium.com/macro-server-less-repository-ci-cd-git-for-lab-aws-lambda-bd8c8c1733cc?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd8c8c1733cc</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 13:26:50 GMT</pubDate>
            <atom:updated>2021-02-10T13:34:39.650Z</atom:updated>
            <content:encoded><![CDATA[<h3>MACRO SERVERLESS REPOSITORY CI-CD GIT-LAB FOR AWS LAMBDA</h3><p>create CI-CD pipeline for aws lambda on Git-Lab.</p><p>First create a repository in Git-lab.</p><p>Then go to settings →CI-CD →variables and click on expand section and setup the aws access secret and key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qa_uPtYEg3wWxi5Bo4xfCA.png" /></figure><p>Now install runner on machine of your choice i.e. Git-Lab runner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*10-HmM_gir-dFhOIS0tKeA.png" /></figure><p>Then go to settings →CI-CD →Runners and expand the section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9J_8-pzRmuyY1gqHPRufKg.png" /></figure><p>Now create a custom runner and follow the steps on machine and OS of your choice as mentioned below in screenshot,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*C8fx671rVkoUGaYVmho3Bw.png" /></figure><p>After following the above steps,in case if you are using Ubuntu machine than don’t forget to change the entry by using the command and the newly entry is in bold.</p><p><strong>$ sudo visudo</strong></p><p>Add the below entry as per the user for Git-Lab runner for me it is show below</p><p># This file MUST be edited with the ‘visudo’ command as root.<br>#<br># Please consider adding local content in /etc/sudoers.d/ instead of<br># directly modifying this file.<br>#<br># See the man page for details on how to write a sudoers file.<br>#<br>Defaults env_reset<br>Defaults mail_badpass<br>Defaults secure_path=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin”</p><p># Host alias specification</p><p># User alias specification</p><p># Cmnd alias specification</p><p># User privilege specification<br>root ALL=(ALL:ALL) ALL</p><p># Members of the admin group may gain root privileges<br>%admin ALL=(ALL) ALL</p><p># Allow members of group sudo to execute any command<br>%sudo ALL=(ALL:ALL) ALL</p><p># See sudoers(5) for more information on “#include” directives:</p><p>#includedir /etc/sudoers.d<strong><br>gitlab-runner ALL=(ALL) NOPASSWD: ALL</strong></p><p>NOTE:Also don’t forget to check run un-tagged jobs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrUGPij5SbeaP1o1SlR95g.png" /></figure><p>so that we can run jobs just for experiments.In real world you should not check it.</p><p>Now go to project and click setup CI-CD ,Right now it is CI-CD configuration as i have already created it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayUJp9xKLEkj0N5EkJD7Tw.png" /></figure><p>Once you click the set CI-CD ,User will get option for <a href="https://gitlab.onionlife.in/ai/data_sync_scripts_poc/blob/master/.gitlab-ci.yml"><strong>.gitlab-ci.yml</strong></a><strong> file creation.</strong></p><p>below is the content for <a href="https://gitlab.onionlife.in/ai/data_sync_scripts_poc/blob/master/.gitlab-ci.yml"><strong>.gitlab-ci.yml</strong></a></p><p>========================================</p><pre>image: docker:latest<br><br>before_script:<br>  - sudo apt-get update -y  # Updating the Ubuntu Docker instance.<br>  - python -V  # Print out python version for debugging.<br>  - sudo apt install -y zip<br>  - sudo pip install --upgrade pip<br>  - sudo apt install -y python3-pip<br>  - sudo pip3 install awscli --force-reinstall --upgrade<br>  - export PATH=~/.local/bin:$PATH # Required for awscli.<br>  - aws --version  # Print out aws cli version for debugging.<br><br>stages:<br>  - deploy<br><br>variables:<br>  LAMBDA_NAME: &#39;vineet-hello-world&#39;   # Replace it with the name of aws lambda function you want.<br>  S3_BUCKET: &#39;vineet-poc&#39;   # Replace it with the name of Bucket that will hold the zip code.<br>  LAMBDA_RUNTIME: &#39;python3.7&#39;<br>  LAMBDA_ARN: &#39;arn:aws:lambda:ap-south-1:696539842619:function:vineet-hello-world&#39; # ARN associated with this lambda function.<br>  LAMBDA_HANDLER: &#39;lambda_function.lambda_handler&#39;  # This is default lambda handler.<br><br>deploy:<br>  stage: deploy<br>  <br>  only:<br>  - master   # We will run the CD only when something is going to change in master branch.<br><br>  script:<br>  - zip -r code.zip lambda_function.py   # Archive the code repository.<br>  - aws s3 cp code.zip s3://$S3_BUCKET/code.zip # Upload archive into s3.<br>  - aws lambda update-function-code --function-name $LAMBDA_NAME --zip-file fileb://code.zip || aws lambda create-function --function-name $LAMBDA_NAME --runtime $LAMBDA_RUNTIME --role $LAMBDA_ARN --handler $LAMBDA_HANDLER --code S3Bucket=$S3_BUCKET,S3Key=code.zip --memory-size 1024<br><br>  environment:<br>    name: master</pre><p>Now if we have more than one lambda we have to specify variables for every lambda and also include individual commands for every lambda in script section.</p><p>This is the concept of Macro repositories where you have all the lambdas in one repository which is useful if you have to-many lambdas.</p><p>If you have few lambdas micro repository is a good option as maintaining the repositories is easy and if we are not anticipating lot of code changes.</p><p>Now once you commit any change, build will get triggered and lambda updated code will be deployed to AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqJQ5bxJzRdnvjJLUU82nA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd8c8c1733cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD pipeline for AWS Lambda using GitHub]]></title>
            <link>https://vineetkarandikar.medium.com/ci-cd-pipeline-for-aws-lambda-using-github-a52d231036be?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a52d231036be</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Wed, 20 Jan 2021 05:22:15 GMT</pubDate>
            <atom:updated>2021-01-20T05:27:46.103Z</atom:updated>
            <content:encoded><![CDATA[<p>Create CI/CD pipeline for AWS Lambda Server-less using github workflow.</p><p>First create aws lambda function using <a href="https://www.npmjs.com/package/serverless"><strong>https://www.npmjs.com/package/serverless</strong></a> which i have shown in one of my blog post.</p><p>Now create git private repository as you don’t want your aws secrets to be public.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiiIdsIPC1m8Efnauo0XLQ.png" /></figure><p>Configure your AWS secrets as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EBZO69xdtFdbrxzyz9fR8g.png" /></figure><p>Now go to actions to set up workflow yourself as show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GqbNR8zDpGE-Cx1GSy7cVw.png" /></figure><p>Use the below main.yaml file as show below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5wxMgzxSii_i5kibRpo9w.png" /></figure><p><strong>main.yaml</strong> is given below</p><p>##############################</p><p><strong>name: deploy to lambda</strong></p><p><strong>on: [push]</strong></p><p><strong>jobs:</strong></p><p><strong>deploy_source:</strong></p><p><strong>name: build and deploy lambda</strong></p><p><strong>strategy:</strong></p><p><strong>matrix:</strong></p><p><strong>node-version: [12.x]</strong></p><p><strong>runs-on: ubuntu-latest</strong></p><p><strong>steps:</strong></p><p><strong>- uses: actions/checkout@v1</strong></p><p><strong>- name: Use Node.js ${{ matrix.node-version }}</strong></p><p><strong>uses: actions/setup-node@v1</strong></p><p><strong>with:</strong></p><p><strong>node-version: ${{ matrix.node-version }}</strong></p><p><strong>- name: npm install and build</strong></p><p><strong>run: |</strong></p><p><strong>npm ci</strong></p><p><strong>npm run build — if-present</strong></p><p><strong>env:</strong></p><p><strong>CI: true</strong></p><p><strong>- name: zip</strong></p><p><strong>uses: montudor/action-zip@v0.1.0</strong></p><p><strong>with:</strong></p><p><strong>args: zip -qq -r ./bundle.zip ./</strong></p><p><strong>- name: default deploy</strong></p><p><strong>uses: appleboy/lambda-action@master</strong></p><p><strong>with:</strong></p><p><strong>aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}</strong></p><p><strong>aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}</strong></p><p><strong>aws_region: us-east-1</strong></p><p><strong>function_name: hello-world-medium-dev-hello</strong></p><p><strong>zip_file: bundle.zip</strong></p><p>############################################</p><p>Now in above <strong>main.yaml</strong> file don’t forget to change the function name to your aws lambda function which you want to use.</p><p>Now when you make changes to your lambda code locally in may be visual studio and commit the same in git,workflow will automatically get’s triggered as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwPDGOJpDTXOLh4F3JLDKA.png" /></figure><p>And if everything is perfect you will get successfully deployed code in aws lambda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iH4lZqBjh-PMISgylGAs8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EkypNd1iVM5x-iJ9aj4W_w.png" /></figure><p><strong>Note: Also don’t forget to commit package-lock.json and don’t commit node_modules.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ykCiPStxasjBm1QHjtio_Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a52d231036be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Server-less code deploy from Visual Code]]></title>
            <link>https://vineetkarandikar.medium.com/aws-server-less-code-deploy-from-visual-code-448ba9f1016a?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/448ba9f1016a</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Tue, 19 Jan 2021 10:41:44 GMT</pubDate>
            <atom:updated>2021-01-19T10:42:40.926Z</atom:updated>
            <content:encoded><![CDATA[<p>Run the following commands</p><p><strong>npm install -g serverless</strong></p><p><strong>serverless config credentials --provider aws --key XXXXXXXXXEXAMPLE --secret XXXXXXXXX/XXXXXXX/XXXXXXXXX</strong></p><p>Also make sure the IAM user for which we would be using aws key and secret should have following policies attached</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GD9D-IFIcLa2f0zGFgprLA.png" /></figure><p><strong>serverless create — template aws-nodejs — path hello-world-medium</strong></p><p><strong>cd hello-world-medium</strong></p><p><strong>serverless deploy -v</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sjF6Qc6zqeLNuMoTRKCyoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_PUICvEcck_3-gVMf2Xigg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=448ba9f1016a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Athena Queries for Spark Partition data Stored on S3]]></title>
            <link>https://vineetkarandikar.medium.com/athena-queries-for-spark-partition-data-stored-on-s3-e2f8d48c7ca8?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2f8d48c7ca8</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[partition]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[athena]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 15:48:18 GMT</pubDate>
            <atom:updated>2021-01-15T15:50:32.448Z</atom:updated>
            <content:encoded><![CDATA[<p>We here are doing little data manipulation on sales data and saving the data using <strong>partition by</strong> Apache spark and saving the data on S3. Now this partition data is getting consumed by Athena for further Analytics.</p><p>Partitioning the data improves the efficiency of Athena query.Also make sure that <strong>partitionBy(“year”,”month”) </strong>should always be in lower cases else partition function for Athena won’t work<strong>.</strong></p><p>The data source is <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/supermarket_sales.csv"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/supermarket_sales.csv</strong></a></p><p>The python script to read data from S3 and perform data definition manipulation and saving the data again on S3 using partition.Below the link for the code <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/spark-athena.py"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/spark-athena.py</strong></a></p><p>Now we need to create external table by creating first database i.e. <strong>super_market </strong>and then <strong>sales_market</strong> table.</p><p>The source for table creation is <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/Athena_DDL.txt"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/Athena_DDL.txt</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1hRrnnNT-m3VyhAD-78Sw.png" /></figure><p>Now run the command MSCK REPAIR TABLE sales_market to re-pair the partition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dm-pzgw0i6-J7TQ7dslH5Q.png" /></figure><p>Now you are ready to fire our query on Athena with performance improved.</p><p><strong>SELECT * FROM “super_market”.”sales_market” where year=2019 and month=02</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14KZvvsLvIaHCkHQuwWu9w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2f8d48c7ca8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Athena triggers alert using SES via a lambda.]]></title>
            <link>https://vineetkarandikar.medium.com/aws-athena-triggers-alert-using-ses-via-a-lambda-5a0b8062031?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a0b8062031</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[athena]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[email-notifications]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Wed, 13 Jan 2021 07:30:25 GMT</pubDate>
            <atom:updated>2021-01-13T07:30:25.760Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is the basic use case where we have the data for supermarket.The data I have taken from kaggle as a reference to show the overall use case.The data you can find at <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/supermarket_sales.csv"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/supermarket_sales.csv</strong></a></p><p>The alert should get triggered when female rating decrease in current month as compared with previous month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_e6N54-0uM-YlLWTzVssg.png" /></figure><p>I have created two queries in AWS Athena which are as follows</p><ol><li><strong>“SELECT avg(rating) as count FROM super_market_sales where date between ‘1/1/2019’ and ‘1/31/2019’ and gender=’Female’”;(Assume it to be previous Month )</strong></li><li><strong>“SELECT avg(rating) as count FROM super_market_sales where date between ‘2/1/2019’ and ‘2/30/2019’ and gender=’Female’”;(Assume it to be Current Month ).</strong></li></ol><p>The query will be called from lambda for Athena and the data will be compared in lambda and based upon it email notification will be triggered.</p><p>Keep one thing in mind before using <strong>SES</strong> as for testing purpose please get the designated email verified at AWS end.</p><p>If the rating get declined i get the below alert at my email id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyvCvceczuvQDzomMQZjzA.png" /></figure><p>The code for lambda is available at <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/vineet-medium-athena-lambda-trigger-ses.js"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/vineet-medium-athena-lambda-trigger-ses.js</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a0b8062031" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Cognito Custom Lambda Authorizer in API Gateway for RBAC.]]></title>
            <link>https://vineetkarandikar.medium.com/aws-cognito-custom-lambda-authorizer-in-api-gateway-for-rbac-a4f5db40b340?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4f5db40b340</guid>
            <category><![CDATA[cognito]]></category>
            <category><![CDATA[rbac-access-control]]></category>
            <category><![CDATA[aws-lambdaaws]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Tue, 12 Jan 2021 08:37:23 GMT</pubDate>
            <atom:updated>2021-01-12T08:37:23.576Z</atom:updated>
            <content:encoded><![CDATA[<p>First create the user pool as i have explained in one my previous blogs.</p><p>Now create one table in dynamo db by name <strong>access_control </strong>with column names as email,roles and urls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtcdWDITIRHSizBanHAKjQ.png" /></figure><p>Now create the lambda function which will act as lambda authorizer. The code is located at <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/vineet-medium-lambda-authorizer.js"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/vineet-medium-lambda-authorizer.js</strong></a></p><p>The lambda authorizer contains third party library <strong>cognito-verify-token </strong>which will verify JWT token passed by client.I have modified it slightly to suit my need.The code for it is at <a href="https://github.com/vineetkarandikar/aws-samples/blob/main/verify-cognito-token/index.js"><strong>https://github.com/vineetkarandikar/aws-samples/blob/main/verify-cognito-token/index.js</strong></a></p><p>The code in lambda authorizer first check the validity of token and then fetches the <strong>URL </strong>list from dynamo db for a email id retrieved from <strong>JWT </strong>token and matches the requested URL with list of URLs allowed for that particular email.If true the request is allowed else rejected.</p><p>Here is our custom lambda authorizer using cognito service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*m6n5unSray2Yq50jxsfbFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2s7SN7SnUuBl7du5Aq7v0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMSyneoiub_GT41ClLBNTA.png" /></figure><p><strong>Currently AWS Cognito does not have RBAC because the scopes option in cognito user pool does not work when we add new scopes and when we request access token the default scope “scope”: “aws.cognito.signin.user.admin”,</strong> <strong>is assigned to every user which is glitch.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4f5db40b340" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Cognito Role-Based Access via API Gateway not Possible without IAM based.]]></title>
            <link>https://vineetkarandikar.medium.com/aws-cognito-role-based-access-via-api-gateway-not-possible-without-iam-based-e526271544b2?source=rss-72a7114648d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e526271544b2</guid>
            <category><![CDATA[cognito]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[rbac-access-control]]></category>
            <dc:creator><![CDATA[Vineet k]]></dc:creator>
            <pubDate>Mon, 11 Jan 2021 05:43:11 GMT</pubDate>
            <atom:updated>2021-01-21T07:06:32.288Z</atom:updated>
            <content:encoded><![CDATA[<p>I created the lambda function to generate access token and id token as mentioned in my previous blogs.The access token we decoded will show something like.</p><p>{<br> “sub”: “5ccc31a1–4934–455f-8d83–1ec4b49b1df2”,<br> “cognito:groups”: [<br> “user”<br> ],<br> “event_id”: “e4308419–92da-49e5–961a-b3df624e3c40”,<br> “token_use”: “access”,<br> <strong>“scope”: “aws.cognito.signin.user.admin”,</strong><br> “auth_time”: 1610342817,<br> “iss”: “<a href="https://cognito-idp.us-east-1.amazonaws.com/us-east-1_b4b1HPlo8">https://cognito-idp.us-east-1.amazonaws.com/us-west-1_b4b1HPlo8</a>&quot;,<br> “exp”: 1610346417,<br> “iat”: 1610342817,<br> “jti”: “83abd9c1–1a08–41af-bc37-d6d64a68d7e6”,<br> “client_id”: “2o6lf8lfpb70l6f99bg7anai6m”,<br> “username”: “8ccc31a1–4934–455f-8d83–1ec4b49b1df2”<br>}</p><p>The main troublemaker is the scope which by default assigns admin to every user which by design is useless and flaw from AWS.</p><p>Hence if one want’s RBAC then i would recommend to go by IAM based access using federated identities pool setting creating custom role and assign it user groups in Cognito user pool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e526271544b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>