Skip to content

Commit

Permalink
re organize debug folder
Browse files Browse the repository at this point in the history
  • Loading branch information
MacHu-GWU committed Jul 9, 2021
1 parent 434b78b commit 4d050f3
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 25 deletions.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions debug/debug02_gen_code_type_hint.py
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
12 changes: 8 additions & 4 deletions debug/debug_deploy_cft.py → debug/debug05_deploy_cft.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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")

Expand Down
File renamed without changes.
21 changes: 0 additions & 21 deletions debug/debug_gen_code_type_hint.py

This file was deleted.

File renamed without changes.

0 comments on commit 4d050f3

Please sign in to comment.