Cookiecutter is a tool that creates projects from project templates. This repository contains a project template to deploy an ECS cluster and ALB load balancers. A project instantiated from this template can be used as hosting layer for Docker containers and other cookiecutter templates, such as cookiecutter-aws-ecs-service
In order to run this cookiecutter template, you need to install following:
- python 3 (
check: python3 --version
) - Cookiecutter:
pip3 install cookiecutter
- aws cli (
check: aws --version
) - make tools (
make --version
)
On Windows, with chocolatey and sudo installed
sudo choco install python
sudo choco install awscli
pip install cookiecutter
- AWS CLI: you should be logged in into the AWS CLI.
- S3 bucket for the artefacts: this bucket needs to be versioned.
- S3 bucket for the Logs
- A GitHub or Bitbucket repository
Create a cookiecutter config file containing the configuration for your service. Cookiecutter will use the values from the config file as defaults when bootstrapping this template.
Find a cookiecutter config file example below:
default_context:
# AWS settings
aws_account_id: 123456789012
aws_default_region: some-aws-region
# Project settings
project_name: ECS Cluster
project_short_description: A Cookiecutter generated ECS cluster example
cloudformation_stack_prefix: shared-infra-x
# Source
vcs_tool: github
bitbucket_connection: ""
github_owner: github-owner
git_repo: ecs-blue-cluster
git_branch: master
container_insights: enabled
artifact_s3_bucket: some-bucket-name
log_bucket: some-bucket-name
nonprod_vpc_id: vpc-xyz
nonprod_private_subnets: subnet-x,subnet-y,subnet-z
nonprod_public_subnets: subnet-a,subnet-b,subnet-c
prod_vpc_id: ""
prod_private_subnets: ""
prod_public_subnets: ""
deploy_public_alb: Y
deploy_private_alb: Y
ssl_certificate_arn: arn:aws:acm:...
sns_alert_topic: arn:aws:sns:...
- aws_account_id: The AWS account to deploy the ECS cluster in.
- aws_default_region: The AWS region to deploy the ECS cluster in.
- project_name: The name for the project. Cookiecutter will make a slug out of it by making it all lowercase and by replacing whitespaces with dashes. Furthermore this slug will be used for naming resources and as you repository name.
- project_short_description: The project's description.
- cloudformation_stack_prefix: The prefix used to properly name the CloudFormation resources.
- vcs_tool: The Version Control System to use. Should be 'github' or 'bitbucket'.
- bitbucket_connection: Codestar connection ARN to connect Bitbucket. Required if vcs_tool is bitbucket otherwise provide an empty string.
- github_owner: GitHub owner. Required if vcs_tool is github otherwise provide an empty string.
- git_repo: Git repository name.
- git_branch: Git branch.
- container_insights: enable/disable ECS container insights.
- artifact_s3_bucket: The S3 bucket to store the artefacts.
- log_bucket: The S3 bucket to store the logs.
- nonprod_vpc_id: The VPC ID for non-production.
- nonprod_private_subnets: The private subnets of the non-production VPC.
- nonprod_public_subnets: The public subnets of the non-production VPC.
- prod_vpc_id: The VPC ID for production.
- prod_private_subnets: The private subnets of the production VPC.
- prod_public_subnets: The public subnets of the production VPC.
- deploy_public_alb: 'Y' to deploy the public Application Load Balancer
- deploy_private_alb: 'Y' to deploy the private Application Load Balancer
- ssl_certificate_arn: The SSL certifacte for the Application Load Balancer Lister
- sns_alert_topic: The SNS Topic for alerting
-
Run cookiecutter in the directory where you usually checkout your git repositories. Cookiecutter will create a new sub-folder in this directory.
$ cookiecutter --config-file .cookiecutter_example --no-input -f https://github.com/element7-io/cookiecutter-aws-ecs-cluster.git
-
Move to the newly created project
$ cd yet-another-test-project
-
Enable git for this project:
git init git add . git commit -m "Initial setup"
-
Create a new GitHub repository corresponding the values specified in the cookiecutter config file (github_owner, github_repo, github_branch).
-
Push your code to GitHub.
-
To finish the setup read the
README.md
file in the newly created project.
This cookiecutter template is Community Driven, so everybody is free to contribute. Read the Contributors' Guide for details on how-to contribute.
Note: depending on the options you choose when executing the template certain components will not be deployed. The diagram below reflects the situation when ALL components are deployed.
This image can be edited with draw.io. Find the source under /img/Cookiecutter_ecs.html.