pycfmodel 1.0.1__tar.gz → 1.1.0__tar.gz

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.
Files changed (74) hide show
  1. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/PKG-INFO +1 -1
  2. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/cloudformation_actions.py +57 -0
  3. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/generic_resource.py +15 -3
  4. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/statement.py +1 -1
  5. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/PKG-INFO +1 -1
  6. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/setup.py +1 -1
  7. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_generic_resoure.py +36 -0
  8. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/LICENSE.md +0 -0
  9. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/README.md +0 -0
  10. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/__init__.py +0 -0
  11. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/action_expander.py +0 -0
  12. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/constants.py +0 -0
  13. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/base.py +0 -0
  14. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/cf_model.py +0 -0
  15. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/generic.py +0 -0
  16. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/parameter.py +0 -0
  17. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/ec2_vpc_endpoint_policy.py +0 -0
  18. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/es_domain.py +0 -0
  19. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_group.py +0 -0
  20. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_managed_policy.py +0 -0
  21. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_policy.py +0 -0
  22. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_role.py +0 -0
  23. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_user.py +0 -0
  24. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/kms_key.py +0 -0
  25. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/opensearch_domain.py +0 -0
  26. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/policy.py +0 -0
  27. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/policy_document.py +0 -0
  28. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/property.py +0 -0
  29. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/security_group_egress_prop.py +0 -0
  30. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/security_group_ingress_prop.py +0 -0
  31. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/statement_condition.py +0 -0
  32. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/tag.py +0 -0
  33. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/types.py +0 -0
  34. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/resource.py +0 -0
  35. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/s3_bucket.py +0 -0
  36. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/s3_bucket_policy.py +0 -0
  37. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/security_group.py +0 -0
  38. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/security_group_egress.py +0 -0
  39. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/security_group_ingress.py +0 -0
  40. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/sns_topic_policy.py +0 -0
  41. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/sqs_queue_policy.py +0 -0
  42. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/types.py +0 -0
  43. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/types.py +0 -0
  44. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/utils.py +0 -0
  45. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/resolver.py +0 -0
  46. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/utils.py +0 -0
  47. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/SOURCES.txt +0 -0
  48. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/dependency_links.txt +0 -0
  49. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/requires.txt +0 -0
  50. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/top_level.txt +0 -0
  51. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pyproject.toml +0 -0
  52. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/scripts/generate_cloudformation_actions_file.py +0 -0
  53. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/setup.cfg +0 -0
  54. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_policy_document.py +0 -0
  55. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_principal.py +0 -0
  56. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_statement.py +0 -0
  57. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_statement_condition.py +0 -0
  58. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_ec2_vpc_endpoint_policy.py +0 -0
  59. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_es_domain.py +0 -0
  60. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_group.py +0 -0
  61. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_managed_policy.py +0 -0
  62. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_policy.py +0 -0
  63. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_role.py +0 -0
  64. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_user.py +0 -0
  65. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_kms_key.py +0 -0
  66. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_opensearch_domain.py +0 -0
  67. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_rds_security_groups.py +0 -0
  68. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_s3_bucket.py +0 -0
  69. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_s3_bucket_policy.py +0 -0
  70. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_security_group.py +0 -0
  71. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_security_group_egress.py +0 -0
  72. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_security_group_ingress.py +0 -0
  73. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_sns_topic_policy.py +0 -0
  74. {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_sqs_queue_policy.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycfmodel
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: A python model for CloudFormation scripts
5
5
  Home-page: https://github.com/Skyscanner/pycfmodel
6
6
  Author: Skyscanner Product Security
@@ -9261,6 +9261,63 @@ CLOUDFORMATION_ACTIONS = [
9261
9261
  "iotjobsdata:GetPendingJobExecutions",
9262
9262
  "iotjobsdata:StartNextPendingJobExecution",
9263
9263
  "iotjobsdata:UpdateJobExecution",
9264
+ "iotmanagedintegrations:CreateCredentialLocker",
9265
+ "iotmanagedintegrations:CreateDestination",
9266
+ "iotmanagedintegrations:CreateEventLogConfiguration",
9267
+ "iotmanagedintegrations:CreateManagedThing",
9268
+ "iotmanagedintegrations:CreateNotificationConfiguration",
9269
+ "iotmanagedintegrations:CreateOtaTask",
9270
+ "iotmanagedintegrations:CreateOtaTaskConfiguration",
9271
+ "iotmanagedintegrations:CreateProvisioningProfile",
9272
+ "iotmanagedintegrations:DeleteCredentialLocker",
9273
+ "iotmanagedintegrations:DeleteDestination",
9274
+ "iotmanagedintegrations:DeleteEventLogConfiguration",
9275
+ "iotmanagedintegrations:DeleteManagedThing",
9276
+ "iotmanagedintegrations:DeleteNotificationConfiguration",
9277
+ "iotmanagedintegrations:DeleteOtaTask",
9278
+ "iotmanagedintegrations:DeleteOtaTaskConfiguration",
9279
+ "iotmanagedintegrations:DeleteProvisioningProfile",
9280
+ "iotmanagedintegrations:GetCredentialLocker",
9281
+ "iotmanagedintegrations:GetCustomEndpoint",
9282
+ "iotmanagedintegrations:GetDefaultEncryptionConfiguration",
9283
+ "iotmanagedintegrations:GetDestination",
9284
+ "iotmanagedintegrations:GetDeviceDiscovery",
9285
+ "iotmanagedintegrations:GetEventLogConfiguration",
9286
+ "iotmanagedintegrations:GetHubConfiguration",
9287
+ "iotmanagedintegrations:GetManagedThing",
9288
+ "iotmanagedintegrations:GetManagedThingCapabilities",
9289
+ "iotmanagedintegrations:GetManagedThingConnectivityData",
9290
+ "iotmanagedintegrations:GetManagedThingMetaData",
9291
+ "iotmanagedintegrations:GetManagedThingState",
9292
+ "iotmanagedintegrations:GetNotificationConfiguration",
9293
+ "iotmanagedintegrations:GetOtaTask",
9294
+ "iotmanagedintegrations:GetOtaTaskConfiguration",
9295
+ "iotmanagedintegrations:GetProvisioningProfile",
9296
+ "iotmanagedintegrations:GetRuntimeLogConfiguration",
9297
+ "iotmanagedintegrations:GetSchemaVersion",
9298
+ "iotmanagedintegrations:ListCredentialLockers",
9299
+ "iotmanagedintegrations:ListDestinations",
9300
+ "iotmanagedintegrations:ListEventLogConfigurations",
9301
+ "iotmanagedintegrations:ListManagedThingSchemas",
9302
+ "iotmanagedintegrations:ListManagedThings",
9303
+ "iotmanagedintegrations:ListNotificationConfigurations",
9304
+ "iotmanagedintegrations:ListOtaTaskConfigurations",
9305
+ "iotmanagedintegrations:ListOtaTaskExecutions",
9306
+ "iotmanagedintegrations:ListOtaTasks",
9307
+ "iotmanagedintegrations:ListProvisioningProfiles",
9308
+ "iotmanagedintegrations:ListSchemaVersions",
9309
+ "iotmanagedintegrations:PutDefaultEncryptionConfiguration",
9310
+ "iotmanagedintegrations:PutHubConfiguration",
9311
+ "iotmanagedintegrations:PutRuntimeLogConfiguration",
9312
+ "iotmanagedintegrations:RegisterCustomEndpoint",
9313
+ "iotmanagedintegrations:ResetRuntimeLogConfiguration",
9314
+ "iotmanagedintegrations:SendManagedThingCommand",
9315
+ "iotmanagedintegrations:StartDeviceDiscovery",
9316
+ "iotmanagedintegrations:UpdateDestination",
9317
+ "iotmanagedintegrations:UpdateEventLogConfiguration",
9318
+ "iotmanagedintegrations:UpdateManagedThing",
9319
+ "iotmanagedintegrations:UpdateNotificationConfiguration",
9320
+ "iotmanagedintegrations:UpdateOtaTask",
9264
9321
  "iotsitewise:AssociateAssets",
9265
9322
  "iotsitewise:AssociateTimeSeriesToAssetProperty",
9266
9323
  "iotsitewise:BatchAssociateProjectAssets",
@@ -1,18 +1,28 @@
1
- from typing import Optional
1
+ import logging
2
+ from typing import ClassVar, Optional
2
3
 
3
4
  from pydantic import ConfigDict, field_validator
4
5
 
5
6
  from pycfmodel.model.generic import Generic
6
7
  from pycfmodel.model.resources.resource import Resource
7
8
 
9
+ logger = logging.getLogger(__name__)
10
+
8
11
 
9
12
  class GenericResource(Resource):
10
- """This class is used for all resource types that don't have a dedicated class."""
13
+ """
14
+ This class is used for all resource types that don't have a dedicated class.
15
+ Setting _strict to False will allow creation of GenericResources that have an explicit model class,
16
+ this is very useful to work around incomplete model definitions or things that are not implemented yet
17
+ like AWS:NoValue. _strict defaults to True. In that case you can't instantiate GenericResources when
18
+ there's a model for that type of resource.
19
+ """
11
20
 
12
21
  Type: Optional[str] = None # Optional to handle cases like "AWS::CloudFormation::Authentication"
13
22
  Properties: Optional[Generic] = None
14
23
 
15
24
  model_config = ConfigDict(extra="allow")
25
+ _strict: ClassVar[bool] = True
16
26
 
17
27
  @field_validator("Type", mode="before")
18
28
  @classmethod
@@ -22,6 +32,8 @@ class GenericResource(Resource):
22
32
  existing_resource_types = {
23
33
  klass.model_fields["Type"].annotation.__args__[0] for klass in ResourceModels.__args__[0].__args__
24
34
  }
25
- if value in existing_resource_types:
35
+ if value in existing_resource_types and cls._strict:
26
36
  raise ValueError(f"Instantiation of GenericResource from {value} in {values} not allowed")
37
+ else:
38
+ logger.warning(f"Instantiation of GenericResource from {value} in {values}")
27
39
  return value
@@ -10,7 +10,7 @@ from pycfmodel.model.resources.properties.statement_condition import StatementCo
10
10
  from pycfmodel.model.types import ResolvableStr, ResolvableStrOrList
11
11
  from pycfmodel.utils import is_resolvable_dict
12
12
 
13
- logger = logging.getLogger(__file__)
13
+ logger = logging.getLogger(__name__)
14
14
 
15
15
 
16
16
  class Principal(Property):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycfmodel
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: A python model for CloudFormation scripts
5
5
  Home-page: https://github.com/Skyscanner/pycfmodel
6
6
  Author: Skyscanner Product Security
@@ -28,7 +28,7 @@ docs_requires = [
28
28
 
29
29
  setup(
30
30
  name="pycfmodel",
31
- version="1.0.1",
31
+ version="1.1.0",
32
32
  description="A python model for CloudFormation scripts",
33
33
  author="Skyscanner Product Security",
34
34
  author_email="security@skyscanner.net",
@@ -1,3 +1,10 @@
1
+ from unittest.mock import patch
2
+
3
+ import pytest
4
+ from pydantic import ValidationError
5
+ from pytest import fixture
6
+
7
+ from pycfmodel.model.cf_model import CFModel
1
8
  from pycfmodel.model.resources.generic_resource import GenericResource
2
9
  from pycfmodel.model.resources.properties.policy_document import PolicyDocument
3
10
  from pycfmodel.model.resources.properties.statement import Principal, Statement
@@ -86,3 +93,32 @@ def test_parse_generic_resource_without_properties():
86
93
  assert isinstance(resource, GenericResource)
87
94
  assert resource.Properties is None
88
95
  assert resource.Type == "AWS::SNS::Topic"
96
+
97
+
98
+ @fixture
99
+ def broken_template():
100
+ return {
101
+ "AWSTemplateFormatVersion": "2010-09-09",
102
+ "Resources": {
103
+ "MyS3Bucket": {
104
+ "Type": "AWS::S3::Bucket",
105
+ "Properties": {
106
+ "BucketName": "my-test-bucket",
107
+ "Tags": [{"Key": "test_novalue", "Value": {"Fn::Ref": "AWS::NoValue"}}],
108
+ },
109
+ }
110
+ },
111
+ }
112
+
113
+
114
+ def test_strict_validation(broken_template):
115
+ with pytest.raises(ValidationError) as error:
116
+ CFModel(**broken_template)
117
+ assert error is not None
118
+
119
+
120
+ def test_non_strict_validation(broken_template, caplog):
121
+ with patch.object(GenericResource, "_strict", False):
122
+ result = CFModel(**broken_template)
123
+ assert "Instantiation of GenericResource from AWS::S3::Bucket" in caplog.text
124
+ assert isinstance(result.Resources["MyS3Bucket"], GenericResource)
File without changes
File without changes
File without changes
File without changes
File without changes