Skip to content

Commit d30f062

Browse files
jsoucheironclaude
andcommitted
Replace ResolvableGeneric with properly typed nested models
Applied the new ResolvableModel type to existing models that were using ResolvableGeneric for nested structures. This provides proper typing and IDE support for nested CloudFormation resource properties. Changes: Auto-generated resources (regenerated with nested types): - AWS::S3::Bucket - 50+ nested model types (CorsConfiguration, ReplicationConfiguration, LifecycleConfiguration, etc.) Manually written resources (added typed nested models): - AWS::OpenSearchService::Domain - ClusterConfig, EBSOptions, VPCOptions, AdvancedSecurityOptions, etc. - AWS::Elasticsearch::Domain - Same nested types as OpenSearch - AWS::EC2::VPCEndpoint - DnsOptions, Tags - AWS::IAM::User - Tags (using existing Tag type) Field type improvements: - TopicARN: ResolvableStr (was ResolvableGeneric) - KMSMasterKeyId: ResolvableStr (was ResolvableGeneric) - UserPoolClientId: ResolvableStr (was ResolvableGeneric) - CertificateArn: ResolvableStr (was ResolvableGeneric) - Various JSON policies: Resolvable[dict] (was ResolvableGeneric) Only PolicyDocument fields remain as ResolvableGeneric since they are intentionally arbitrary JSON (IAM policy documents). Updated tests to work with the new typed access patterns: - LogPublishingOptions and AdvancedOptions now use dict access instead of attribute access Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b64a0ea commit d30f062

19 files changed

+1421
-353
lines changed

pycfmodel/model/resources/autoscaling_auto_scaling_group.py

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
from typing import List, Literal, Optional
88

99
from pycfmodel.model.base import CustomModel
10-
from pycfmodel.model.generic import ResolvableGeneric
1110
from pycfmodel.model.resources.resource import Resource
12-
from pycfmodel.model.types import Resolvable
13-
from pycfmodel.model.types import ResolvableBool
14-
from pycfmodel.model.types import ResolvableInt
15-
from pycfmodel.model.types import ResolvableModel
16-
from pycfmodel.model.types import ResolvableStr
11+
from pycfmodel.model.types import Resolvable, ResolvableBool, ResolvableInt, ResolvableModel, ResolvableStr
1712

1813

