Skip to content

tiny aws lambda calculator via IaC (TerraForm)

Notifications You must be signed in to change notification settings

GittyBitch/calcy

Repository files navigation

AWS Lambda Calculator PoC

This repository demonstrates a simple proof-of-concept (PoC) calculator application deployed on AWS using Terraform. The calculator performs basic arithmetic operations like addition, subtraction, multiplication, and division. It leverages AWS Lambda for computation and AWS API Gateway for handling HTTP requests. The HTML frontend and JavaScript code are hosted on a public S3 bucket, providing a simple user interface to interact with the calculator.

Screen shot showing the HTML frontend

Prerequisites

  • bash
  • sed
  • curl
  • jq
  • AWS Account with necessary access credentials.
  • AWS CLI v2.x.x
  • Terraform v1.x.x

Installation

  1. Install AWS CLI: Follow the official AWS CLI installation guide to install the AWS CLI on your machine.

  2. Configure AWS CLI: Run the following command to configure AWS CLI, and follow the prompts to input your AWS credentials (access key ID and secret access key) and default region:

  3. Install Terraform: Follow the official Terraform installation guide to install Terraform on your machine.

    aws configure

Usage

  1. Initialize Terraform:

    Navigate to the directory containing the Terraform configurations and run the following command:

    terraform init
  2. Deploy Infrastructure:

    Apply the Terraform configurations to provision the AWS infrastructure, including the public S3 bucket for hosting the HTML and JavaScript files:

    terraform apply

    After the command completes, it will output the URL of the S3 bucket hosting the frontend, and the URL of the API Gateway endpoint.

  3. Access the Calculator:

    Open the provided S3 bucket URL in your web browser to access the HTML frontend, where you can perform arithmetic operations using the calculator.

Testing AWS CLI Installation and Configuration

Ensure AWS CLI is correctly installed and configured with the following steps:

  1. Check AWS CLI Version:

    aws --version
  2. List AWS S3 Buckets:

    aws s3 ls

Misc

https://repost.aws/knowledge-center/s3-access-denied-bucket-policy

SAM: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-invoke.html

terraform plan terraform validate terraform apply

alles wieder löschen: terraform destroy

endpoint config: html/endpoint.js

cleanup:

  • hard-coded URL in output

About

tiny aws lambda calculator via IaC (TerraForm)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published