cdk-factory 0.16.6__py3-none-any.whl → 0.16.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cdk-factory might be problematic. Click here for more details.
- cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py +70 -3
- cdk_factory/version.py +1 -1
- {cdk_factory-0.16.6.dist-info → cdk_factory-0.16.8.dist-info}/METADATA +1 -1
- {cdk_factory-0.16.6.dist-info → cdk_factory-0.16.8.dist-info}/RECORD +7 -7
- {cdk_factory-0.16.6.dist-info → cdk_factory-0.16.8.dist-info}/WHEEL +0 -0
- {cdk_factory-0.16.6.dist-info → cdk_factory-0.16.8.dist-info}/entry_points.txt +0 -0
- {cdk_factory-0.16.6.dist-info → cdk_factory-0.16.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,6 +12,7 @@ from aws_cdk import aws_autoscaling as autoscaling
|
|
|
12
12
|
from aws_cdk import aws_cloudwatch as cloudwatch
|
|
13
13
|
from aws_cdk import aws_iam as iam
|
|
14
14
|
from aws_cdk import aws_ssm as ssm
|
|
15
|
+
from aws_cdk import aws_ecs as ecs
|
|
15
16
|
from aws_cdk import Duration, Stack
|
|
16
17
|
from aws_lambda_powertools import Logger
|
|
17
18
|
from constructs import Construct
|
|
@@ -49,6 +50,8 @@ class AutoScalingStack(IStack):
|
|
|
49
50
|
self.launch_template = None
|
|
50
51
|
self.instance_role = None
|
|
51
52
|
self.user_data = None
|
|
53
|
+
self.ecs_cluster = None
|
|
54
|
+
self._vpc = None
|
|
52
55
|
|
|
53
56
|
# SSM imports storage is now handled by the enhanced SsmParameterMixin via IStack
|
|
54
57
|
|
|
@@ -92,6 +95,9 @@ class AutoScalingStack(IStack):
|
|
|
92
95
|
# Create launch template
|
|
93
96
|
self.launch_template = self._create_launch_template(asg_name)
|
|
94
97
|
|
|
98
|
+
# Create ECS cluster if ECS configuration is detected
|
|
99
|
+
self._create_ecs_cluster_if_needed(asg_name)
|
|
100
|
+
|
|
95
101
|
# Create Auto Scaling Group
|
|
96
102
|
self.auto_scaling_group = self._create_auto_scaling_group(asg_name)
|
|
97
103
|
|
|
@@ -110,6 +116,10 @@ class AutoScalingStack(IStack):
|
|
|
110
116
|
if not self.asg_config:
|
|
111
117
|
raise AttributeError("AutoScalingStack not properly initialized. Call build() first.")
|
|
112
118
|
|
|
119
|
+
# Return cached VPC if already created
|
|
120
|
+
if self._vpc:
|
|
121
|
+
return self._vpc
|
|
122
|
+
|
|
113
123
|
# Check SSM imported values first using enhanced mixin
|
|
114
124
|
if self.has_ssm_import("vpc_id"):
|
|
115
125
|
vpc_id = self.get_ssm_imported_value("vpc_id")
|
|
@@ -138,11 +148,14 @@ class AutoScalingStack(IStack):
|
|
|
138
148
|
vpc_attrs["public_subnet_ids"] = ["subnet-dummy1", "subnet-dummy2"]
|
|
139
149
|
|
|
140
150
|
# Use from_vpc_attributes() for SSM tokens
|
|
141
|
-
|
|
151
|
+
self._vpc = ec2.Vpc.from_vpc_attributes(self, f"{self.stack_name}-VPC", **vpc_attrs)
|
|
152
|
+
return self._vpc
|
|
142
153
|
elif self.asg_config.vpc_id:
|
|
143
|
-
|
|
154
|
+
self._vpc = ec2.Vpc.from_lookup(self, f"{self.stack_name}-VPC", vpc_id=self.asg_config.vpc_id)
|
|
155
|
+
return self._vpc
|
|
144
156
|
elif self.workload.vpc_id:
|
|
145
|
-
|
|
157
|
+
self._vpc = ec2.Vpc.from_lookup(self, f"{self.stack_name}-VPC", vpc_id=self.workload.vpc_id)
|
|
158
|
+
return self._vpc
|
|
146
159
|
else:
|
|
147
160
|
# Use default VPC if not provided
|
|
148
161
|
raise ValueError(
|
|
@@ -605,6 +618,60 @@ class AutoScalingStack(IStack):
|
|
|
605
618
|
# Scheduled action implementation would go here
|
|
606
619
|
pass
|
|
607
620
|
|
|
621
|
+
def _create_ecs_cluster_if_needed(self, asg_name: str) -> None:
|
|
622
|
+
"""Create ECS cluster if ECS configuration is detected"""
|
|
623
|
+
# Check if this is an ECS configuration by looking for ECS-related patterns
|
|
624
|
+
is_ecs_config = (
|
|
625
|
+
# Check if ECS cluster name is in user data
|
|
626
|
+
(self.user_data and "ECS_CLUSTER=" in str(self.user_data)) or
|
|
627
|
+
# Check if ECS managed policy is attached
|
|
628
|
+
any("AmazonEC2ContainerServiceforEC2Role" in policy for policy in self.asg_config.managed_policies) or
|
|
629
|
+
# Check for explicit ECS configuration
|
|
630
|
+
self.stack_config.dictionary.get("auto_scaling", {}).get("enable_ecs_cluster", False)
|
|
631
|
+
)
|
|
632
|
+
|
|
633
|
+
if not is_ecs_config:
|
|
634
|
+
logger.debug("No ECS configuration detected, skipping cluster creation")
|
|
635
|
+
return
|
|
636
|
+
|
|
637
|
+
# Extract cluster name from user data or use default
|
|
638
|
+
cluster_name = f"{self.deployment.build_resource_name('cluster')}"
|
|
639
|
+
|
|
640
|
+
# Try to extract cluster name from user data if available
|
|
641
|
+
if self.user_data:
|
|
642
|
+
user_data_str = str(self.user_data)
|
|
643
|
+
for line in user_data_str.split('\n'):
|
|
644
|
+
if 'ECS_CLUSTER=' in line:
|
|
645
|
+
cluster_name = line.split('ECS_CLUSTER=')[1].strip()
|
|
646
|
+
break
|
|
647
|
+
|
|
648
|
+
logger.info(f"Creating ECS cluster: {cluster_name}")
|
|
649
|
+
|
|
650
|
+
# Create ECS cluster
|
|
651
|
+
self.ecs_cluster = ecs.Cluster(
|
|
652
|
+
self,
|
|
653
|
+
"ECSCluster",
|
|
654
|
+
cluster_name=cluster_name,
|
|
655
|
+
vpc=self.vpc,
|
|
656
|
+
container_insights=True
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
# Export cluster name
|
|
660
|
+
cdk.CfnOutput(
|
|
661
|
+
self,
|
|
662
|
+
f"{cluster_name}-name",
|
|
663
|
+
value=self.ecs_cluster.cluster_name,
|
|
664
|
+
export_name=f"{self.deployment.build_resource_name(cluster_name)}-name",
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
# Export cluster ARN
|
|
668
|
+
cdk.CfnOutput(
|
|
669
|
+
self,
|
|
670
|
+
f"{cluster_name}-arn",
|
|
671
|
+
value=self.ecs_cluster.cluster_arn,
|
|
672
|
+
export_name=f"{self.deployment.build_resource_name(cluster_name)}-arn",
|
|
673
|
+
)
|
|
674
|
+
|
|
608
675
|
def _export_resources(self, asg_name: str) -> None:
|
|
609
676
|
"""Export stack resources to SSM and CloudFormation outputs"""
|
|
610
677
|
# Export ASG name
|
cdk_factory/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.16.
|
|
1
|
+
__version__ = "0.16.8"
|
|
@@ -2,7 +2,7 @@ cdk_factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
cdk_factory/app.py,sha256=RnX0-pwdTAPAdKJK_j13Zl8anf9zYKBwboR0KA8K8xM,10346
|
|
3
3
|
cdk_factory/cdk.json,sha256=SKZKhJ2PBpFH78j-F8S3VDYW-lf76--Q2I3ON-ZIQfw,3106
|
|
4
4
|
cdk_factory/cli.py,sha256=FGbCTS5dYCNsfp-etshzvFlGDCjC28r6rtzYbe7KoHI,6407
|
|
5
|
-
cdk_factory/version.py,sha256=
|
|
5
|
+
cdk_factory/version.py,sha256=gTaD1zTddtl6pHFsMfOrT2s2L-el8KyB3KZmgEpwcwo,23
|
|
6
6
|
cdk_factory/builds/README.md,sha256=9BBWd7bXpyKdMU_g2UljhQwrC9i5O_Tvkb6oPvndoZk,90
|
|
7
7
|
cdk_factory/commands/command_loader.py,sha256=QbLquuP_AdxtlxlDy-2IWCQ6D-7qa58aphnDPtp_uTs,3744
|
|
8
8
|
cdk_factory/configurations/base_config.py,sha256=JKjhNsy0RCUZy1s8n5D_aXXI-upR9izaLtCTfKYiV9k,9624
|
|
@@ -86,7 +86,7 @@ cdk_factory/stack_library/acm/__init__.py,sha256=4FNRLykblcKZvq_wieYwvv9N_jgrZnJ
|
|
|
86
86
|
cdk_factory/stack_library/acm/acm_stack.py,sha256=hflRXyOSjqGeJxBx87EV3Z3MJ5HEX2rnrjJ_E9wwhH8,5862
|
|
87
87
|
cdk_factory/stack_library/api_gateway/api_gateway_stack.py,sha256=l6J5uurBQqbhj9JuvQitV9PiIHS5kqa-dFWifCeA3GM,39347
|
|
88
88
|
cdk_factory/stack_library/auto_scaling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
89
|
-
cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py,sha256=
|
|
89
|
+
cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py,sha256=_OcX_J4ftm0HQdiW0u1sl14wXI60pBTjw4buo5ugWDE,28691
|
|
90
90
|
cdk_factory/stack_library/aws_lambdas/lambda_stack.py,sha256=SFbBPvvCopbyiuYtq-O5sQkFCf94Wzua6aDUXiFDSB4,26161
|
|
91
91
|
cdk_factory/stack_library/buckets/README.md,sha256=XkK3UNVtRLE7NtUvbhCOBBYUYi8hlrrSaI1s3GJVrqI,78
|
|
92
92
|
cdk_factory/stack_library/buckets/bucket_stack.py,sha256=SLoZqSffAqmeBBEVUQg54D_8Ad5UKdkjEAmKAVgAqQo,1778
|
|
@@ -134,8 +134,8 @@ cdk_factory/utilities/lambda_function_utilities.py,sha256=S1GvBsY_q2cyUiaud3HORJ
|
|
|
134
134
|
cdk_factory/utilities/os_execute.py,sha256=5Op0LY_8Y-pUm04y1k8MTpNrmQvcLmQHPQITEP7EuSU,1019
|
|
135
135
|
cdk_factory/utils/api_gateway_utilities.py,sha256=If7Xu5s_UxmuV-kL3JkXxPLBdSVUKoLtohm0IUFoiV8,4378
|
|
136
136
|
cdk_factory/workload/workload_factory.py,sha256=yDI3cRhVI5ELNDcJPLpk9UY54Uind1xQoV3spzT4z7E,6068
|
|
137
|
-
cdk_factory-0.16.
|
|
138
|
-
cdk_factory-0.16.
|
|
139
|
-
cdk_factory-0.16.
|
|
140
|
-
cdk_factory-0.16.
|
|
141
|
-
cdk_factory-0.16.
|
|
137
|
+
cdk_factory-0.16.8.dist-info/METADATA,sha256=GvGrA3k62K1D9u4WBepkbZOjOpW2IcNqHi-GFzLhoew,2451
|
|
138
|
+
cdk_factory-0.16.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
139
|
+
cdk_factory-0.16.8.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
|
|
140
|
+
cdk_factory-0.16.8.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
|
|
141
|
+
cdk_factory-0.16.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|