### Setup Python Virtual Environment and Install ECS-Compose-X Source: https://docs.compose-x.io/installation.html This command sequence creates a Python virtual environment, activates it, upgrades pip, and then installs ECS-Compose-X. This is the preferred method for installation. ```bash python -m venv venv source venv/bin/activate pip install pip -U pip install ecs_composex ``` -------------------------------- ### Set Up Local Development Environment Source: https://docs.compose-x.io/contributing.html Install ECS Compose-X locally using a virtual environment and Poetry. This involves creating a virtual environment, activating it, installing Poetry, and then installing project dependencies. ```bash $ python -m venv venv $ source venv/bin/activate $ cd ecs_composex/ $ pip install poetry $ poetry install ``` -------------------------------- ### Basic Network Configuration Example Source: https://docs.compose-x.io/syntax/compose_x/ecs.details/network.html A basic example showing network configuration including x-ecs_connect, AssignPublicIp, Ingress, and x-cloudmap. ```yaml services: serviceA: x-network: x-ecs_connect: {} AssignPublicIp: bool Ingress: {} x-cloudmap: {} ``` -------------------------------- ### Example: Create New S3 Bucket Source: https://docs.compose-x.io/_sources/syntax/compose_x/s3.rst.txt This example demonstrates the creation of a new S3 bucket using ECS Compose-X. ```yaml x-s3: my-bucket: Properties: BucketEncryption: ServerSideEncryptionConfiguration: - ServerSideEncryptionByDefault: SSEAlgorithm: AES256 Services: my-app: Access: bucket: ListOnly objects: RW services: my-app: Image: "public.ecr.aws/nginx/nginx:latest" PortForwarding: - "80:80" ``` -------------------------------- ### Create Neptune Cluster Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/neptune.rst.txt An example demonstrating how to create a new Neptune Cluster using ECS Compose-X. This configuration is intended for initial setup. ```yaml x-neptune: cluster-01: Instances: - DBInstanceClass: db.t3.medium DBClusterParameterGroup: Name: default.neptune1 Properties: StorageEncrypted: true DeletionProtection: false ``` -------------------------------- ### Example: Create New Bucket with AWS CFN Properties Source: https://docs.compose-x.io/_sources/syntax/compose_x/s3.rst.txt This example demonstrates creating a new S3 bucket and configuring it with AWS CloudFormation properties. ```yaml x-s3: my-bucket: Properties: BucketEncryption: ServerSideEncryptionConfiguration: - ServerSideEncryptionByDefault: SSEAlgorithm: AES256 PublicAccessBlockConfiguration: BlockPublicAcls: "true" BlockPublicPolicy: "true" IgnorePublicAcls: "true" RestrictPublicBuckets: "true" Services: my-app: Access: bucket: ListOnly objects: RW services: my-app: Image: "public.ecr.aws/nginx/nginx:latest" PortForwarding: - "80:80" ``` -------------------------------- ### Simple SSM Parameter Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/ssm_parameter.rst.txt A basic example demonstrating the usage of x-ssm_parameter, likely for creating a simple SSM parameter. ```yaml x-ssm_parameter: parameterA: Lookup: Tags: - owner: myself - costallocation: 123 Services: - name: serviceA access: SSMParameterReadPolicy ``` -------------------------------- ### Install ECS Compose-X from Cloned Sources using Poetry Source: https://docs.compose-x.io/_sources/installation.rst.txt Navigate into the cloned repository, set up a virtual environment, upgrade pip, install poetry, and then install ECS Compose-X with poetry. This method is recommended for development purposes and installs dev dependencies. ```console # After git clone cd ecs_composex python -m venv venv source venv/bin/activate pip install pip -U pip install poetry poetry install ``` -------------------------------- ### Example: Create Only with Topics Source: https://docs.compose-x.io/_sources/syntax/compose_x/alarms.rst.txt This example demonstrates creating alarms with SNS topic configurations, as shown in the use-cases/alarms/create_only.with_topics.yml file. ```yaml x-alarms: alarm-01: Properties: Namespace: AWS/ApplicationELB Dimensions: - Name: LoadBalancer Value: !Ref LoadBalancer - Name: TargetGroup Value: !Ref TargetGroup MetricName: HealthyCount Statistic: Minimum Period: 60 EvaluationPeriods: 1 Threshold: 0 ComparisonOperator: LessThanThreshold AlarmDescription: "Alarm when the healthy count drops to zero." AlarmActions: - !Ref SNSTopic OKActions: - !Ref SNSTopic Topics: - x-sns: sns-topic-01 NotifyOn: all ``` -------------------------------- ### Full Compose File Example with Service Configuration Source: https://docs.compose-x.io/syntax/compose_x/ecs.details/deploy.html A comprehensive example of a compose file including secrets, service definitions with logging, sysctls, capabilities, and other configurations. ```yaml --- # base file for services with the x-keys for BDD version: '3.8' secrets: abcd: {} john: x-secrets: Name: /cicd/shared/github.com/token VarName: SOMETHING_GITHUB zyx: {} services: app01: logging: driver: awslogs options: awslogs-group: a-custom-name awslogs-create-group: "true" sysctls: - net.core.somaxconn=2048 - net.ipv4.tcp_syncookies=1 cap_add: - ALL ``` -------------------------------- ### Install ECS-Compose-X from Source using Poetry Source: https://docs.compose-x.io/installation.html For development purposes, install ECS-Compose-X from source using Poetry. This command also installs development dependencies. ```bash # After git clone cd ecs_composex python -m venv venv source venv/bin/activate pip install pip -U pip install poetry poetry install ``` -------------------------------- ### Example: Create Only with Alarms and ELBv2 Source: https://docs.compose-x.io/_sources/syntax/compose_x/alarms.rst.txt This example shows how to create alarms specifically for an ELBv2 resource, as found in the use-cases/elbv2/create_only_with_alarms.yml file. ```yaml x-alarms: alarm-01: Properties: Namespace: AWS/ApplicationELB Dimensions: - Name: LoadBalancer Value: !Ref LoadBalancer - Name: TargetGroup Value: !Ref TargetGroup MetricName: HealthyCount Statistic: Minimum Period: 60 EvaluationPeriods: 1 Threshold: 0 ComparisonOperator: LessThanThreshold AlarmDescription: "Alarm when the healthy count drops to zero." AlarmActions: - !Ref SNSTopic OKActions: - !Ref SNSTopic ``` -------------------------------- ### Ingress Configuration Example Source: https://docs.compose-x.io/syntax/compose_x/ecs.details/network.html An example demonstrating how to configure ingress rules for external IP addresses, AWS security groups, and prefix lists, along with self-access options. ```yaml services: app01: x-network: Ingress: ExtSources: - IPv4: 0.0.0.0/0 Name: all - IPv4: 1.1.1.1/32 Source_name: CloudFlareDNS AwsSources: - Type: SecurityGroup Id: sg-abcd - Type: PrefixList Id: pl-abcd Myself: True/False ``` -------------------------------- ### Install ECS-Compose-X from Source using Pip Source: https://docs.compose-x.io/installation.html After cloning the repository and setting up a virtual environment, use this command to install ECS-Compose-X from the local source. ```bash # After git clone cd ecs_composex python -m venv venv source venv/bin/activate pip install pip -U pip install . ``` -------------------------------- ### Short Example: x-s3 Bucket with Service Access Source: https://docs.compose-x.io/syntax/compose_x/s3.html A concise example demonstrating the definition of an S3 bucket ('bucketA') with specific access settings for a service ('service-01'). It shows how to define object and bucket-level access permissions. ```yaml x-s3: bucketA: Properties: {} Settings: {} Services: service-01: Access: objects: RW bucket: ListOnly services: service-01: {} ``` -------------------------------- ### Ingress Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/ecs.details/network.rst.txt An example demonstrating how to configure ingress rules for a service, including external IP sources, AWS sources like security groups and prefix lists, and a 'Myself' flag. ```yaml services: app01: x-network: Ingress: ExtSources: - IPv4: 0.0.0.0/0 Name: all - IPv4: 1.1.1.1/32 Source_name: CloudFlareDNS AwsSources: - Type: SecurityGroup Id: sg-abcd - Type: PrefixList Id: pl-abcd Myself: True/False ``` -------------------------------- ### Example: Lookup and Use Existing S3 Bucket Source: https://docs.compose-x.io/_sources/syntax/compose_x/s3.rst.txt This example shows how to configure ECS Compose-X to look up and use an existing S3 bucket. ```yaml x-s3: my-bucket: Lookup: Name: "my-existing-bucket" Tags: - name: "prod" value: "true" Services: my-app: Access: bucket: ListOnly objects: RW services: my-app: Image: "public.ecr.aws/nginx/nginx:latest" PortForwarding: - "80:80" ``` -------------------------------- ### Set up Python Virtual Environment and Install Cookiecutter Source: https://docs.compose-x.io/_sources/create_own_extension.rst.txt These commands set up a Python virtual environment, activate it, upgrade pip, and install the cookiecutter tool, which is necessary for generating the extension project structure. ```bash python3 -m venv venv source venv/bin/activate python3 -m pip install pip -U pip install cookiecutter ``` -------------------------------- ### Install ECS Compose-X from Cloned Sources using Pip Source: https://docs.compose-x.io/_sources/installation.rst.txt Navigate into the cloned repository, set up a virtual environment, upgrade pip, and install ECS Compose-X using pip. ```console # After git clone cd ecs_composex python -m venv venv source venv/bin/activate pip install pip -U pip install . ``` -------------------------------- ### Set up Python Virtual Environment and Install ECS Compose-X Source: https://docs.compose-x.io/_sources/installation.rst.txt Create a new Python virtual environment, activate it, upgrade pip, and then install ECS Compose-X. This is highly recommended to avoid conflicts with system-wide packages. ```console python -m venv venv source venv/bin/activate pip install pip -U pip install ecs_composex ``` -------------------------------- ### S3 Bucket Access Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/s3.rst.txt A short example demonstrating service access to an S3 bucket, specifying 'ListOnly' for bucket access and 'RW' for object access. ```yaml x-s3: bucketA: Properties: {} Settings: {} Services: service-01: Access: objects: RW bucket: ListOnly services: service-01: {} ``` -------------------------------- ### Lookup Neptune DB Cluster Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/neptune.rst.txt An example showing how to use the lookup functionality to reference an existing Neptune DB Cluster. This is recommended for production to avoid accidental deletions. ```yaml x-neptune: cluster-01: Lookup: Identifier: my-neptune-cluster Tags: Project: compose-x ``` -------------------------------- ### Plan Deployment with ECS Compose-X (Installed) Source: https://docs.compose-x.io/examples/nginx_simple.html Execute the `plan` command after installing ECS Compose-X locally to preview CloudFormation changesets. This is useful for verifying deployment configurations before applying them. ```bash # Using compose-x after install ecs-compose-x plan -f docker-compose.yaml -f aws-compose-x.yaml -n frontend-app ``` -------------------------------- ### Compose X Service with Docker Options Source: https://docs.compose-x.io/syntax/compose_x/ecs.details/docker_opts.html Example of defining a service in Compose X with `x-docker_opts` and `InterpolateWithDigest` enabled. ```yaml services: serviceA: image: nginx x-docker_opts: InterpolateWithDigest: bool ``` -------------------------------- ### Get FireLens Advanced Configuration Source: https://docs.compose-x.io/_modules/ecs_composex/compose/compose_services/service_logging.html Extracts the 'Advanced' section from the FireLens configuration. This allows for detailed, custom FireLens setups. ```python @property def firelens_advanced(self) -> dict: return set_else_none("Advanced", self.firelens_config) ``` -------------------------------- ### Create a DocDB and import an existing one Source: https://docs.compose-x.io/_sources/syntax/compose_x/opensearch.rst.txt This sample demonstrates how to create an OpenSearch domain and import an existing one. It is designed for lookup scenarios. ```yaml name: "opensearch-lookup-sample" services: opensearch: type: "opensearch" version: "1.3.0" lookup: true vpc_options: subnet_ids: - "subnet-xxxxxxxxxxxxxxxxx" - "subnet-yyyyyyyyyyyyyyyyy" ``` -------------------------------- ### ECS Cluster Creation (AWS Console - Fargate Providers) Source: https://docs.compose-x.io/_sources/syntax/compose_x/ecs.details/deploy.rst.txt Example of an ECS cluster configuration created via the AWS Console, which automatically includes Fargate capacity providers. This setup is ready for Fargate deployments. ```json [ { "clusterArn": "arn:aws:ecs:eu-west-1:211111111111:cluster/testinginconsole", "clusterName": "testinginconsole", "status": "ACTIVE", "registeredContainerInstancesCount": 0, "runningTasksCount": 0, "pendingTasksCount": 0, "activeServicesCount": 0, "statistics": [], "tags": [], "settings": [ { "name": "containerInsights", "value": "enabled" } ], "capacityProviders": [ "FARGATE_SPOT", "FARGATE" ], "defaultCapacityProviderStrategy": [] } ] ``` -------------------------------- ### FireLens Configuration Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/ecs.details/logging.rst.txt Illustrates the basic structure for configuring FireLens, which automatically generates FluentBit configurations for log shipping. ```yaml FireLens is a configuration that will automatically generate the configuration for `FluentBit`_ to ship logs in the appropriate destinations configured. We recommend the `Rendered`_ configuration which works for AWS Fargate, EC2 and ECS Anywhere. ``` -------------------------------- ### Install ECS-Compose-X via Pip Source: https://docs.compose-x.io/installation.html Install ECS-Compose-X using pip for the most recent stable release. It is recommended to install within a Python virtual environment. ```bash pip install --user ecs_composex ``` -------------------------------- ### Install ECS Compose-X using Pip Source: https://docs.compose-x.io/_sources/installation.rst.txt Install the ECS Compose-X package using pip. This is the recommended method for installing the most recent stable release. ```console pip install --user ecs_composex ``` -------------------------------- ### setup_logging Function Source: https://docs.compose-x.io/ecs_composex.common.html Configures the logging system for the application. ```APIDOC ## ecs_composex.common.logging.setup_logging() ### Description Configures the logging system for the application. ``` -------------------------------- ### Determine Container Start Condition Source: https://docs.compose-x.io/_modules/ecs_composex/compose/compose_services.html Determines the container start condition, prioritizing HEALTHY if ECS health check is defined, otherwise falling back to START based on deploy labels. ```python if ( isinstance(self.ecs_healthcheck, HealthCheck) and self.ecs_healthcheck != NoValue ): return "HEALTHY" depends_key = "ecs.depends.condition" return set_else_none( depends_key, self.deploy_labels, alt_value="START", ) ``` -------------------------------- ### Docker Compose Blog Example Source: https://docs.compose-x.io/_sources/extras.rst.txt This YAML file demonstrates a typical Docker Compose configuration for a blog service, including resource limits and reservations. ```yaml version: "3.7" services: blog: image: "docker.io/library/nginx:latest" ports: - "80:80" deploy: resources: limits: cpus: "0.75" memory: "192M" reservations: cpus: "0.25" memory: "128M" ``` -------------------------------- ### Install ECS Compose-X Source: https://docs.compose-x.io/_sources/index.rst.txt Install ECS Compose-X within a Python virtual environment or for your user only. ```bash python3 -m venv venv source venv/bin/activate pip install pip -U pip install ecs-composex ``` ```bash pip install ecs-composex --user ``` -------------------------------- ### Basic Secret Definition Example Source: https://docs.compose-x.io/_sources/syntax/docker-compose/secrets.rst.txt A simple example of defining a secret named `topsecret_info` and then referencing it in a service definition. ```yaml secrets: topsecret_info: x-secrets: Name: /path/to/my/secret services: serviceA: secrets: - topsecret_info ``` -------------------------------- ### Define x-sqs and x-neptune Resources with Access and ReturnValues Source: https://docs.compose-x.io/_sources/syntax/compose_x/common.rst.txt This example shows the definition of x-sqs and x-neptune resources, including service access configurations and the use of `ReturnValues` to expose resource properties as environment variables. ```yaml x-sqs: queue01: # We only set the access, no return values Services: backend: Access: RW x-neptune: cluster-01: Services: backend: Access: Http: RW DBCluster: RO ReturnValues: ClusterResourceId: CLUSTER_ID cluster-0002: Services: backend: Access: Http: RW DBCluster: RO ReturnValues: DBClusterArn: CLUSTER_ID # Here when specifying the env var to CLUSTER_ID, this will conflict with cluster-01 value. ``` -------------------------------- ### RDS MacroParameters Definitions Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/rds.rst.txt An example demonstrating how to define RDS MacroParameters, including engine details, availability, and feature configurations. ```yaml Engine: aurora-postgresql # Same as AWS CFN Engine property EngineVersion: 11.7 # Same as AWS CFN EngineVersion property UseServerless: False UseMultiAz: True ParametersGroups: Description: Some description Family: aurora-postgresql-11.7 Parameters: {} Instances: [] RdsFeatures: - Name: s3Import Resources: - x-s3::bucket-01 - arn:aws:s3:::bucket/path/allowed/* - bucket-name ``` -------------------------------- ### AWS ECR Setup and Image Push Source: https://docs.compose-x.io/examples/nginx_simple.html Commands to set up an AWS ECR repository, log in Docker, and push the built image. This prepares the image for deployment on AWS. ```bash # Define your region or default region export AWS_DEFAULT_REGION=us-east-1 # Create the new ECR Repository aws ecr create-repository --repository-name frontend export AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r .Account) # We define the Registy URI based on the region and account ID export REGISTRY_URI=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION:-$AWS_DEFAULT_REGION}.amazonaws.com/ # We then log in. aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin ${REGISTRY_URI} # We rebuild the image even if there is no change, so that the image gets tagged properly docker-compose -f docker-compose.yaml build docker-compose -f docker-compose.yaml push ``` -------------------------------- ### Simple SSM Parameter Examples Source: https://docs.compose-x.io/syntax/compose_x/ssm_parameter.html Illustrates various ways to define SSM parameters, including basic string parameters, parameters with service access, and parameters loaded from local files with transformations. ```yaml version: '3.8' x-ssm_parameter: parameterA: Properties: DataType: text Description: Something Name: /some/parameter Type: String Value: ABCD parameterB: Properties: DataType: text Description: Something Name: /some/other-parameter Type: String Value: ABCD Services: bignicefamily: Access: RW parameterC: MacroParameters: FromFile: ./use-cases/ssm/test_json.json MinimizeJson: true ValidateJson: true Properties: Name: /some/yet-other-parameter Type: String Services: rproxy: Access: RO youtoo: Access: SSMParameterReadPolicy parameterD: MacroParameters: FromFile: ./use-cases/ssm/test_yaml.yaml ValidateYaml: true Properties: Name: /some/yet-other-parameter Type: String Services: rproxy: Access: RO youtoo: Access: SSMParameterReadPolicy parameterENCODED: MacroParameters: EncodeToBase64: true FromFile: ./use-cases/ssm/test_yaml_jinja2.yaml Properties: Name: /some/yet-other-parameter Type: String Services: rproxy: Access: RO youtoo: Access: SSMParameterReadPolicy parameterS: MacroParameters: FromFile: ./use-cases/ssm/test_yaml.yaml RenderToJson: true ValidateYaml: true Properties: Name: /some/yet-other-parameter Type: String Services: rproxy: Access: RO youtoo: Access: SSMParameterReadPolicy ``` -------------------------------- ### RDS RdsFeatures Example with S3 Integration Source: https://docs.compose-x.io/_sources/syntax/compose_x/rds.rst.txt An example showcasing the use of RdsFeatures for s3Import and s3Export, including resource definitions for S3 buckets. ```yaml x-rds: dbB: Properties: {} MacroParameters: PermissionsBoundary: policy-name RdsFeatures: - Name: s3Import Resources: - x-s3::bucket-01 - arn:aws:s3:::sacrificial-lamb/folder/* - bucket-name - Name: s3Export Resources: - x-s3::bucket-01 - arn:aws:s3:::sacrificial-lamb/folder/* - bucket-name ``` -------------------------------- ### AWS CloudFormation Event Rule Example Source: https://docs.compose-x.io/how_tos/ecs_scheduled_tasks.html This is an example of an AWS CloudFormation Event Rule definition. It specifies event patterns to filter AWS events. ```yaml EventRule: Type: AWS::Events::Rule Properties: Description: "EventRule" EventPattern: source: - "aws.ec2" detail-type: - "EC2 Instance State-change Notification" detail: state: - "stopping" State: "ENABLED" Targets: - Arn: Fn::GetAtt: - "LambdaFunction" - "Arn" Id: "TargetFunctionV1" ``` -------------------------------- ### Set Container Start Condition Source: https://docs.compose-x.io/_modules/ecs_composex/compose/compose_services.html Sets the container start condition based on provided valid conditions. Updates the deploy labels or creates them if they don't exist. ```python depends_key = "ecs.depends.condition" valid_conditions = ["START", "COMPLETE", "SUCCESS", "HEALTHY"] if value not in valid_conditions: raise ValueError( self.name, depends_key, "is set to ", value, "must be one of", valid_conditions, ) if self.deploy: if keyisset("labels", self.deploy): self.deploy["labels"][depends_key] = value else: self.deploy["labels"]: dict = {depends_key: value} else: self.deploy: dict = {"labels": {depends_key: value}} ``` -------------------------------- ### DocDB Cluster Parameter Group Example Source: https://docs.compose-x.io/syntax/compose_x/docdb.html An example of creating a custom parameter group for a DocDB cluster, including description, family, name, and specific parameters. ```yaml Description: "description" Family: "docdb3.6" Name: "sampleParameterGroup" Parameters: audit_logs: "disabled" tls: "enabled" ttl_monitor: "enabled" ``` -------------------------------- ### ecs_composex.vpc.vpc_stack.Vpc.init_outputs Source: https://docs.compose-x.io/ecs_composex.vpc.html Initializes outputs for the VPC. ```APIDOC ## Vpc.init_outputs() ### Description Initializes outputs for the VPC. ### Method (Method signature not provided in source) ``` -------------------------------- ### Initialize Modules and Resources Source: https://docs.compose-x.io/_modules/ecs_composex/mods_manager.html Initializes modules and their resources based on ComposeX settings. It iterates through loaded modules, checks for resource class definitions, and sets up resources if a module definition exists. ```python def init_mods_resources(self, settings: ComposeXSettings): for module in self.modules.values(): if not module.resource_class or not isinstance( settings.compose_content[module.res_key], dict ): continue if module.definition: module.set_resources(settings) elif keyisset(module.res_key, settings.compose_content): module.definition = settings.compose_content[module.res_key] module.set_resources(settings) ``` -------------------------------- ### ecs_composex.vpc.vpc_stack.init_vpc_template Source: https://docs.compose-x.io/ecs_composex.vpc.html Initializes the VPC template. ```APIDOC ## init_vpc_template() ### Description Initializes the VPC template. ### Parameters (Parameters not provided in source) ``` -------------------------------- ### OpenSearchDomain.init_outputs Source: https://docs.compose-x.io/ecs_composex.opensearch.html Initializes the output properties for an OpenSearchDomain. ```APIDOC ## OpenSearchDomain.init_outputs ### Description Initializes the output properties for an OpenSearchDomain. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ``` -------------------------------- ### ECR Vulnerability Scan Configuration Example Source: https://docs.compose-x.io/syntax/compose_x/ecs.details/ecr.html Example demonstrating how to enable and configure ECR vulnerability scanning for a service, including ignoring failures and setting severity thresholds. ```yaml services: grafana: x-ecr: InterpolateWithDigest: true VulnerabilitiesScan: IgnoreFailure: false Thresholds: CRITICAL: 0 HIGH: 5 MEDIUM: 10 LOW: 10 ``` -------------------------------- ### x-elbv2 Alarm Example Source: https://docs.compose-x.io/syntax/compose_x/alarms.html Defines an AWS NetworkELB alarm monitoring HealthyHostCount, linking to an x-elbv2 resource. This example demonstrates how to specify dimensions and metric properties for an alarm. ```yaml timeout_seconds: 60 desync_mitigation_mode: defensive drop_invalid_header_fields: True http2: False cross_zone: True Settings: {} Listeners: - Port: 8080 TargetGroupAttributes: deregistration_delay.timeout_seconds: "30" proxy_protocol_v2.enabled: "true" preserve_client_ip.enabled: "true" # - Key: deregistration_delay.timeout_seconds AlarmDescription: Alarm for Healthy hosts < 2 within a period of 1 minute ComparisonOperator: LessThanThreshold DatapointsToAlarm: 1 Dimensions: - Name: LoadBalancer Value: x-elbv2::lbC - Name: TargetGroup Value: x-elbv2::lbC::app03::5000 EvaluationPeriods: 1 MetricName: HealthyHostCount Namespace: AWS/NetworkELB Period: 60 Statistic: Maximum Threshold: 2.0 TreatMissingData: notBreaching ``` -------------------------------- ### Sample to create two DBs with different instances configuration Source: https://docs.compose-x.io/_sources/syntax/compose_x/opensearch.rst.txt Use this sample to create two OpenSearch databases with distinct instance configurations. Ensure you set either GenerateMasterUserSecret or CreateMasterUserRole, but not both, to True. ```yaml name: "opensearch-sample" services: opensearch: type: "opensearch" version: "1.3.0" instances: - name: "opensearch-1" instance_type: "t3.small.search" instance_count: 1 - name: "opensearch-2" instance_type: "r5.large.search" instance_count: 1 vpc_options: subnet_ids: - "subnet-xxxxxxxxxxxxxxxxx" - "subnet-yyyyyyyyyyyyyyyyy" create_master_user_role: true generate_master_user_secret: false master_user_role_permissions_boundary: "arn:aws:iam::123456789012:policy/MyPermissionsBoundary" ``` -------------------------------- ### Kinesis Stream Services Definition Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/kinesis.rst.txt Example demonstrating how to configure services to access a Kinesis stream as either a Producer or Consumer. This includes setting the ShardCount for the stream. ```yaml services: [serviceA, serviceB] x-kinesis: streamA: Properties: ShardCount: 2 Services: serviceA: Access: Producer serviceB: Access: Consumer ``` -------------------------------- ### NetworkXResource Initialization Source: https://docs.compose-x.io/_modules/ecs_composex/compose/x_resources/network_x_resources.html Initializes a NetworkXResource, setting up VPC requirements and cleansing external targets. Requires ComposeXSettings for configuration. ```python class NetworkXResource(ServicesXResource): """ Class for resources that need VPC and SecurityGroups to be managed for Ingress """ def __init__( self, name: str, definition: dict, module: XResourceModule, settings: ComposeXSettings, ): self.subnets_override = None self.security_group = None self.security_group_param = None self.port_param = None super().__init__(name, definition, module, settings) self.requires_vpc = True self.cleanse_external_targets() self.set_override_subnets() self.cloudmap_dns_supported = True ``` -------------------------------- ### DocumentDB Parameter Group Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/docdb.rst.txt An example of defining a custom parameter group for a DocumentDB cluster to tune its settings. Includes description, family, name, and specific parameters. ```yaml Description: "description" Family: "docdb3.6" Name: "sampleParameterGroup" Parameters: audit_logs: "disabled" tls: "enabled" ttl_monitor: "enabled" ``` -------------------------------- ### ecs_composex.cli.main Source: https://docs.compose-x.io/ecs_composex.html Main entry point for the ECS ComposeX CLI. ```APIDOC ## main ### Description Main entry point for CLI. ### Returns - status code (int) ``` -------------------------------- ### init_vpc_template Source: https://docs.compose-x.io/ecs_composex.vpc.html Creates a VPC Template. ```APIDOC ## init_vpc_template ### Description Simple wrapper function to create the VPC Template. ### Returns troposhere.Template ``` -------------------------------- ### Custom Fluent Bit Source File Example Source: https://docs.compose-x.io/_sources/syntax/compose_x/ecs.details/x_logging_firelens.rst.txt Illustrates how to include a custom source file in Fluent Bit configuration to add pre-built parsers and transform logs, such as NGINX logs. ```fluentbit [SERVICE] Parsers_File /fluent-bit/parsers/parsers.conf [FILTER] Name modify Match web-firelens* Rename ecs_task_arn task_id [FILTER] Name parser Match web-firelens* Parser nginx Key_Name log Reserve_Data True ``` -------------------------------- ### FamilyLogging.init_family_services_log_configuration Source: https://docs.compose-x.io/ecs_composex.ecs.ecs_family.family_logging.html Initializes the logging configuration for all services within the family. ```APIDOC ## FamilyLogging.init_family_services_log_configuration() ### Response #### Success Response (200) - **None** - ``` -------------------------------- ### RDS MacroParameters Definitions Example Source: https://docs.compose-x.io/syntax/compose_x/rds.html An example demonstrating how to define RDS MacroParameters, including engine, version, serverless, multi-AZ, parameter groups, instances, and RDS features like s3Import. ```yaml Engine: aurora-postgresql # Same as AWS CFN Engine property EngineVersion: 11.7 # Same as AWS CFN EngineVersion property UseServerless: False UseMultiAz: True ParametersGroups: Description: Some description Family: aurora-postgresql-11.7 Parameters: {} Instances: [] RdsFeatures: - Name: s3Import Resources: - x-s3::bucket-01 - arn:aws:s3:::bucket/path/allowed/* - bucket-name ``` -------------------------------- ### x-elbv2 ApplicationELB Alarm Example Source: https://docs.compose-x.io/syntax/compose_x/alarms.html Defines an AWS ApplicationELB alarm monitoring HTTPCode_ELB_5XX_Count, linking to an x-elbv2 resource. This example shows alarm configuration for a different ELB type and metric. ```yaml lba-only-issues: Properties: AlarmName: unheathy_hosts_alb ActionsEnabled: True AlarmDescription: Alarm for Healthy hosts < 2 within a period of 1 minute ComparisonOperator: LessThanThreshold DatapointsToAlarm: 1 Dimensions: - Name: LoadBalancer Value: x-elbv2::lbA EvaluationPeriods: 1 MetricName: HTTPCode_ELB_5XX_Count Namespace: AWS/ApplicationELB Period: 60 Statistic: Maximum Threshold: 2.0 TreatMissingData: notBreaching ``` -------------------------------- ### x-codeguru_profiler with Service Integration Source: https://docs.compose-x.io/syntax/compose_x/codeguru_profiler.html Example showing how to configure a CodeGuru Profiler and associate it with a service, retrieving the profiling group name via an environment variable. ```yaml x-codeguru_profiler: Profiler01: Properties: {} Services: service01 Access: RW ReturnValues: ProfileName: AWS_CODEGURU_PROFILER_GROUP_NAME ``` -------------------------------- ### Initialize ServiceCompute with Family Source: https://docs.compose-x.io/_modules/ecs_composex/ecs/service_compute.html Instantiates the ServiceCompute class, setting up initial states for launch type and capacity providers based on the provided ComposeFamily object. ```python class ServiceCompute: """ Class to manage the ECS Service settings for launch type and capacity providers """ def __init__(self, family): self.family: ComposeFamily = family self._launch_type = None self._ecs_capacity_providers = [] self._cfn_launch_type = None self._cfn_capacity_providers = None self.set_update_launch_type() self.set_update_capacity_providers() ``` -------------------------------- ### Configure x-docdb Resource with Network and IAM Access Source: https://docs.compose-x.io/_sources/syntax/compose_x/common.rst.txt This example demonstrates configuring an x-docdb resource, granting network access and IAM permissions for a DocumentDB cluster. ```yaml x-docdb: # To access DocumentDB, we need to grant network access and IAM permissions to the secret, done automatically db-01: Services: backend: Access: DBCluster: RO # Here, we grant additional IAM permissions to the service to allow describe of the cluster. ReturnValues: ClusterResourceId: DB01_CLUSTER_ID # We expose the ClusterResourceId value into a variable DB01_CLUSTER_ID to the service. ``` -------------------------------- ### Create and Import Existing DocDB Instances Source: https://docs.compose-x.io/syntax/compose_x/docdb.html Configure a new DocDB instance alongside importing an existing one using lookup criteria. This allows for managing both new and pre-existing resources within the same configuration. ```yaml x-docdb: docdbA: Properties: {} Services: app03: access: RW docdbB: Lookup: cluster: Name: docdbb-purmjgtgvyqr Tags: - CreatedByComposeX: 'true' - Name: docdb.docdbB secret: Tags: - aws:cloudformation:logical-id: docdbBSecret Services: app03: Access: RW ``` -------------------------------- ### ecs_composex.vpc.vpc_stack.Vpc.storage_subnets_count Source: https://docs.compose-x.io/ecs_composex.vpc.html Gets the count of storage subnets. ```APIDOC ## Vpc.storage_subnets_count() ### Description Gets the count of storage subnets. ### Method (Method signature not provided in source) ``` -------------------------------- ### init_database_template Source: https://docs.compose-x.io/ecs_composex.rds.html Initialize default DB Template. ```APIDOC ## init_database_template ### Description Initialize default DB Template. ### Parameters * **db** (ecs_composex.rds.rds_stack.Rds) – The RDS database configuration. ### Returns troposphere.Template ``` -------------------------------- ### ECS Compose-X Plan Output Example Source: https://docs.compose-x.io/examples/nginx_simple.html Observe the informational and warning messages generated by ECS Compose-X during the `plan` command execution. This output indicates resource creation, potential issues, and deployment details. ```text # Output should look like when using plan # We create a new VPC and ECS Cluster given we did not specify existing ones. 2021-08-18 09:26:02 [INFO], No x-vpc detected. Creating a new VPC. 2021-08-18 09:26:02 [INFO], No cluster information provided. Creating a new one # Compose-x will "crunch" all the input and let us know of anything of interest or just some info. 2021-08-18 09:26:02 [INFO], No external rules defined. Skipping. 2021-08-18 09:26:02 [ERROR], No scaling range was defined for the service and rule HighCpuUsageAndMaxScaledOut requires it. Skipping 2021-08-18 09:26:02 [ERROR], No scaling range was defined for the service and rule HighRamUsageAndMaxScaledOut requires it. Skipping 2021-08-18 09:26:02 [INFO], Family frontend - Service frontend 2021-08-18 09:26:02 [INFO], LB public-alb only has a unique service. LB will be deployed with the service stack. 2021-08-18 09:26:02 [WARNING], You defined ingress rules for a NLB. This is invalid. Define ingress rules at the service level. 2021-08-18 09:26:02 [INFO], Added dependency between service family frontend and elbv2 2021-08-18 09:26:02 [WARNING], No certificates defined for Listener publicalb80 2021-08-18 09:26:02 [INFO], publicalb80 has no defined DefaultActions and only 1 service. Default all to service. ```