Skip to main content

Reusable CDK construct for an ECS Service

Project description

aws_cdk-ecs-service

A reusable AWS CDK module for deploying an ECS Service with advanced deployment and load balancing options.

Features

  • Deploys an ECS Service using CloudFormation via AWS CDK
  • Supports custom deployment configuration and circuit breaker
  • Integrates with existing ECS Cluster and Target Group via CloudFormation exports
  • Outputs ECS Service Name, ARN, and ID

Installation

pip install ecs_service

Usage

Prerequisites

  • Python 3.8+
  • AWS CDK v2
  • Install dependencies:
    pip install aws-cdk-lib constructs pytest
    

Example

from aws_cdk import App, Stack
from ecs_service.ecs_service_stack import ECSServiceStack

app = App()
stack = Stack(app, "MyStack")

ECSServiceStack(
    scope=stack,
    id="ECSService",
    ecs_stack_name="MyStack",
    desired_count=2,
    task_definition_arn="arn:aws:ecs:region:account-id:task-definition/my-task-def",
    health_check_grace_period_seconds=60,
    container_port=80,
    target_group_arn="arn:aws:elasticloadbalancing:region:account-id:targetgroup/my-tg/1234567890abcdef",
    containername="my-container",
    maximum_percent=200,
    minimum_healthy_percent=100
)

Testing

Unit tests are provided using pytest and aws_cdk.assertions.

To run tests:

pytest

Logical IDs

Logical IDs generated by AWS CDK are random and may change between synths. Use resource outputs and exports for stable references.

Project Structure

src/
  ecs_service/
    ecs_service_stack.py
tests/
  test_ecs_service.py
README.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecs-service-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ecs_service-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file ecs-service-0.1.0.tar.gz.

File metadata

  • Download URL: ecs-service-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ecs-service-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b7e0134032a6171ecd5323d2f47a36e25423d9cb572a2e248b4332a0be6286ce
MD5 c413820da17fb025fd65115759f2fb83
BLAKE2b-256 70ffb79563009c2fc7c47b436522e971cce45f83f0caeb5ac564bcd8686d1b10

See more details on using hashes here.

File details

Details for the file ecs_service-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ecs_service-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ecs_service-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 449fdff0dff017da1636d4d69db8f37bab1143b4218ece679585e2b407e9deae
MD5 db53c3d27a1baa7c4a6ae7b468ff8024
BLAKE2b-256 610ca95057cc54260a198ca17d6a8ccd85558286074f271adafacfcf2e832672

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page