GithubHelp home page GithubHelp logo

mahadzar81 / terraform-aws-serverless Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 11.29 MB

Deploy demo app on AWS serverless by utilizing Cognito, API gateway, python lambda function, and RDS resources

License: MIT License

Python 25.38% HCL 74.62%

terraform-aws-serverless's Introduction

terraform-aws-serverless

Deploy demo app on AWS serverless by utilizing API gateway, python lambda function, and RDS resources

Requirements

Steps

# terraform workspace new terraform-aws-serverless
# terraform workspace select terraform-aws-serverless
# terraform plan -var-file env/$(terraform workspace show).tfvars
# terraform apply -auto-approve -var-file env/$(terraform workspace show).tfvars

Example Environment tfvars

region = "ap-southeast-1"
object_ownership = "BucketOwnerPreferred"
control_object_ownership = true
ami = "ami-066eeae61f083f121"
instance_type = "t2.micro"
db_name = "college"
db_username = "demoapp"
db_password = "<password>"
cognito_user = "<user>"
cognito_password = "<password>"
count_instance = 1
user = "admin"
key_pair_id = "~/.ssh/id_rsa.pub"

To verify

Register cognito-idp admin credential permanently using AWS CLI

 aws cognito-idp admin-set-user-password --user-pool-id <region endpoint> --username <username> --password <credential> --permanent

To test calling API gateway, first we need to get Bearer access_token from AWS Cognito IDP by using curl command

 curl --request POST --url https://cognito-idp.<regions>.amazonaws.com/<region end point> --header 'content-type: application/x-amz-json-1.1' --header 'x-amz-target: AWSCognitoIdentityProviderService.InitiateAuth' --data '{ "AuthParameters" : {"USERNAME" : "<username>", "PASSWORD" : "password"},"AuthFlow" : "USER_PASSWORD_AUTH","ClientId" : "<client ID>"}'

Call AWS Gateway using curl command

curl -X GET https://<rest-api-id>.execute-api.<region>.amazonaws.com/<stage>/ \
-H 'authorization: Bearer <access_token>' \
-H 'content-type: application/json'

Modules

Name Description
API Gateway AWS API Gateway v2 (HTTP/Websocket) Terraform module
AWS Lambda AWS Lambda Terraform module
AWS RDS AWS RDS Terraform module
AWS VPC AWS VPC Terraform module
AWS S3 AWS S3 bucket Terraform module

License

MIT / BSD

Author Information

terraform-aws-serverless's People

Contributors

mahadzar81 avatar

Stargazers

 avatar

Watchers

 avatar  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.