Coder Social home page Coder Social logo

mongodb / cookiecutter-aws-sam-python-mongodb-atlas Goto Github PK

View Code? Open in Web Editor NEW
5.0 8.0 4.0 51 KB

A Cookiecutter template to create a Serverless App based on Serverless Application Model (SAM) and Python 3.6 for MongoDB Atlas

License: MIT No Attribution

Python 31.74% Makefile 15.50% HTML 48.45% Shell 4.31%
mongodb atlas databases aws cloudformation mongo cfn serverless sam-cli

cookiecutter-aws-sam-python-mongodb-atlas's Introduction

Cookiecutter SAM for MongoDB Atlas with Python Lambda functions

⚠️ THIS is ALPHA SOFTWARE in active DEVELOPMENT use at own risk and not in production, yet. ⚠️

This is a Cookiecutter template to create a Serverless App based on Serverless Application Model (SAM) and Python 3.8 which uses MongoDB Atlas.

It is important to note that you should not try to git clone this project but use SAM CLI instead as {{cookiecutter.project_slug}} will be rendered based on your input and therefore all variables and files will be rendered properly.

tldr

curl https://raw.githubusercontent.com/mongodb-developer/get-started-aws-cfn/main/get-setup.sh | bash -s us-east-2
sam init --location gh:mongodb/cookiecutter-mongodb-atlas-aws-sam-python
# cd to your project
sam build --use-container
sam deploy --extra-parameters $(./export-mongocli-parameters.sh)
# sam deploy --guided     # Have you apikey ready

Pre-requisite

The project will deploy the MongoDB Atlas AWS Quick Start which provisions complete MongoDB Atlas deployments through CloudFormation using official MongoDB Atlas AWS CloudFormation Resource Types.

Until these resources a more easily available you can use the get-started-aws-cfn project to bootstrap each AWS region with the Atlas CFN Resource Types:

curl https://raw.githubusercontent.com/mongodb-developer/get-started-aws-cfn/main/get-setup.sh | bash -s us-west-2

The above command will deploy and seutp the MongoDB Atlas CFN resources into the us-west-2 region. For advanced use, including sample AWS IAM policy suitable for aws sts assume-role, see: the aws-iam-permissions note in the Get-Started project.

Usage

Generate a new SAM based Serverless App: sam init --location gh:mongodb/cookiecutter-mongodb-atlas-aws-sam-python

You'll be prompted a few questions to help this cookiecutter template to scaffold this project and after its completed you should see a new folder at your current path with the name of the project you gave as input.

  • Create an organizational-level MongoDB Atlas Programmatic API. The key needs Project Creator permissions.

  • The aws and sam cli's setup and configured on your development machine.

  • We also recommend mongocli for the easiest way to manage all your MongoDB Atlas needs, cluster and apikeys included!

You can then deploy your SAM app directly using your mongocli configuration - this will create the sam app, stack-name, and Atlas Project all with <APP_NAME>:

OVERRIDES=$(curl https://raw.githubusercontent.com/monogdb-developer/get-started-aws-cfn/main/export-mongocli-config.py | bash -s --  default parameter-override <APP_NAME>)
sam deploy --guided --parameter-overrides ${OVERRIDES} --stack-name <APP_NAME>

Options

Option Description
include_safe_deployment Sends by default 10% of traffic for every 1 minute to a newly deployed function using CodeDeploy + SAM integration - Linear10PercentEvery1Minute

Deployment Parameters

To deploy your serverless app you will need to supply the following:

Parameter Required Description Default
PublicKey Y Your MongoDB Cloud Public API Key
PrivateKey Y Your MongoDB Cloud Private API Key
OrgId Y Your MongoDB Cloud Organization Id
ProjectName N The name of the project." get-started-aws-lambda-python
ClusterName N Name of the cluster as it appears in Atlas. Once the cluster is created, its name cannot be changed. Cluster-1
ClusterInstanceSize N Atlas Cluster Tier M10
ClusterRegion N The AWS Region where the Atlas DB Cluster will run. (AWS Region format) us-east-1
ClusterMongoDBMajorVersion N The version of MongoDB latest

Credits

License

This project is licensed under the terms of the MIT License with no attribution

cookiecutter-aws-sam-python-mongodb-atlas's People

Contributors

jasonmimick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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