|
12 | 12 | _build_lambda_function_image_config_property, |
13 | 13 | _check_image_config_value, |
14 | 14 | _get_cors_v2_api, |
| 15 | + _build_capacity_provider_config_property, |
15 | 16 | ) |
16 | 17 | from samcli.hook_packages.terraform.hooks.prepare.constants import REMOTE_DUMMY_VALUE |
17 | 18 |
|
@@ -248,3 +249,90 @@ def test_get_json_body_invalid(self, invalid_value): |
248 | 249 | def test_get_cors_v2_api(self, tf_properties, expected): |
249 | 250 | response = _get_cors_v2_api(tf_properties, Mock()) |
250 | 251 | self.assertEqual(response, expected) |
| 252 | + |
| 253 | + @parameterized.expand( |
| 254 | + [ |
| 255 | + ( |
| 256 | + # Full capacity provider config with all optional fields |
| 257 | + { |
| 258 | + "capacity_provider_config": [ |
| 259 | + { |
| 260 | + "lambda_managed_instances_capacity_provider_config": [ |
| 261 | + { |
| 262 | + "capacity_provider_arn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test", |
| 263 | + "per_execution_environment_max_concurrency": 10, |
| 264 | + "execution_environment_memory_gib_per_vcpu": 2.0, |
| 265 | + } |
| 266 | + ] |
| 267 | + } |
| 268 | + ] |
| 269 | + }, |
| 270 | + { |
| 271 | + "LambdaManagedInstancesCapacityProviderConfig": { |
| 272 | + "CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test", |
| 273 | + "PerExecutionEnvironmentMaxConcurrency": 10, |
| 274 | + "ExecutionEnvironmentMemoryGiBPerVCpu": 2.0, |
| 275 | + } |
| 276 | + }, |
| 277 | + ), |
| 278 | + ( |
| 279 | + # Minimal capacity provider config with only required field |
| 280 | + { |
| 281 | + "capacity_provider_config": [ |
| 282 | + { |
| 283 | + "lambda_managed_instances_capacity_provider_config": [ |
| 284 | + { |
| 285 | + "capacity_provider_arn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test", |
| 286 | + } |
| 287 | + ] |
| 288 | + } |
| 289 | + ] |
| 290 | + }, |
| 291 | + { |
| 292 | + "LambdaManagedInstancesCapacityProviderConfig": { |
| 293 | + "CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test", |
| 294 | + } |
| 295 | + }, |
| 296 | + ), |
| 297 | + ( |
| 298 | + # Capacity provider config with only max concurrency |
| 299 | + { |
| 300 | + "capacity_provider_config": [ |
| 301 | + { |
| 302 | + "lambda_managed_instances_capacity_provider_config": [ |
| 303 | + { |
| 304 | + "capacity_provider_arn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test", |
| 305 | + "per_execution_environment_max_concurrency": 100, |
| 306 | + } |
| 307 | + ] |
| 308 | + } |
| 309 | + ] |
| 310 | + }, |
| 311 | + { |
| 312 | + "LambdaManagedInstancesCapacityProviderConfig": { |
| 313 | + "CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test", |
| 314 | + "PerExecutionEnvironmentMaxConcurrency": 100, |
| 315 | + } |
| 316 | + }, |
| 317 | + ), |
| 318 | + # No capacity provider config |
| 319 | + ({}, None), |
| 320 | + ({"capacity_provider_config": None}, None), |
| 321 | + ({"capacity_provider_config": []}, None), |
| 322 | + # Empty nested config |
| 323 | + ({"capacity_provider_config": [{}]}, None), |
| 324 | + ( |
| 325 | + {"capacity_provider_config": [{"lambda_managed_instances_capacity_provider_config": None}]}, |
| 326 | + None, |
| 327 | + ), |
| 328 | + ( |
| 329 | + {"capacity_provider_config": [{"lambda_managed_instances_capacity_provider_config": []}]}, |
| 330 | + None, |
| 331 | + ), |
| 332 | + ] |
| 333 | + ) |
| 334 | + def test_build_capacity_provider_config_property(self, tf_properties, expected): |
| 335 | + """Test building CapacityProviderConfig property from Terraform properties""" |
| 336 | + resource_mock = Mock() |
| 337 | + result = _build_capacity_provider_config_property(tf_properties, resource_mock) |
| 338 | + self.assertEqual(result, expected) |
0 commit comments