Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rix0rrr/cdk-ecs-demo
Sample code for an ECS application definition using CDK
https://github.com/rix0rrr/cdk-ecs-demo
Last synced: 7 days ago
JSON representation
Sample code for an ECS application definition using CDK
- Host: GitHub
- URL: https://github.com/rix0rrr/cdk-ecs-demo
- Owner: rix0rrr
- License: mit
- Created: 2019-05-13T12:05:43.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T02:32:34.000Z (almost 2 years ago)
- Last Synced: 2024-08-02T00:26:21.871Z (3 months ago)
- Language: TypeScript
- Size: 251 KB
- Stars: 40
- Watchers: 3
- Forks: 12
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cdk - ECS with CI/CD - Demo of deploying ECS application using CDK. (Training Materials and Sample Code / Multi-accounts setup)
- awesome-cdk - ECS with CI/CD - Demo of deploying ECS application using CDK. (Training Materials and Sample Code / Multi-accounts setup)
README
# Demo of deploying ECS application using CDK
This repository shows how an asset-based ECS application written in CDK can be
deployed, both directly from your developer desktop for testing as well as
automatically using a pipeline in production.Demo written against CDK **0.31.0**.
## Explanation
The application contains 4 stacks:
- **ClusterStack**: a stack with a VPC and an ECS cluster, needs to be manually deployed (that is not a best practice, but it is the current state of this example).
- **HttpServiceStack**: a *development* instance of the stack defining the ECS service. This stack uses an AssetImage, meaning it will build and push the ECS image in the repository when deployed.
- **ProdHttpServiceStack**: a *production* instance of the stack defining the ECS service. This stack takes the Docker image as a pipeline input, to be supplied at deployment time.
- **CodePipelineStack**: a stack defining an ECR repository and a CodePipeline which will build both the CDK app and the Docker image, then finally deploy the combination through CloudFormation.### Pipeline
The pipeline looks like this:
```
┌──────────────┐
│ SOURCE │
│ │
│ GitHub │
└──────────────┘
│
├──────────────┐
│ │
▽ ▽
┌──────────────┬──────────────┐
│ BUILD │ BUILD │
│ │ │
│ DockerBuild │ CdkBuild │
└──────────────┴──────────────┘
│ │
├──────────────┘
│
▽
┌──────────────┐
│ DEPLOY │
│ │
│ CFN_Deploy │
└──────────────┘
```## To deploy manually (using asset, for development purposes)
```ts
npm run build
npx cdk deploy HttpServiceStack
```## To deploy using CI/CD
Fork this repository to your own repository, update the repository name in
`lib/code-pipeline-stack.ts`, and deploy the pipeline so:```ts
npm run build
npx cdk deploy CodePipelineStack
```NOTE: It would probably be better to parameterize the pipeline source, but this example
is simplified somewhat for understandability.