cdk-factory 0.16.4__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", {})
@@ -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
cdk_factory/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.16.4"
1
+ __version__ = "0.16.5"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdk_factory
3
- Version: 0.16.4
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=v0NTmSx9E_r4wWkO-UdvuH1fI3XtgjoFi5IbuPS9pjY,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
@@ -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
@@ -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.4.dist-info/METADATA,sha256=XcD0gE5ROxuXm3YB12qeIZZD7DytTLgnXIG2USGSr4Q,2451
136
- cdk_factory-0.16.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
137
- cdk_factory-0.16.4.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
138
- cdk_factory-0.16.4.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
139
- cdk_factory-0.16.4.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,,