Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d4vidsha/terraform-aws-lambda-hello-world
A basic "Hello world" implementation of a serverless app using AWS and Terraform.
https://github.com/d4vidsha/terraform-aws-lambda-hello-world
aws-apigateway aws-lambda aws-s3 terraform
Last synced: 25 days ago
JSON representation
A basic "Hello world" implementation of a serverless app using AWS and Terraform.
- Host: GitHub
- URL: https://github.com/d4vidsha/terraform-aws-lambda-hello-world
- Owner: d4vidsha
- Created: 2024-09-16T05:08:27.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-16T23:07:50.000Z (about 2 months ago)
- Last Synced: 2024-10-01T16:17:34.168Z (about 1 month ago)
- Topics: aws-apigateway, aws-lambda, aws-s3, terraform
- Language: HCL
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# terraform-aws-lambda-hello-world
This project was largely adapted from the [official HashiCorp Terraform tutorials](https://developer.hashicorp.com/terraform/tutorials/aws) on [deploying serverless applications with AWS Lambda and API Gateway](https://developer.hashicorp.com/terraform/tutorials/aws/lambda-api-gateway).
## Prerequisites
> [!NOTE]
> These prerequisites where taken from the [Terraform AWS Tutorial](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-build#prerequisites).You will need:
- The [Terraform CLI](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) (1.2.0+) installed.
- The [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed.
- [AWS account](https://aws.amazon.com/free) and [associated credentials](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html) that allow you to create resources.To use your IAM credentials to authenticate the Terraform AWS provider, set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables.
```bash
export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
```## Deploying the serverless app
Assuming you have authenticated with the AWS CLI, you can run the following commands from the root of this repository to deploy the infrastructure.
1. Initialise Terraform.
```bash
terraform init
```2. Apply the Terraform configuration and confirm by typing `yes` when prompted.
```bash
terraform apply
```3. You can now invoke the Lambda via the API Gateway endpoint `/hello`.
```bash
curl "$(terraform output -raw base_url)/hello"
```Alternatively, you can directly invoke the Lambda function using the AWS CLI bypassing API Gateway. Response is stored in `response.json`.
```bash
aws lambda invoke --region=ap-southeast-2 --function-name=$(terraform output -raw function_name) response.json
```4. To clean up and delete resources, run the following command.
```bash
terraform destroy
```## Resources
> [!NOTE]
> The following are a list of important links I visited in the making of this project.-
-
-
-
-