GithubHelp home page GithubHelp logo

mukulmantosh / pulumi_django Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 1.27 MB

Managing AWS Resources from Django Admin using Pulumi

Python 100.00%
aws django iaac infrastructure-as-code pulumi pulumi-aws python3

pulumi_django's Introduction

IaaC using Django & Pulumi


stack_logo

Prerequisites

Before starting up this project, make sure you have an AWS account.

Software Installation

Python Dependencies

  • Installing Python Packages
$ pip install -r requirements.txt
  • Note: For our project we are using db.sqlite3. I strongly recommend to use Postgres/MySQL when setting up in production.

Pulumi Stack

Login to Pulumi and create a new project.

Make sure to name the stack as aws-python.

step1

Update the respective YAML files & django settings in the codebase.

Pulumi.yaml

step2

settings.py

step3

Pulumi CLI

Run the below command :

  • pulumi login

step4

Migrating Tables

Run the below command :

  • python manage.py migrate

step5

Creating SuperUser

Run the below command :

  • python manage.py createsuperuser

step6

AWS Credentials

Make sure to update your AWS credentials, residing in $HOME/.aws/credentials

  • Note: For this demo, make sure the IAM User should have AdministratorAccess. This is not recommended permission you need to give. Kindly, follow the security best practices.
[default]
aws_access_key_id = xxxxxxxxxxxxxxxxxxxxx
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxx

Loading AWS Resources

Run the below command :

  • python manage.py load_resources

This command is going to dump all the AWS resources into your database.

  • VPC
  • Subnets
  • Security Groups
  • Key Pair
  • Instance Types

step7

Logging into Django Admin

Provide the superuser credentials, which you have created recently.

step8

step9

You can now observe that all the AWS information has been dumped in our database, and it's reflected in the admin.

Instance Types

step10

Operating Systems

step11

Creating an EC2 Instance

We will provide all the necessary information for creating EC2 Instance.

  • Note: Pulumi will be invoked in the foreground, I recommend using background tasks like Celery & RabbitMQ

step12

You can see below, that the instance has been created and the Public IPv4 address has been updated.

step13

step14

Deleting an EC2 Instance

Now, we will go ahead and delete the instance information from Django Admin

step15

You can observe the django console, that Pulumi has started the process to terminate the instance.

step16

step17

References

If you are interested to know more about Pulumi.

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.