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.
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/PKG-INFO +1 -1
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/cloudformation_actions.py +57 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/generic_resource.py +15 -3
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/statement.py +1 -1
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/PKG-INFO +1 -1
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/setup.py +1 -1
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_generic_resoure.py +36 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/LICENSE.md +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/README.md +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/__init__.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/action_expander.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/constants.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/base.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/cf_model.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/generic.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/parameter.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/ec2_vpc_endpoint_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/es_domain.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_group.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_managed_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_role.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/iam_user.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/kms_key.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/opensearch_domain.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/policy_document.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/property.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/security_group_egress_prop.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/security_group_ingress_prop.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/statement_condition.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/tag.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/types.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/resource.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/s3_bucket.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/s3_bucket_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/security_group.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/security_group_egress.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/security_group_ingress.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/sns_topic_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/sqs_queue_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/types.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/types.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/utils.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/resolver.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/utils.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/SOURCES.txt +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/dependency_links.txt +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/requires.txt +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel.egg-info/top_level.txt +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/pyproject.toml +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/scripts/generate_cloudformation_actions_file.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/setup.cfg +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_policy_document.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_principal.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_statement.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/properties/test_statement_condition.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_ec2_vpc_endpoint_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_es_domain.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_group.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_managed_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_role.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_iam_user.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_kms_key.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_opensearch_domain.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_rds_security_groups.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_s3_bucket.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_s3_bucket_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_security_group.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_security_group_egress.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_security_group_ingress.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_sns_topic_policy.py +0 -0
- {pycfmodel-1.0.1 → pycfmodel-1.1.0}/tests/resources/test_sqs_queue_policy.py +0 -0
|
@@ -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
|
-
|
|
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
|
-
"""
|
|
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(
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class Principal(Property):
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pycfmodel-1.0.1 → pycfmodel-1.1.0}/pycfmodel/model/resources/properties/statement_condition.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|