<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prashansa Joshi</title>
    <description>The latest articles on DEV Community by Prashansa Joshi (@prashansa_joshi_40b0a5811).</description>
    <link>https://dev.to/prashansa_joshi_40b0a5811</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2056485%2F42dae1f0-51a4-42d1-9afd-859a0a04b20c.png</url>
      <title>DEV Community: Prashansa Joshi</title>
      <link>https://dev.to/prashansa_joshi_40b0a5811</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prashansa_joshi_40b0a5811"/>
    <language>en</language>
    <item>
      <title>Getting Started with Infracost: Estimating Cloud Costs</title>
      <dc:creator>Prashansa Joshi</dc:creator>
      <pubDate>Mon, 23 Jun 2025 10:44:51 +0000</pubDate>
      <link>https://dev.to/aws-builders/getting-started-with-infracost-estimating-cloud-costs-an4</link>
      <guid>https://dev.to/aws-builders/getting-started-with-infracost-estimating-cloud-costs-an4</guid>
      <description>&lt;h2&gt;
  
  
  Getting Started with Infracost: Estimating Cloud Costs in Terraform Projects
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cloud cost surprises are no fun, especially when they show up after deployment.&lt;/strong&gt; If using Terraform to manage AWS infrastructure, there's a powerful open-source tool that helps bring &lt;strong&gt;cost visibility into the development workflow&lt;/strong&gt;: meet &lt;strong&gt;Infracost&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Infracost?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Infracost&lt;/strong&gt; estimates cloud costs directly from the &lt;strong&gt;Terraform code&lt;/strong&gt;, even &lt;strong&gt;before you apply it&lt;/strong&gt;. It supports major cloud providers and services, and integrates easily with GitHub, GitLab, Bitbucket, and CI tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In short: see the financial impact of changes before they hit the cloud bill.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Terraform&lt;/li&gt;
&lt;li&gt;Infracost CLI&lt;/li&gt;
&lt;li&gt;Terraform AWS project (EC2, S3, RDS, etc.)&lt;/li&gt;
&lt;li&gt;AWS credentials configured&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Install Infracost
&lt;/h2&gt;

&lt;p&gt;Run the following command based on OS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;infracost --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0e5o0brqf84henpb4xi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0e5o0brqf84henpb4xi.png" alt="Infracost version" width="664" height="100"&gt;&lt;/a&gt;&lt;br&gt;
fig: Infracost version&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Generate API Key for Infracost
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Infracost&lt;/strong&gt; requires an API key to fetch accurate, real-time cloud pricing data and to post cost estimates in pull requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Generate an API Key&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit &lt;a href="https://dashboard.infracost.io/" rel="noopener noreferrer"&gt;https://dashboard.infracost.io/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Sign up or log in&lt;/li&gt;
&lt;li&gt;Generate an &lt;strong&gt;INFRACOST_API_KEY&lt;/strong&gt; from the dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Use the API Key in GitHub Actions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Settings → Secrets and variables → Actions&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click New repository secret&lt;/li&gt;
&lt;li&gt;Name the secret &lt;strong&gt;INFRACOST_API_KEY&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Paste the API key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reference in GitHub workflow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;env:
  INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Authenticate Locally for Development&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option A: Interactive Login&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;infracost auth login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhui7l46yc812tvtbpb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhui7l46yc812tvtbpb1.png" alt=" " width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flftijj82y6xlv7lmo4fo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flftijj82y6xlv7lmo4fo.png" alt=" " width="794" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option B: Set API Key Manually&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;infracost configure set api_key &amp;lt;YOUR_API_KEY&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;YOUR_API_KEY&amp;gt;&lt;/code&gt; with the value copied from the Infracost dashboard.&lt;/p&gt;

&lt;p&gt;Once set, the key is stored locally and used for all Infracost CLI commands, including breakdown and diff.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Initialize Terraform Project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/my-terraform-project
terraform init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Generate a Cost Estimate
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;infracost breakdown --path . --format table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates a table with estimated monthly costs for each resource:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqabu1hekxlykksb97qq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqabu1hekxlykksb97qq.png" alt=" " width="800" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Can also use &lt;code&gt;--format json&lt;/code&gt; for CI/CD integrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Compare Cost Changes (Pull Request Workflow)
&lt;/h2&gt;

