This repository consists of a set of nested templates that deploy the following:
- ECS cluster and services. Runing PHP Laravel application with Nginx.
- Codepipeline that will automate the steps required to release the application changes continuously. Which is in another GitHub repository..
- Another Codepipeline that will automate the steps required to release the CloudFormation templates changes continuously.
- CloudFormation, How it works
- AWS account predefined with the following resources:
- VPC
- Subnets
- Security Groups
- EC2 key pair. This is necessary to for EC2 Launch Type.
- A GitHub repository for the application code with the required artifacts.
- Fork this repo so that you have a copy of the templates.
The templates below are included in this repository and reference architecture:
Template | Description |
---|---|
cf-master.yaml | This is the master template - which includes all of the other child templates. |
cf-ecs.yaml | This template deploys a web application in an Amazon ECS container with autoscaling and an application load balancer. For more information, see Getting Started with Amazon ECS in the Amazon Elastic Container Service Developer Guide. |
cf-app-pipeline.yaml | This template creates a pipeline that will detect code changes through push event in GitHub branches and pull them into the pipeline. New docker images will be built in CodeBuild and trigger ECS zero-downtime redeployment. |
cf-cloudformation-pipeline.yaml | This template will creates a pipeline that performs the following workflow to update Cloudformation stacks:
|
config/* | This folder contains JSON-formatted text Template Configuration File that can specify template parameter values, a stack policy, and tags. Which is only used in CodePipeline that performs Cloudformation changes. Learn more. |
cf-master-ecs-ec2.yaml and cf-ecs-ec2.yaml | Templates for launch the ECS services in EC2 launch type. |
Package and upload the local artifacts with Cloudformation package command.
aws cloudformation package --template-file $CF_MASTER_TEMPLATE_FILE_NAME \
--s3-bucket $CODEPIPELINE_S3_BUCKET_NAME \
--s3-prefix cf-stacks-template \
--output-template-file transformed-$CF_MASTER_TEMPLATE_FILE_NAME
Use the AWS CloudFormation Console to run the master template. Click the "Create Stack" button in the upper left corner of the console, then under "Choose a template", select "Upload a template to Amazon S3" and click "Browse" to find your local template file.
- Securing GitHub Tokens with Secrets Manager
- Enable HTTPS support
- Uploading nested template to an S3 Bucket
- Cost-Efficient ECS services with Scheduled Lambda
- Required artifacts in application repository
- Sending SNS Alerts for Task Stopped Events
- Lambda Functions
- The StartupKit-templates repo
- Cloudformation User Guide
- Cloudformation Template Snippets
- Cloudformation Continuous Delivery
Any improvements or suggestions are welcomed. Just do a commit or pull request.