cdk-factory 0.16.3__py3-none-any.whl → 0.16.5__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.

@@ -175,3 +175,8 @@ class AutoScalingConfig(EnhancedBaseConfig):
175
175
  def key_name(self) -> Optional[str]:
176
176
  """EC2 key pair name for SSH access"""
177
177
  return self.__config.get("key_name")
178
+
179
+ @property
180
+ def ssm_imports(self) -> Dict[str, Any]:
181
+ """SSM imports for the Auto Scaling Group"""
182
+ return self.__config.get("ssm", {}).get("imports", {})
@@ -155,6 +155,12 @@ class RdsConfig(EnhancedBaseConfig):
155
155
  """Allocated storage in GB"""
156
156
  # Ensure we return an integer
157
157
  return int(self.__config.get("allocated_storage", 20))
158
+
159
+ @property
160
+ def max_allocated_storage(self) -> Optional[int]:
161
+ """Maximum storage for auto-scaling in GB (enables storage auto-scaling if set)"""
162
+ max_storage = self.__config.get("max_allocated_storage")
163
+ return int(max_storage) if max_storage is not None else None
158
164
 
159
165
  @property
160
166
  def storage_encrypted(self) -> bool:
@@ -180,6 +186,11 @@ class RdsConfig(EnhancedBaseConfig):
180
186
  def enable_performance_insights(self) -> bool:
181
187
  """Whether to enable Performance Insights"""
182
188
  return self.__config.get("enable_performance_insights", True)
189
+
190
+ @property
191
+ def allow_major_version_upgrade(self) -> bool:
192
+ """Whether to allow major version upgrades"""
193
+ return self.__config.get("allow_major_version_upgrade", False)
183
194
 
184
195
  @property
185
196
  def subnet_group_name(self) -> str:
@@ -47,6 +47,8 @@ class AutoScalingStack(IStack, EnhancedSsmParameterMixin):
47
47
  self.instance_role = None
48
48
  self.user_data = None
49
49
  self._vpc = None
50
+ # SSM imported values
51
+ self.ssm_imported_values: Dict[str, str] = {}
50
52
 
51
53
  def build(
52
54
  self,
@@ -73,6 +75,9 @@ class AutoScalingStack(IStack, EnhancedSsmParameterMixin):
73
75
  )
74
76
  asg_name = deployment.build_resource_name(self.asg_config.name)
75
77
 
78
+ # Process SSM imports
79
+ self._process_ssm_imports()
80
+
76
81
  # Get VPC and security groups
77
82
  self.security_groups = self._get_security_groups()
78
83
 
@@ -97,11 +102,28 @@ class AutoScalingStack(IStack, EnhancedSsmParameterMixin):
97
102
  @property
98
103
  def vpc(self) -> ec2.IVpc:
99
104
  """Get the VPC for the Auto Scaling Group"""
100
- # Assuming VPC is provided by the workload
101
-
102
105
  if self._vpc:
103
106
  return self._vpc
104
107
 
108
+ # Check SSM imported values first (tokens from SSM parameters)
109
+ if "vpc_id" in self.ssm_imported_values:
110
+ vpc_id = self.ssm_imported_values["vpc_id"]
111
+
112
+ # Build VPC attributes
113
+ vpc_attrs = {
114
+ "vpc_id": vpc_id,
115
+ "availability_zones": ["us-east-1a", "us-east-1b"],
116
+ }
117
+
118
+ # If we have subnet_ids from SSM, provide dummy subnets
119
+ # The actual subnets will be set via CloudFormation escape hatch
120
+ if "subnet_ids" in self.ssm_imported_values:
121
+ # Provide dummy subnet IDs - these will be overridden by the escape hatch
122
+ # We need at least one dummy subnet per AZ to satisfy CDK's validation
123
+ vpc_attrs["public_subnet_ids"] = ["subnet-dummy1", "subnet-dummy2"]
124
+
125
+ # Use from_vpc_attributes() for SSM tokens
126
+ self._vpc = ec2.Vpc.from_vpc_attributes(self, "VPC", **vpc_attrs)
105
127
  elif self.asg_config.vpc_id:
106
128
  self._vpc = ec2.Vpc.from_lookup(self, "VPC", vpc_id=self.asg_config.vpc_id)
107
129
  elif self.workload.vpc_id:
@@ -120,18 +142,13 @@ class AutoScalingStack(IStack, EnhancedSsmParameterMixin):
120
142
  """Get target group ARNs from SSM imports"""