&lt;p&gt;One of Infracost's most powerful features is the ability to &lt;strong&gt;compare infrastructure cost before and after code changes&lt;/strong&gt; — a workflow that's especially useful in &lt;strong&gt;pull requests (PRs)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reads Terraform code before changes&lt;/li&gt;
&lt;li&gt;Calculates baseline cost&lt;/li&gt;
&lt;li&gt;Saves to &lt;code&gt;infracost-base.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Compares with updated code&lt;/li&gt;
&lt;li&gt;Generates a diff report&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4d27wgnnedl0cin4hc11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4d27wgnnedl0cin4hc11.png" alt=" " width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F47ntgppvsp869z9pw2e9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F47ntgppvsp869z9pw2e9.png" alt=" " width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before the Change – Create a Baseline&lt;/strong&gt;&lt;br&gt;
This command should be run &lt;strong&gt;before making any infrastructure edits&lt;/strong&gt;, typically from the main or dev branch:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;infracost breakdown --path . --format json --out-file infracost-base.json&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What it does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scans the current Terraform state&lt;/li&gt;
&lt;li&gt;Calculates the monthly cost estimate&lt;/li&gt;
&lt;li&gt;Saves the cost structure to infracost-base.json (baseline)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This baseline will be compared against the new code later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoazi1nofgjwsmh3dhz5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoazi1nofgjwsmh3dhz5.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make Infrastructure Changes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Modify the Terraform code, for example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add EC2 instance&lt;/li&gt;
&lt;li&gt;Resize RDS instance&lt;/li&gt;
&lt;li&gt;Modify EBS volume&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;After the Change,run the Diff&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;infracost diff --path . --compare-to infracost-base.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What it does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reads the new version of the code&lt;/li&gt;
&lt;li&gt;Compares it against infracost-base.json&lt;/li&gt;
&lt;li&gt;Outputs a human-readable diff showing:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;What changed&lt;/li&gt;
&lt;li&gt;New monthly cost estimate&lt;/li&gt;
&lt;li&gt;Increase or decrease in cost&lt;/li&gt;
&lt;li&gt;Which specific resources were affected&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg42ik8ol2bmejxozboe9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg42ik8ol2bmejxozboe9.png" alt=" " width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Matters in a PR Workflow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a team environment using GitHub/GitLab:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This infracost diff step can run in the CI/CD pipeline&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;adds a comment to the pull request&lt;/strong&gt;, like:
&lt;strong&gt;Cost estimate change:&lt;/strong&gt; +$40/month&lt;/li&gt;
&lt;li&gt;aws_instance.app added&lt;/li&gt;
&lt;li&gt;aws_db_instance upgraded from db.t3.medium to db.t3.large&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives reviewers visibility into not just what changed, but how much it will cost.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 6: Integrate with GitHub Pull Requests
&lt;/h2&gt;

&lt;p&gt;Infracost can post cost diff comments automatically to GitHub PRs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up GitHub Actions or another CI system&lt;/li&gt;
&lt;li&gt;Use the &lt;a href="https://github.com/infracost/actions" rel="noopener noreferrer"&gt;https://github.com/infracost/actions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example workflow snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Infracost Cost Estimation

on:
  pull_request:
    branches:
      - dev
      - stage
      - main
    paths:
      - '*.tfvars'
  push:
    branches:
      - dev
      - stage
      - main
    paths:
      - '*.tfvars'
permissions:
  contents: read
  pull-requests: write

env:
  INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}

jobs:
  infracost:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup Infracost
        uses: infracost/actions/setup@v3
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}

      - name: Generate Infracost Baseline
        run: |
          git fetch origin ${{ github.base_ref }}
          git checkout origin/${{ github.base_ref }} -- .
          infracost breakdown \
            --path=. \
            --terraform-var-file=${{ &amp;lt;file_path&amp;gt; }} \
            --format=json \
            --out-file=infracost-baseline.json

      - name: Generate Infracost Diff
        run: |
          git checkout ${{ github.head_ref }}
          infracost diff \
            --path=. \
            --terraform-var-file=${{ &amp;lt;file_path&amp;gt; }} \
            --compare-to=infracost-baseline.json \
            --format=json \
            --out-file=infracost-diff.json

      - name: Upload Infracost diff to Cloud Dashboard
        run: |
          infracost upload --path=infracost-diff.json

      - name: Post Infracost Comment to PR
        if: github.event_name == 'pull_request'
        run: |
          infracost comment github \
            --path=infracost-diff.json \
            --repo=${{ github.repository }} \
            --pull-request=${{ github.event.pull_request.number }} \
            --github-token=${{ secrets.GITHUB_TOKEN }} \
            --behavior=update

      - name: Show Human-Readable Cost Breakdown in Logs
        run: |
          infracost breakdown \
            --path=. \
            --terraform-var-file=${{ &amp;lt;file_path&amp;gt; }} \
            --format=table

      - name: Upload Infracost Table Breakdown
        run: |
          infracost breakdown \
            --path=. \
            --terraform-var-file=${{ &amp;lt;file_path&amp;gt; }} \
            --format=table \
            --out-file=infracost-breakdown.txt
        continue-on-error: true

      - name: Upload breakdown as artifact
        uses: actions/upload-artifact@v4
        with:
          name: infracost-breakdown
          path: infracost-breakdown.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswk5ajjdryoj3post29d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswk5ajjdryoj3post29d.png" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Infracost?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No more budget surprises&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Empower developers with cost insights&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enable cost-aware reviews&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Catch expensive changes before deploy&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Infracost is a simple, open-source tool that helps teams understand cloud cost impacts before provisioning infrastructure.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.infracost.io/docs/" rel="noopener noreferrer"&gt;Infracost Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/infracost/infracost" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Use SNS as both trigger and destination of AWS lambda</title>
      <dc:creator>Prashansa Joshi</dc:creator>
      <pubDate>Fri, 30 May 2025 08:39:27 +0000</pubDate>
      <link>https://dev.to/aws-builders/use-sns-as-both-trigger-and-destination-of-aws-lambda-25l4</link>
      <guid>https://dev.to/aws-builders/use-sns-as-both-trigger-and-destination-of-aws-lambda-25l4</guid>
      <description>&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AWS console access&lt;/li&gt;
