Package: django-ecsmanage
A Django app that provides a management command allowing you to run any
other management command on an AWS Elastic Container Service (ECS)
cluster.Withdjango-ecsmanage, you can easily run migrations and other
one-off tasks on a remote cluster from the command line:$ django-admin ecsmanage migrateTable of ContentsInstallationConfigurationEnvironmentsAWS ResourcesDevelopingInstallationInstall from PyPi using pip:$pipinstalldjango-ecsmanageUpdateINSTALLED_APPSin your Django settings to install the app:INSTALLED_APPS=(...'ecsmanage',)ConfigurationSettings for the management command are kept in a single configuration
dictionary in your Django settings namedECSMANAGE_ENVIRONMENTS.
Each entry inECSMANAGE_ENVIRONMENTSshould be a key-value pair
corresponding to a named environment (likedefaultorproduction) and a set of AWS resources associated with that
environment. For example:ECSMANAGE_ENVIRONMENTS={'default':{'TASK_DEFINITION_NAME':'StagingAppCLI','CONTAINER_NAME':'django','CLUSTER_NAME':'ecsStagingCluster','LAUNCH_TYPE':'FARGATE','PLATFORM_VERSION':'1.4.0','SECURITY_GROUP_TAGS':{'Name':'sgAppEcsService','Environment':'Staging','Project':'ProjectName'},'SUBNET_TAGS':{'Name':'PrivateSubnet','Environment':'Staging','Project':'ProjectName'},'ASSIGN_PUBLIC_IP':'DISABLED','AWS_REGION':'us-east-1',},}This configuration defines a single environment, nameddefault, with
associated AWS ECS resources.EnvironmentsThe key name for an environment can be any string. You can use this name
with the--envflag when running the command to run a command on a
different environment. Take thisECSMANAGE_ENVIRONMENTSconfiguration as an example:ECSMANAGE_ENVIRONMENTS={'default':{'TASK_DEFINITION_NAME':'StagingAppCLI','CLUSTER_NAME':'ecsStagingCluster','SECURITY_GROUP_TAGS':{'Name':'sgStagingAppEcsService',},'SUBNET_TAGS':{'Name':'StagingPrivateSubnet',},},'production':{'TASK_DEFINITION_NAME':'ProductionAppCLI','CLUSTER_NAME':'ecsProductionCluster','SECURITY_GROUP_TAGS':{'Name':'sgProductionAppEcsService',},'SUBNET_TAGS':{'Name':'ProductionPrivateSubnet',},},}This configuration defines two environments,defaultandproduction. Using the above settings, you could run production
migrations with the following command:$django-adminecsmanage--envproductionmigrateIf the--envargument is not present, the command will default to
the environment nameddefault.AWS ResourcesThe following environment configuration keys help the management command locate
the appropriate AWS resources for your cluster:KeyDescriptionDefaultTASK_DEFINITION_NAMEThe name of your ECS task definition. The command
will automatically retrieve the latest definition.CONTAINER_NAMEThe name of the Django container in your ECS task definition.djangoCLUSTER_NAMEThe name of your ECS cluster.SECURITY_GROUP_TAGSA dictionary of tags to use to identify a security
group for your task.SUBNET_TAGSA dictionary of tags to use to identify a subnet
for your task.ASSIGN_PUBLIC_IPWhether to automatically assign a public IP address to your
task. Can beENABLEDorDISABLED.DISABLEDLAUNCH_TYPEThe ECS launch type for your task.FARGATEPLATFORM_VERSIONThe Fargate platform version, ifLAUNCH_TYPEisFARGATE.LATESTAWS_REGIONThe AWS region to run your task.us-east-1DevelopingLocal development is managed with Python virtual environments. Make sure
that you have Python 3.8+ and pip installed before starting.Install the development package in a virtual environment:$./scripts/updateRun the tests:$./scripts/test