1914
class AcceleratorCountRequest(CustomModel):
@@ -222,7 +217,7 @@ class NotificationConfiguration(CustomModel):
222217
A structure that specifies an Amazon SNS notification configuration for the ``NotificationConfigurations`` property of the [AWS::AutoScaling::AutoScalingGroup](https://docs.
223218
"""
224219

225-
TopicARN: ResolvableGeneric
220+
TopicARN: ResolvableStr
226221
NotificationTypes: Optional[Resolvable[List[ResolvableStr]]] = None
227222

228223

@@ -370,8 +365,8 @@ class InstanceRequirements(CustomModel):
370365

371366
class LaunchTemplateOverrides(CustomModel):
372367
"""
373-
Use this structure to let Amazon EC2 Auto Scaling do the following when the Auto Scaling group has a mixed instances policy:
374-
+ Override the instance type that is specified in the launch template.
368+
Use this structure to let Amazon EC2 Auto Scaling do the following when the Auto Scaling group has a mixed instances policy:
369+
+ Override the instance type that is specified in the launch template.
375370
"""
376371

377372
ImageId: Optional[ResolvableStr] = None
@@ -410,53 +405,53 @@ class MixedInstancesPolicy(CustomModel):
410405

411406
class AutoScalingAutoScalingGroupProperties(CustomModel):
412407
"""
413-
Properties for AWS::AutoScaling::AutoScalingGroup.
414-
415-
Properties:
416-
417-
- AutoScalingGroupName: The name of the Auto Scaling group. This name must be unique per Region per acco...
418-
- AvailabilityZoneDistribution: The EC2 instance capacity distribution across Availability Zones for the Auto Sc...
419-
- AvailabilityZoneImpairmentPolicy: The Availability Zone impairment policy for the Auto Scaling group.
420-
- AvailabilityZones: A list of Availability Zones where instances in the Auto Scaling group can be cr...
421-
- CapacityRebalance: Indicates whether Capacity Rebalancing is enabled. Otherwise, Capacity Rebalanci...
422-
- CapacityReservationSpecification: The capacity reservation specification for the Auto Scaling group.
423-
- Context: Reserved.
424-
- Cooldown: *Only needed if you use simple scaling policies.*
425-
The amount of time, in secon...
426-
- DefaultInstanceWarmup: The amount of time, in seconds, until a new instance is considered to have finis...
427-
- DesiredCapacity: The desired capacity is the initial capacity of the Auto Scaling group at the ti...
428-
- DesiredCapacityType: The unit of measurement for the value specified for desired capacity. Amazon EC2...
429-
- HealthCheckGracePeriod: The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checki...
430-
- HealthCheckType: A comma-separated value string of one or more health check types.
431-
The valid val...
432-
- InstanceId: The ID of the instance used to base the launch configuration on. For more inform...
433-
- InstanceLifecyclePolicy: The instance lifecycle policy for the Auto Scaling group.
434-
- InstanceMaintenancePolicy: An instance maintenance policy. For more information, see [Set instance maintena...
435-
- LaunchConfigurationName: The name of the launch configuration to use to launch instances.
436-
Required only ...
437-
- LaunchTemplate: Information used to specify the launch template and version to use to launch ins...
438-
- LifecycleHookSpecificationList: One or more lifecycle hooks to add to the Auto Scaling group before instances ar...
439-
- LoadBalancerNames: A list of Classic Load Balancers associated with this Auto Scaling group. For Ap...
440-
- MaxInstanceLifetime: The maximum amount of time, in seconds, that an instance can be in service. The ...
441-
- MaxSize: The maximum size of the group.
442-
With a mixed instances policy that uses instanc...
443-
- MetricsCollection: Enables the monitoring of group metrics of an Auto Scaling group. By default, th...
444-
- MinSize: The minimum size of the group.
445-
- MixedInstancesPolicy: An embedded object that specifies a mixed instances policy.
446-
The policy includes...
447-
- NewInstancesProtectedFromScaleIn: Indicates whether newly launched instances are protected from termination by Ama...
448-
- NotificationConfiguration:
449-
- NotificationConfigurations: Configures an Auto Scaling group to send notifications when specified events tak...
450-
- PlacementGroup: The name of the placement group into which to launch your instances. For more in...
451-
- ServiceLinkedRoleARN: The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling ...
452-
- SkipZonalShiftValidation:
453-
- Tags: One or more tags. You can tag your Auto Scaling group and propagate the tags to ...
454-
- TargetGroupARNs: The Amazon Resource Names (ARN) of the Elastic Load Balancing target groups to a...
455-
- TerminationPolicies: A policy or a list of policies that are used to select the instance to terminate...
456-
- TrafficSources: The traffic sources associated with this Auto Scaling group.
457-
- VPCZoneIdentifier: A list of subnet IDs for a virtual private cloud (VPC) where instances in the Au...
458-
459-
More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-autoscalinggroup.html)
408+
Properties for AWS::AutoScaling::AutoScalingGroup.
409+
410+
Properties:
411+
412+
- AutoScalingGroupName: The name of the Auto Scaling group. This name must be unique per Region per acco...
413+
- AvailabilityZoneDistribution: The EC2 instance capacity distribution across Availability Zones for the Auto Sc...
414+
- AvailabilityZoneImpairmentPolicy: The Availability Zone impairment policy for the Auto Scaling group.
415+
- AvailabilityZones: A list of Availability Zones where instances in the Auto Scaling group can be cr...
416+
- CapacityRebalance: Indicates whether Capacity Rebalancing is enabled. Otherwise, Capacity Rebalanci...
417+
- CapacityReservationSpecification: The capacity reservation specification for the Auto Scaling group.
418+
- Context: Reserved.
419+
- Cooldown: *Only needed if you use simple scaling policies.*
420+
The amount of time, in secon...
421+
- DefaultInstanceWarmup: The amount of time, in seconds, until a new instance is considered to have finis...
422+
- DesiredCapacity: The desired capacity is the initial capacity of the Auto Scaling group at the ti...
423+
- DesiredCapacityType: The unit of measurement for the value specified for desired capacity. Amazon EC2...
424+
- HealthCheckGracePeriod: The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checki...
425+
- HealthCheckType: A comma-separated value string of one or more health check types.
426+
The valid val...
427+
- InstanceId: The ID of the instance used to base the launch configuration on. For more inform...
428+
- InstanceLifecyclePolicy: The instance lifecycle policy for the Auto Scaling group.
429+
- InstanceMaintenancePolicy: An instance maintenance policy. For more information, see [Set instance maintena...
430+
- LaunchConfigurationName: The name of the launch configuration to use to launch instances.
431+
Required only ...
432+
- LaunchTemplate: Information used to specify the launch template and version to use to launch ins...
433+
- LifecycleHookSpecificationList: One or more lifecycle hooks to add to the Auto Scaling group before instances ar...
434+
- LoadBalancerNames: A list of Classic Load Balancers associated with this Auto Scaling group. For Ap...
435+
- MaxInstanceLifetime: The maximum amount of time, in seconds, that an instance can be in service. The ...
436+
- MaxSize: The maximum size of the group.
437+
With a mixed instances policy that uses instanc...
438+
- MetricsCollection: Enables the monitoring of group metrics of an Auto Scaling group. By default, th...
439+
- MinSize: The minimum size of the group.
440+
- MixedInstancesPolicy: An embedded object that specifies a mixed instances policy.
441+
The policy includes...
442+
- NewInstancesProtectedFromScaleIn: Indicates whether newly launched instances are protected from termination by Ama...
443+
- NotificationConfiguration:
444+
- NotificationConfigurations: Configures an Auto Scaling group to send notifications when specified events tak...
445+
- PlacementGroup: The name of the placement group into which to launch your instances. For more in...
446+
- ServiceLinkedRoleARN: The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling ...
447+
- SkipZonalShiftValidation:
448+
- Tags: One or more tags. You can tag your Auto Scaling group and propagate the tags to ...
449+
- TargetGroupARNs: The Amazon Resource Names (ARN) of the Elastic Load Balancing target groups to a...
450+
- TerminationPolicies: A policy or a list of policies that are used to select the instance to terminate...
451+
- TrafficSources: The traffic sources associated with this Auto Scaling group.
452+
- VPCZoneIdentifier: A list of subnet IDs for a virtual private cloud (VPC) where instances in the Au...
453+
454+
More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-autoscalinggroup.html)
460455
"""
461456

462457
MaxSize: ResolvableStr

pycfmodel/model/resources/cloudwatch_alarm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88

99
from pycfmodel.model.base import CustomModel
1010
from pycfmodel.model.resources.resource import Resource
11-
from pycfmodel.model.types import Resolvable
12-
from pycfmodel.model.types import ResolvableBool
13-
from pycfmodel.model.types import ResolvableInt
14-
from pycfmodel.model.types import ResolvableModel
15-
from pycfmodel.model.types import ResolvableStr
11+
from pycfmodel.model.types import Resolvable, ResolvableBool, ResolvableInt, ResolvableModel, ResolvableStr
1612

1713

1814
class Dimension(CustomModel):

pycfmodel/model/resources/dynamodb_table.py

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
from pycfmodel.model.base import CustomModel
1010
from pycfmodel.model.generic import ResolvableGeneric
1111
from pycfmodel.model.resources.resource import Resource
12-
from pycfmodel.model.types import Resolvable
13-
from pycfmodel.model.types import ResolvableBool
14-
from pycfmodel.model.types import ResolvableInt
15-
from pycfmodel.model.types import ResolvableModel
16-
from pycfmodel.model.types import ResolvableStr
12+
from pycfmodel.model.types import Resolvable, ResolvableBool, ResolvableInt, ResolvableModel, ResolvableStr
1713

1814

1915
class AttributeDefinition(CustomModel):
@@ -192,7 +188,7 @@ class SSESpecification(CustomModel):
192188
"""
193189

194190
SSEEnabled: ResolvableBool
195-
KMSMasterKeyId: Optional[ResolvableGeneric] = None
191+
KMSMasterKeyId: Optional[ResolvableStr] = None
196192
SSEType: Optional[ResolvableStr] = None
197193

198194

@@ -266,35 +262,35 @@ class GlobalSecondaryIndex(CustomModel):
266262

267263
class DynamoDBTableProperties(CustomModel):
268264
"""
269-
Properties for AWS::DynamoDB::Table.
270-
271-
Properties:
272-
273-
- AttributeDefinitions: A list of attributes that describe the key schema for the table and indexes.
274-
Th...
275-
- BillingMode: Specify how you are charged for read and write throughput and how you manage cap...
276-
- ContributorInsightsSpecification: The settings used to specify whether to enable CloudWatch Contributor Insights f...
277-
- DeletionProtectionEnabled: Determines if a table is protected from deletion. When enabled, the table cannot...
278-
- GlobalSecondaryIndexes: Global secondary indexes to be created on the table. You can create up to 20 glo...
279-
- ImportSourceSpecification: Specifies the properties of data being imported from the S3 bucket source to the...
280-
- KeySchema: Specifies the attributes that make up the primary key for the table. The attribu...
281-
- KinesisStreamSpecification: The Kinesis Data Streams configuration for the specified table.
282-
- LocalSecondaryIndexes: Local secondary indexes to be created on the table. You can create up to 5 local...
283-
- OnDemandThroughput: Sets the maximum number of read and write units for the specified on-demand tabl...
284-
- PointInTimeRecoverySpecification: The settings used to enable point in time recovery.
285-
- ProvisionedThroughput: Throughput for the specified table, which consists of values for ``ReadCapacityU...
286-
- ResourcePolicy: An AWS resource-based policy document in JSON format that will be attached to th...
287-
- SSESpecification: Specifies the settings to enable server-side encryption.
288-
- StreamSpecification: The settings for the DDB table stream, which captures changes to items stored in...
289-
- TableClass: The table class of the new table. Valid values are ``STANDARD`` and ``STANDARD_I...
290-
- TableName: A name for the table. If you don't specify a name, CFNlong generates a unique ph...
291-
- Tags: An array of key-value pairs to apply to this resource.
292-
For more information, se...
293-
- TimeToLiveSpecification: Specifies the Time to Live (TTL) settings for the table.
294-
For detailed informat...
295-
- WarmThroughput: Represents the warm throughput (in read units per second and write units per sec...
296-
297-
More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html)
265+
Properties for AWS::DynamoDB::Table.
266+
267+
Properties:
268+
269+
- AttributeDefinitions: A list of attributes that describe the key schema for the table and indexes.
270+
Th...
271+
- BillingMode: Specify how you are charged for read and write throughput and how you manage cap...
272+
- ContributorInsightsSpecification: The settings used to specify whether to enable CloudWatch Contributor Insights f...
273+
- DeletionProtectionEnabled: Determines if a table is protected from deletion. When enabled, the table cannot...
274+
- GlobalSecondaryIndexes: Global secondary indexes to be created on the table. You can create up to 20 glo...
275+
- ImportSourceSpecification: Specifies the properties of data being imported from the S3 bucket source to the...
276+
- KeySchema: Specifies the attributes that make up the primary key for the table. The attribu...
277+
- KinesisStreamSpecification: The Kinesis Data Streams configuration for the specified table.
278+
- LocalSecondaryIndexes: Local secondary indexes to be created on the table. You can create up to 5 local...
279+
- OnDemandThroughput: Sets the maximum number of read and write units for the specified on-demand tabl...
280+
- PointInTimeRecoverySpecification: The settings used to enable point in time recovery.
281+
- ProvisionedThroughput: Throughput for the specified table, which consists of values for ``ReadCapacityU...
282+
- ResourcePolicy: An AWS resource-based policy document in JSON format that will be attached to th...
283+
- SSESpecification: Specifies the settings to enable server-side encryption.
284+
- StreamSpecification: The settings for the DDB table stream, which captures changes to items stored in...
285+
- TableClass: The table class of the new table. Valid values are ``STANDARD`` and ``STANDARD_I...
286+
- TableName: A name for the table. If you don't specify a name, CFNlong generates a unique ph...
287+
- Tags: An array of key-value pairs to apply to this resource.
288+
For more information, se...
289+
- TimeToLiveSpecification: Specifies the Time to Live (TTL) settings for the table.
290+
For detailed informat...
291+
- WarmThroughput: Represents the warm throughput (in read units per second and write units per sec...
292+
293+
More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html)
298294
"""
299295

300296
KeySchema: Resolvable[List[KeySchema]]

pycfmodel/model/resources/ec2_vpc_endpoint_policy.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
from typing import List, Literal, Optional
22

33
from pycfmodel.model.base import CustomModel
4-
from pycfmodel.model.generic import ResolvableGeneric
54
from pycfmodel.model.resources.properties.policy_document import PolicyDocument as resource_policy_document
5+
from pycfmodel.model.resources.properties.tag import Tag
66
from pycfmodel.model.resources.resource import Resource
7-
from pycfmodel.model.types import Resolvable, ResolvableBool, ResolvableStr
7+
from pycfmodel.model.types import Resolvable, ResolvableBool, ResolvableModel, ResolvableStr
88
from pycfmodel.model.utils import OptionallyNamedPolicyDocument
99

1010

11+
class DnsOptions(CustomModel):
12+
"""DNS options for VPC endpoint."""
13+
14+
DnsRecordIpType: Optional[ResolvableStr] = None
15+
PrivateDnsOnlyForInboundResolverEndpoint: Optional[ResolvableBool] = None
16+
17+
18+
ResolvableDnsOptions = ResolvableModel(DnsOptions)
19+
20+
1121
class EC2VpcEndpointPolicyProperties(CustomModel):
1222
"""
1323
Properties:
@@ -30,7 +40,7 @@ class EC2VpcEndpointPolicyProperties(CustomModel):
3040
More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html)
3141
"""
3242

33-
DnsOptions: Optional[ResolvableGeneric] = None
43+
DnsOptions: Optional[ResolvableDnsOptions] = None
3444
IpAddressType: Optional[ResolvableStr] = None
3545
PolicyDocument: Optional[Resolvable[resource_policy_document]] = None
3646
PrivateDnsEnabled: Optional[ResolvableBool] = None
@@ -41,7 +51,7 @@ class EC2VpcEndpointPolicyProperties(CustomModel):
4151
ServiceNetworkArn: Optional[ResolvableStr] = None
4252
ServiceRegion: Optional[ResolvableStr] = None
4353
SubnetIds: Optional[Resolvable[List[ResolvableStr]]] = None
44-
Tags: Optional[Resolvable[List[ResolvableGeneric]]] = None
54+
Tags: Optional[Resolvable[List[Tag]]] = None
4555
VpcEndpointType: Optional[ResolvableStr] = None
4656
VpcId: ResolvableStr
4757

pycfmodel/model/resources/elbv2_listener.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
from typing import List, Literal, Optional
88

99
from pycfmodel.model.base import CustomModel
10-
from pycfmodel.model.generic import ResolvableGeneric
1110
from pycfmodel.model.resources.resource import Resource
12-
from pycfmodel.model.types import Resolvable
13-
from pycfmodel.model.types import ResolvableBool
14-
from pycfmodel.model.types import ResolvableInt
15-
from pycfmodel.model.types import ResolvableModel
16-
from pycfmodel.model.types import ResolvableStr
11+
from pycfmodel.model.types import Resolvable, ResolvableBool, ResolvableInt, ResolvableModel, ResolvableStr
1712

1813

1914
class AuthenticateCognitoConfig(CustomModel):
@@ -22,9 +17,9 @@ class AuthenticateCognitoConfig(CustomModel):
2217
"""
2318

2419
UserPoolArn: ResolvableStr
25-
UserPoolClientId: ResolvableGeneric
20+
UserPoolClientId: ResolvableStr
2621
UserPoolDomain: ResolvableStr
27-
AuthenticationRequestExtraParams: Optional[ResolvableGeneric] = None
22+
AuthenticationRequestExtraParams: Optional[Resolvable[dict]] = None
2823
OnUnauthenticatedRequest: Optional[ResolvableStr] = None
2924
Scope: Optional[ResolvableStr] = None
3025
SessionCookieName: Optional[ResolvableStr] = None
@@ -44,7 +39,7 @@ class AuthenticateOidcConfig(CustomModel):
4439
Issuer: ResolvableStr
4540
TokenEndpoint: ResolvableStr
4641
UserInfoEndpoint: ResolvableStr
47-
AuthenticationRequestExtraParams: Optional[ResolvableGeneric] = None
42+
AuthenticationRequestExtraParams: Optional[Resolvable[dict]] = None
4843
ClientSecret: Optional[ResolvableStr] = None
4944
OnUnauthenticatedRequest: Optional[ResolvableStr] = None
5045
Scope: Optional[ResolvableStr] = None
@@ -61,7 +56,7 @@ class Certificate(CustomModel):
6156
Specifies an SSL server certificate to use as the default certificate for a secure listener.
6257
"""
6358

64-
CertificateArn: Optional[ResolvableGeneric] = None
59+
CertificateArn: Optional[ResolvableStr] = None
6560

6661

6762
ResolvableCertificate = ResolvableModel(Certificate)
@@ -94,9 +89,7 @@ class JwtValidationActionAdditionalClaim(CustomModel):
9489

9590

9691
class JwtValidationConfig(CustomModel):
97-
"""
98-
99-
"""
92+
""" """
10093

10194
Issuer: ResolvableStr
10295
JwksEndpoint: ResolvableStr

0 commit comments

Comments
 (0)