ecs_composex.compute package ¶
Submodules ¶
ecs_composex.compute.compute_conditions module ¶
Conditions relative to the Compute stack.
ecs_composex.compute.compute_params module ¶
Cluster parameters for CFN This is a crucial part as all the titles, maked _T are string which are then used the same way across all imports, which gives consistency for CFN to use the same names, which it heavily relies onto.
You can change the names values so you like so long as you keep it [a-zA-Z0-9]
ecs_composex.compute.compute_stack module ¶
Module to create the compute resources, if so chosen, the SpotFleet / OnDemand instances to go with it.
The SpotFleet and OnDemand instances are optional, but the LaunchTemplate gets created so that if for testing one would wish to run a new EC2 instance, you can simply do it from the launch template.
- class ecs_composex.compute.compute_stack. ComputeStack ( title , settings , parameters ) [source] ¶
-
Bases:
ecs_composex.common.stacks.ComposeXStack
Class to handle the EC2 compute creation.
- ecs_composex.compute.compute_stack. create_compute_stack ( settings ) [source] ¶
-
Function entrypoint for CLI.
- Parameters
-
settings ( ecs_composex.common.settings.ComposeXSettings ) – The settings for execution
- Returns
-
cluster template
- Return type
-
troposphere.Template
ecs_composex.compute.compute_template module ¶
Main module generating the ECS Cluster template.
The root stack is to build the IAM Instance profile for the hosts that can be used for ASG or SpotFleet. That way it is easy for anyone to deploy an instance in standalone if you wanted that.
- ecs_composex.compute.compute_template. add_spotfleet_stack ( template , settings , launch_template ) [source] ¶
-
Function to build the spotfleet stack and add it to the Cluster parent template
- Parameters
-
-
launch_template – the launch template
-
template ( troposphere.Template ) – parent cluster template
-
settings ( ComposeXSettings ) – The settings for execution
-
- ecs_composex.compute.compute_template. generate_compute_template ( settings ) [source] ¶
-
Function that generates the Compute resources to run ECS services on top of EC2
- Parameters
-
settings ( ComposeXSettings ) – The settings for executio
- Returns
-
ECS Cluster Template
- Return type
-
troposphere.Template
ecs_composex.compute.hosts_template module ¶
Module to create the Launch Template for the hosts and the associated security group and IAM Role (with Instance Profile).
The Launch Template uses CFN-INIT in order to bootstrap the machine at runtime, avoiding any hardcoding, especially not for the ECS Service
These settings are all documented on AWS official documentation: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html
- ecs_composex.compute.hosts_template. add_hosts_profile ( template ) [source] ¶
-
Adds role to the template
- Parm template
-
EC2 Cluster template to add the role and profile to
- Returns
-
troposphere IAM Role for EC2 hosts
- Return type
-
troposphere.iam.Role
- ecs_composex.compute.hosts_template. add_hosts_resources ( template ) [source] ¶
-
Function to add the LaunchTemplate, SG and IAM Profile to go along with the ECS Cluster
- Parameters
-
template ( troposphere.Template ) – the ecs_cluster template to add the hosts config to
- Returns
-
launch_template
- Return type
-
troposphere.ec2.LaunchTemplate
- ecs_composex.compute.hosts_template. add_hosts_security_group ( template ) [source] ¶
-
Function to add a security group for the host
- Parm template
-
EC2 Cluster template to add the SG to
- Returns
-
troposphere IAM Role for EC2 hosts
- Return type
-
troposphere.ec2.SecurityGroup
- ecs_composex.compute.hosts_template. add_launch_template ( template , hosts_sg ) [source] ¶
-
Function to create a launch template.
- Parameters
-
-
template ( troposphere.Template ) – ECS Cluster template
-
hosts_sg ( troposphere.ec2.SecurityGroup ) – security group for the EC2 hosts
-
- Returns
-
launch_template
- Return type
-
troposphere.ec2.LaunchTemplate
ecs_composex.compute.spot_fleet module ¶
Functions to add to the Cluster template when people want to use SpotFleet for their ECS Cluster.
- ecs_composex.compute.spot_fleet. add_fleet_role ( template ) [source] ¶
-
Function to create the IAM Role for the EC2 Spot Fleet
- Parameters
-
template ( troposphere.Template ) – source template to add the resources to
- Returns
-
role
- Return type
-
troposphere.iam.Role
- ecs_composex.compute.spot_fleet. add_scaling_policies ( template , spot_fleet , role ) [source] ¶
-
Function to add Scaling to the SpotFleet
- Parameters
-
-
template ( troposphere.Template ) – source template to add the resources to
-
spot_fleet ( troposphere.ec2.SpotFleet ) – the SpotFleet for reference
-
role ( troposphere.iam.Role ) – IAM Role for the SpotFleet
-
- Returns
-
tuple(scale_in_policy, scale_out_policy)
- Return type
-
tuple
- ecs_composex.compute.spot_fleet. define_default_cw_alarms ( template , spot_fleet , scaling_set ) [source] ¶
-
Function to define CW alarms for the fleet. These default CW Alarms will purely rely on EC2 Metrics.
- Parameters
-
-
template ( troposphere.Template ) – Cluster Template
-
spot_fleet ( troposphere.ec2.SpotFleet ) – The spot fleet the alarms are for
-
scaling_set ( tuple ) – Scale In/Out Policies triggered by alarams
-
- Returns
-
void
- ecs_composex.compute.spot_fleet. define_overrides ( settings , lt_id , lt_version , spot_config ) [source] ¶
-
From the list of AZs and the configurations set for spotfleet instances, it will generate an override that SpotFleet will use to diversify the compute resources.
- Parameters
-
-
settings ( ecs_composex.common.settings.ComposeXSettings ) – The settings for execution
-
lt_id – Launch template ID
-
lt_version – Launch Template Version
-
spot_config – SpotFleet configuration for pricing and instance types
-
- Returns
-
configs
- Type
-
list
- ecs_composex.compute.spot_fleet. define_spot_fleet ( template , settings , lt_id , lt_version , spot_config ) [source] ¶
-
Function to add a spot fleet to the cluster template
- Parameters
-
-
settings ( ecs_composex.common.settings.ComposeXSettings ) – The settings for execution
-
template ( troposphere.Template ) – Source template
-
- Returns
-
NIL