&lt;li&gt;S3 bucket&lt;/li&gt;
&lt;li&gt;Two Amazon SNS&lt;/li&gt;
&lt;li&gt;Lambda configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzj5pciobk0le7pli6fk6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzj5pciobk0le7pli6fk6.png" alt=" " width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  SNS
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create first SNS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1qf9wyrfyryns8ir64x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1qf9wyrfyryns8ir64x.png" alt=" " width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add SNS policy
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Id": "sns-ID",
  "Statement": [
    {
      "Sid": "Example SNS topic policy",
      "Effect": "Allow",
      "Principal": {
        "Service": "s3.amazonaws.com"
      },
      "Action": "SNS:Publish",
      "Resource": "SNS-topic-ARN",  #arn of thie created sns
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "426857564226"
        },
        "ArnLike": {
          "aws:SourceArn": "arn:aws:s3:::prashansa-sns-bucket"
        }
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Step 2: *&lt;/em&gt; Go to subscription and click on create subscription&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create subscription setting protocol as AWS Lambda that means the destination of this SNS is AWS Lambda. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ti39i5xzllr4ivmnfi4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ti39i5xzllr4ivmnfi4.png" alt=" " width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Create another SNS&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Another SNS for notifying user via email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftau6schxzxasts7ipidj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftau6schxzxasts7ipidj.png" alt=" " width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set policy for this SNS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;Step 4: *&lt;/em&gt; Create subscription&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the protocol to email for this SNS to send direct notification to the user via email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiik0d15pkuxyfc89jj2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiik0d15pkuxyfc89jj2.png" alt=" " width="800" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  S3 Bucket
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Step 5: *&lt;/em&gt; Create S3 bucket&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm4xfc6i4vj30z1u8b84.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm4xfc6i4vj30z1u8b84.png" alt=" " width="800" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Go to properties &amp;gt; event notification &amp;gt; create event notification&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd6uo6ecxd5w16dt2vg2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd6uo6ecxd5w16dt2vg2.png" alt=" " width="641" height="757"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt; Go to Destination&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scrolling down there is destination&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwuzmr2hpesc3ne79p1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwuzmr2hpesc3ne79p1w.png" alt=" " width="642" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lambda
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt; Create lambda function&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3x2go0k7u7r1nm3xufb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3x2go0k7u7r1nm3xufb.png" alt=" " width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9:&lt;/strong&gt; Add trigger&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the first SNS whose protocol was set to lambda as trigger&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsztpiitgdiwefpsqkk8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsztpiitgdiwefpsqkk8w.png" alt=" " width="800" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10:&lt;/strong&gt; Set Lambda destination&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the lambda destination, set the SNS secondly created that was set the protocol for email as the lambda destination&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjlqt243qrxxmlx3iabp9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjlqt243qrxxmlx3iabp9.png" alt=" " width="644" height="716"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 11:&lt;/strong&gt; Upload the image in S3 bucket&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkjwst5w46gfne157sn9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkjwst5w46gfne157sn9.png" alt=" " width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 12:&lt;/strong&gt; Check the email for notification&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpaihnjpane0i561cz9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpaihnjpane0i561cz9b.png" alt=" " width="800" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://repost.aws/knowledge-center/lambda-invoke-error-s3-bucket-permission" rel="noopener noreferrer"&gt;https://repost.aws/knowledge-center/lambda-invoke-error-s3-bucket-permission&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
