Giter Site home page Giter Site logo

briancaffey / terraform-aws-django Goto Github PK

View Code? Open in Web Editor NEW
27.0 5.0 5.0 165 KB

Terraform modules for deploying Django applications on AWS using ECS Fargate

Home Page: https://registry.terraform.io/modules/briancaffey/django/aws/latest

HCL 98.63% Makefile 1.37%
terraform aws django ecs-fargate

terraform-aws-django's Introduction

Terraform AWS Django

About

This repo is a collection of Terraform modules for deploying Django applications on AWS using EC2, ECS (EC2 + Fargate), and EKS.

Currently this repo contains one high-level module for deploying a Django application on AWS using ECS (Fargate launch type).

See the examples/ directory for examples of how to use this module.

Here is a companion repo that shows how to use this module with a Django application: https://github.com/briancaffey/django-step-by-step.

Also see https://github.com/briancaffey/terraform-aws-ad-hoc-environments for a repo that shows how to use this module with an ad-hoc environment.

terraform-aws-django's People

Contributors

briancaffey avatar codyfletcher avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

terraform-aws-django's Issues

Keep RDS from automatically upgrading minor version

When an RDS instance is created, it will automatically upgrade the minor version which causes state file issues. This happens because AWS automatically upgrades the RDS engine version to the latest version for security and performance reasons.

For example, this repo currently has engine_version set to “13.4”, and a new deployment will work as expected (at 13.4). However, AWS will eventually upgrade this to “13.7” (I think during a maintenance window, likely hours after you were last looking at the base deployment).

This can cause upleasant surprises when you go to update your base stack and it thinks you want to downgrade (which ultimately fails):

  # module.main.module.rds.aws_db_instance.this will be updated in-place
  ~ resource "aws_db_instance" "this" {
  	~ engine_version                    	= "13.7" -> "13.4"
    	id                                	= "ocpython-rds"
    	name                              	= "postgres"
    	tags                              	= {}
    	# (49 unchanged attributes hidden)
	}

To prevent this issue, we should be able to set the auto_minor_version_upgrade parameter to false when creating the RDS instance, which will prevent automatic minor version upgrades.

Avoiding issues with lists in Terraform

Problem

In Terraform, when I have a list of 2 items (e.g. A, B) it doesn’t always preserve the order and sometimes thinks there is a change (e.g. B, A).

I’m trying to remember where exactly I saw it in this project, but I’ve been occasionally running into this for years and finally dug around for a potential solution.

Potential Solution

In Terraform, when using lists, the order of the elements is not guaranteed to be preserved. To make Terraform aware of the order of the elements in the list and avoid changes, we can use the tuple data type instead of a list. A tuple is an ordered collection of elements that can be of different types, and Terraform will treat each element of the tuple as a separate resource. This way, Terraform will be aware of the order of the elements and will not consider changes when the order is changed.

Alternatively, we might be able use the jsonencode function in some cases to convert the list to a json string and use that as input. This will preserve the order of the elements in the list and Terraform will not consider changes when the order is changed.

locals {
  ordered_list = jsonencode([ "A", "B"])
}

and use the ordered_list variable in your resource configuration.

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.