121
143
  target_group_arns = []
122
144
 
123
- # Import target group ARNs using the SSM import pattern
124
- imported_values = self.import_resources_from_ssm(
125
- scope=self,
126
- config=self.asg_config,
127
- resource_name=self.asg_config.name,
128
- resource_type="auto-scaling",
129
- )
130
-
131
- # Look for target group ARN imports
132
- for key, value in imported_values.items():
133
- if "target_group" in key and "arn" in key:
134
- target_group_arns.append(value)
145
+ # Check if we have SSM imports for target groups
146
+ if "target_group_arns" in self.ssm_imported_values:
147
+ imported_tg_arns = self.ssm_imported_values["target_group_arns"]
148
+ if isinstance(imported_tg_arns, list):
149
+ target_group_arns.extend(imported_tg_arns)
150
+ else:
151
+ target_group_arns.append(imported_tg_arns)
135
152
 
136
153
  # see if we have any directly defined in the config
137
154
  if self.asg_config.target_group_arns:
@@ -562,11 +579,47 @@ class AutoScalingStack(IStack, EnhancedSsmParameterMixin):
562
579
  export_name=f"{self.deployment.build_resource_name(asg_name)}-launch-template-id",
563
580
  )
564
581
 
565
- # Instance Role ARN
566
- if self.instance_role:
567
- cdk.CfnOutput(
568
- self,
569
- f"{asg_name}-instance-role-arn",
570
- value=self.instance_role.role_arn,
571
- export_name=f"{self.deployment.build_resource_name(asg_name)}-instance-role-arn",
572
- )
582
+ def _process_ssm_imports(self) -> None:
583
+ """
584
+ Process SSM imports from configuration.
585
+
586
+ This method handles importing SSM parameters that are specified in the
587
+ auto_scaling configuration under the 'ssm.imports' section.
588
+ """
589
+ logger.info(f"Processing {len(self.asg_config.ssm_imports)} SSM imports for Auto Scaling Group")
590
+
591
+ for param_key, param_value in self.asg_config.ssm_imports.items():
592
+ try:
593
+ if isinstance(param_value, list):
594
+ # Handle list imports (like security_group_ids)
595
+ imported_list = []
596
+ for item in param_value:
597
+ param_path = item
598
+ if not param_path.startswith('/'):
599
+ param_path = f"/{self.deployment.environment}/{self.deployment.workload_name}/{item}"
600
+
601
+ construct_id = f"ssm-import-{param_key}-{hash(param_path) % 10000}"
602
+ param = ssm.StringParameter.from_string_parameter_name(
603
+ self, construct_id, param_path
604
+ )
605
+ imported_list.append(param.string_value)
606
+
607
+ self.ssm_imported_values[param_key] = imported_list
608
+ logger.info(f"Imported SSM parameter list: {param_key} with {len(imported_list)} items")
609
+ else:
610
+ # Handle string values
611
+ param_path = param_value
612
+ if not param_path.startswith('/'):
613
+ param_path = f"/{self.deployment.environment}/{self.deployment.workload_name}/{param_path}"
614
+
615
+ construct_id = f"ssm-import-{param_key}-{hash(param_path) % 10000}"
616
+ param = ssm.StringParameter.from_string_parameter_name(
617
+ self, construct_id, param_path
618
+ )
619
+
620
+ self.ssm_imported_values[param_key] = param.string_value
621
+ logger.info(f"Imported SSM parameter: {param_key} from {param_path}")
622
+
623
+ except Exception as e:
624
+ logger.error(f"Failed to import SSM parameter {param_key}: {e}")
625
+ raise
@@ -244,9 +244,18 @@ class RdsStack(IStack, EnhancedSsmParameterMixin):
244
244
  "backup_retention": Duration.days(self.rds_config.backup_retention),
245
245
  "cloudwatch_logs_exports": self.rds_config.cloudwatch_logs_exports,
246
246
  "enable_performance_insights": self.rds_config.enable_performance_insights,
247
+ "allow_major_version_upgrade": self.rds_config.allow_major_version_upgrade,
247
248
  "removal_policy": removal_policy,
248
249
  }
249
250
 
251
+ # Add storage auto-scaling if max_allocated_storage is configured
252
+ if self.rds_config.max_allocated_storage:
253
+ db_props["max_allocated_storage"] = self.rds_config.max_allocated_storage
254
+ logger.info(
255
+ f"Storage auto-scaling enabled: {self.rds_config.allocated_storage}GB "
256
+ f"-> {self.rds_config.max_allocated_storage}GB"
257
+ )
258
+
250
259
  # Use either subnet group or vpc_subnets depending on what's available
