diff --git a/debug/inspect_cft_spec_file.py b/debug/debug00_inspect_cft_spec_file.py similarity index 100% rename from debug/inspect_cft_spec_file.py rename to debug/debug00_inspect_cft_spec_file.py diff --git a/debug/debug_code_rendering.py b/debug/debug01_code_rendering.py similarity index 100% rename from debug/debug_code_rendering.py rename to debug/debug01_code_rendering.py diff --git a/debug/debug02_gen_code_type_hint.py b/debug/debug02_gen_code_type_hint.py new file mode 100644 index 0000000..7a88193 --- /dev/null +++ b/debug/debug02_gen_code_type_hint.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +""" +If you can not import a aws service module in ``cottonformation.res.*.py`` +most likely it's because of the type hint and validator code. + +This code helps developer +""" + +from cottonformation.code.spec import CftSpec, _find_type_hint_and_validator + +ctf_spec = CftSpec.new() +pt = ctf_spec.find_property_type("AWS::WAFv2::WebACL.ManagedRuleGroupStatement") +p = pt.find_property("ScopeDownStatement") +print(p) + +type_hint, validator, converter = _find_type_hint_and_validator( + prop=p, + prop_type_class_name="WebACLRateBasedStatement", + cycled_class_name_set=set() +) + +print(f"type_hint = {type_hint}") +print(f"validator = {validator}") +print(f"converter = {converter}") + +# try import +# import cottonformation.res._imp +# _ = cottonformation.res._imp diff --git a/debug/debug_gen_code.py b/debug/debug03_gen_code.py similarity index 100% rename from debug/debug_gen_code.py rename to debug/debug03_gen_code.py diff --git a/debug/debug_gen_helpers_code.py b/debug/debug04_gen_helpers_code.py similarity index 100% rename from debug/debug_gen_helpers_code.py rename to debug/debug04_gen_helpers_code.py diff --git a/debug/debug_deploy_cft.py b/debug/debug05_deploy_cft.py similarity index 87% rename from debug/debug_deploy_cft.py rename to debug/debug05_deploy_cft.py index 64b82d2..f6233cc 100644 --- a/debug/debug_deploy_cft.py +++ b/debug/debug05_deploy_cft.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import boto3 +from cottonformation.core.template import Template from cottonformation.core.model import ( - Template, Parameter, Output, + Parameter, Output, Ref, Sub, serialize, ) from cottonformation.res import ( @@ -16,17 +17,20 @@ "ProjectName", Type=Parameter.TypeEnum.String, Default="cottonformation-dev", -).add(tpl) +) +tpl.add(param_project_name) bucket = s3.Bucket( "MyBucket", p_BucketName=Sub("${ProjectName}-bucket", dict(ProjectName=param_project_name.ref())), -).add(tpl) +) +tpl.add(bucket) out_bucket_domain_name = Output( "MyBucketDomainName", Value=bucket.rv_DomainName, -).add(tpl) +) +tpl.add(out_bucket_domain_name) # tpl.to_json_file("tpl.json") diff --git a/debug/debug_dese.py b/debug/debug_dese/debug_dese.py similarity index 100% rename from debug/debug_dese.py rename to debug/debug_dese/debug_dese.py diff --git a/debug/debug_gen_code_type_hint.py b/debug/debug_gen_code_type_hint.py deleted file mode 100644 index f427279..0000000 --- a/debug/debug_gen_code_type_hint.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -""" - -from cottonformation.code.spec import CftSpec, _find_type_hint_and_validator - -ctf_spec = CftSpec.new() -pt = ctf_spec.find_property_type("AWS::WAFv2::WebACL.ManagedRuleGroupStatement") -p = pt.find_property("ScopeDownStatement") -print(p) - -print( - _find_type_hint_and_validator( - prop=p, - prop_type_class_name="WebACLRateBasedStatement", - cycled_class_name_set=set() - ) -) -# import cottonformation.res._imp -# _ = cottonformation.res._imp diff --git a/debug/debug_ssh_to_ec2.py b/debug/debug_vpc_ec2_rds/debug01_ssh_to_ec2.py similarity index 100% rename from debug/debug_ssh_to_ec2.py rename to debug/debug_vpc_ec2_rds/debug01_ssh_to_ec2.py