Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
/ cirrocumulus Public archive

Library to create an easy-to-use ECS cluster using AWS CDK

License

Notifications You must be signed in to change notification settings

cohalz/cirrocumulus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9738caa · Mar 16, 2022
Mar 1, 2022
Jun 16, 2019
Feb 14, 2020
Jun 16, 2019
Feb 18, 2020
Jun 16, 2019
Jun 16, 2019
Jul 17, 2019
Jun 16, 2019
Oct 20, 2019
Mar 16, 2022
Mar 16, 2022
Jun 16, 2019
Jun 16, 2019
Jun 16, 2019

Repository files navigation

Cirrocumulus

Build Status

Install

npm i -D @cohalz/cirrocumulus

Libraries

Ec2Cluster

  • A ECS cluster configuration such as userdata

DeployFiles

  • Deploy local files to all instances of the ECS cluster

Synopsis

import { SynthUtils } from "@aws-cdk/assert"
import { InstanceClass, InstanceSize, Vpc } from "@aws-cdk/aws-ec2"
import { Role } from "@aws-cdk/aws-iam"
import { Stack } from "@aws-cdk/core"
import { Ec2Cluster, DeployFiles, ScalingPlan } from '@cohalz/cirrocumulus'
import * as path from "path"

const stack = new Stack()
const vpc = new Vpc(stack, "VPC")

const ec2Cluster = new Ec2Cluster(stack, "Ec2Cluster", {
  instanceTypes: [new InstanceType("t3.medium")],
  vpc,
})

const deployFiles = new DeployFiles(stack, "DeployFiles", {
  source: path.join(process.cwd(), "examples/"),
  targets: [
    {
      key: "tag:ClusterName",
      values: [ec2Cluster.cluster.clusterName],
    },
  ],
})

const instanceRole = ec2Cluster.autoScalingGroup.node.findChild(
  "InstanceRole"
) as Role
instanceRole.addToPolicy(deployFiles.deployPolicy())

const ecsService = new ecsPatterns.LoadBalancedEc2Service(this, "Ec2Service", {
  cluster: ec2Cluster.cluster,
  memoryLimitMiB: 512,
  image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
})

new cdk.CfnOutput(this, 'LoadBalancerDNS', { value: ecsService.loadBalancer.loadBalancerDnsName })

License

cirrocumulus is distributed under the Apache License, Version 2.0.

See LICENSE and NOTICE for more information.