251
260
  if db_subnet_group:
252
261
  db_props["subnet_group"] = rds.SubnetGroup.from_subnet_group_name(
cdk_factory/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.16.3"
1
+ __version__ = "0.16.5"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdk_factory
3
- Version: 0.16.3
3
+ Version: 0.16.5
4
4
  Summary: CDK Factory. A QuickStarter and best practices setup for CDK projects
5
5
  Author-email: Eric Wilson <eric.wilson@geekcafe.com>
6
6
  License: MIT License
@@ -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=VI_bTBU6ZbRZpVhA2ix956hkRwHW57V59GEZJkhU-vc,23
5
+ cdk_factory/version.py,sha256=r0anPjT1FU7ZF59Wu8yrTS7JfVcf5Cbwqs29-uSLGyo,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
@@ -21,7 +21,7 @@ cdk_factory/configurations/resources/_resources.py,sha256=tnXGn4kEC0JPQaTWB3QpAZ
21
21
  cdk_factory/configurations/resources/acm.py,sha256=2TY8VfoVxnDGVdqpd8v8TvQebLYBZ7J9HfaAhMvpRFE,2740
22
22
  cdk_factory/configurations/resources/api_gateway.py,sha256=-k4hMGszIdQLb5DGmWBIPy49YGutp8zczafRh-Vob0I,4904
23
23
  cdk_factory/configurations/resources/apigateway_route_config.py,sha256=6ytn_nwKwlfpBtHL5sV6gxMpgAJ3p6QFGumMoW4CTHM,2351
24
- cdk_factory/configurations/resources/auto_scaling.py,sha256=rY-lZBZIS3bq0Lzf4IGbmMxhgiD_tknjjTZhh4Z6yFI,5922
24
+ cdk_factory/configurations/resources/auto_scaling.py,sha256=-3CSmhWhkU9RkQb6yELoK_OES2UqLNQDxtVPFpZNCsA,6098
25
25
  cdk_factory/configurations/resources/cloudfront.py,sha256=oCWa9I8hbXVu114t-IO5frW6hgvPoovFgDbipDqFoGs,3848
26
26
  cdk_factory/configurations/resources/cloudwatch_widget.py,sha256=EdEQSXUkDtoY_Mg_cJBWo1Hp84jSiK7U9tsd3k1VhKI,1271
27
27
  cdk_factory/configurations/resources/code_artifact.py,sha256=P2X2i6NEcePitEf2wkN6lFTjIbXasn0uzrlPOT0tEac,3253
@@ -39,7 +39,7 @@ cdk_factory/configurations/resources/lambda_layers.py,sha256=gVeP_-LC3Eq0lkPaG_J
39
39
  cdk_factory/configurations/resources/lambda_triggers.py,sha256=MD7cdMNKEulNBhtMLIFnWJuJ5R-yyIqa0LHUgbSQerA,834
40
40
  cdk_factory/configurations/resources/load_balancer.py,sha256=CNmE4uqOgyI0amZy2EDvDF5_Feiw5kcCmbkY1HI5u_s,5911
41
41
  cdk_factory/configurations/resources/monitoring.py,sha256=zsfDMa7yph33Ql8iP7lIqqLAyixh-Mesi0imtZJFdcE,2310
42
- cdk_factory/configurations/resources/rds.py,sha256=ZPNQhsOOxE_cg9CeFIhjKLyQYzMURg_3wb8Ckc2tAtw,15724
42
+ cdk_factory/configurations/resources/rds.py,sha256=_nMPOC1Rinc-nbVJzl__3vodBQc4sCeVPY_NfjWZFoA,16217
43
43
  cdk_factory/configurations/resources/resource_mapping.py,sha256=cwv3n63RJ6E59ErsmSTdkW4i-g8huhHtKI0ExbRhJxA,2182
44
44
  cdk_factory/configurations/resources/resource_naming.py,sha256=VE9S2cpzp11qqPL2z1sX79wXH0o1SntO2OG74nEmWC8,5508
45
45
  cdk_factory/configurations/resources/resource_types.py,sha256=1WQHyDoErb-M-tETZZzyLDtbq_jdC85-I403dM48pgE,2317
@@ -84,7 +84,7 @@ cdk_factory/stack_library/acm/__init__.py,sha256=4FNRLykblcKZvq_wieYwvv9N_jgrZnJ
84
84
  cdk_factory/stack_library/acm/acm_stack.py,sha256=hflRXyOSjqGeJxBx87EV3Z3MJ5HEX2rnrjJ_E9wwhH8,5862
85
85
  cdk_factory/stack_library/api_gateway/api_gateway_stack.py,sha256=l6J5uurBQqbhj9JuvQitV9PiIHS5kqa-dFWifCeA3GM,39347
86
86
  cdk_factory/stack_library/auto_scaling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
- cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py,sha256=XPTPGF-W8ARvzW8UYd4yPJ7xFUw-2BrdxQOYk9I-v3g,23490
87
+ cdk_factory/stack_library/auto_scaling/auto_scaling_stack.py,sha256=0q3wF7b6JX8yQiPQWnlII05_pwJif63ijvaQS5rzqyI,26451
88
88
  cdk_factory/stack_library/aws_lambdas/lambda_stack.py,sha256=SFbBPvvCopbyiuYtq-O5sQkFCf94Wzua6aDUXiFDSB4,26161
89
89
  cdk_factory/stack_library/buckets/README.md,sha256=XkK3UNVtRLE7NtUvbhCOBBYUYi8hlrrSaI1s3GJVrqI,78
90
90
  cdk_factory/stack_library/buckets/bucket_stack.py,sha256=SLoZqSffAqmeBBEVUQg54D_8Ad5UKdkjEAmKAVgAqQo,1778
@@ -104,7 +104,7 @@ cdk_factory/stack_library/load_balancer/load_balancer_stack.py,sha256=Mw8r3919-g
104
104
  cdk_factory/stack_library/monitoring/__init__.py,sha256=k1G_KDx47Aw0UugaL99PN_TKlyLK4nkJVApCaAK7GJg,153
105
105
  cdk_factory/stack_library/monitoring/monitoring_stack.py,sha256=N_1YvEXE7fboH_S3kv_dSKZsufxMuPdFMjGzlNFpuSo,19283
106
106
  cdk_factory/stack_library/rds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
- cdk_factory/stack_library/rds/rds_stack.py,sha256=otT4qCl_GExUgl4xHWrcGksnJeg2Ps6luZxbpCXQYcI,15048
107
+ cdk_factory/stack_library/rds/rds_stack.py,sha256=ohBNpXJKkrj1rmfFPaBuZKcYQh2j_DB_tJ2A3jm6M0s,15546
108
108
  cdk_factory/stack_library/route53/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
109
109
  cdk_factory/stack_library/route53/route53_stack.py,sha256=hW-iKXdw862cYg4o-OL7X4CnKxzXdrzPgfQ8KdxTMnE,8403
110
110
  cdk_factory/stack_library/rum/__init__.py,sha256=gUrWQdzd4rZ2J0YzAQC8PsEGAS7QgyYjB2ZCUKWasy4,90
@@ -132,8 +132,8 @@ cdk_factory/utilities/lambda_function_utilities.py,sha256=S1GvBsY_q2cyUiaud3HORJ
132
132
  cdk_factory/utilities/os_execute.py,sha256=5Op0LY_8Y-pUm04y1k8MTpNrmQvcLmQHPQITEP7EuSU,1019
133
133
  cdk_factory/utils/api_gateway_utilities.py,sha256=If7Xu5s_UxmuV-kL3JkXxPLBdSVUKoLtohm0IUFoiV8,4378
134
134
  cdk_factory/workload/workload_factory.py,sha256=yDI3cRhVI5ELNDcJPLpk9UY54Uind1xQoV3spzT4z7E,6068
135
- cdk_factory-0.16.3.dist-info/METADATA,sha256=ZcxvwT_8nNbqBmdht6NiCo7XSgmh6cFLZPt51K3UU7w,2451
136
- cdk_factory-0.16.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
137
- cdk_factory-0.16.3.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
138
- cdk_factory-0.16.3.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
139
- cdk_factory-0.16.3.dist-info/RECORD,,
135
+ cdk_factory-0.16.5.dist-info/METADATA,sha256=D2vXNb4pXKyPu01N3lbLxoY_hHCmL_SdzCQx0uUppyE,2451
136
+ cdk_factory-0.16.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
137
+ cdk_factory-0.16.5.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
138
+ cdk_factory-0.16.5.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
139
+ cdk_factory-0.16.5.dist-info/RECORD,,