AWS 云格式资源提供者打字插件
我们兴奋地分享我们的进步,在"云阵CLI"中加入新的语言!
AWS 云格式资源提供者类型脚本插件
CloudFormation CLI (cfn) 允许您编写自己的可供 CloudFormation 使用的资源提供者 .
此插件库帮助提供 TypeScript 运行时间绑定, 通过 CloudFormation 执行您的提供者 .
使用量
如果您正在使用此软件包为 CloudFormation 构建资源提供者, 请安装 云格式 CLI 类型脚本插件 - 这将自动安装 云阵 CLI推荐 Python 虚拟环境 .
先决条件
- Python 版本 3.6 或以上
- 萨姆CLI
- 您选择类型脚本 IDE
安装
pip3 install cloudformation-cli-typescript-plugin
参见 云格式 CLI 用户指南 联 合 国 云阵 CLI 用于使用指令.
怎么样
示例运行 :
$ cfn init
Initializing new project
What's the name of your resource type?
(Organization::Service::Resource)
>> Foo::Bar::Baz
Select a language for code generation:
[1] java
[2] typescript
(enter an integer):
>> 2
Use docker for platform-independent packaging (Y/n)?
This is highly recommended unless you are experienced
with cross-platform Typescript packaging.
>> y
Initialized a new project in <>
$ cfn submit --dry-run
$ sam local invoke --event sam-tests/create.json TestEntrypoint
发展
对于插件的修改,推荐一个Python虚拟环境. 检查并安装可编辑模式的插件 :
python3 -m venv env
source env/bin/activate
pip3 install -e /path/to/cloudformation-cli-typescript-plugin
你也许也想看看 云阵 CLI 如果您想要编辑此内容。 在这种情况下,将它们安装在一次操作中效果良好:
pip3 install \
-e /path/to/cloudformation-cli \
-e /path/to/cloudformation-cli-typescript-plugin
这可以确保两个都无意中从PyPI安装.
对于打字机库"@amazon-web- services-cloudform/cloudform-cli-typescript-lib"的修改,将所编译的Javascript:
npm run build
npm pack
您可以在 Cfn 资源工程中安装 :
npm install ../path/to/cloudformation-cli-typescript-plugin/amazon-web-services-cloudformation-cloudformation-cli-typescript-lib-1.0.1.tgz
固定和运行单元测试通过 承诺前,在安装后自动执行(pre-commit install) (中文(简体) ). 持续整合还进行这些检查。 手动选项可供选择,所以不需要执行:
# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files
# run unit tests only. can also be used for other hooks, e.g. black, flake8, pylint-local
pre-commit run pytest-local
许可证
这个库根据Apache 2.0许可证获得许可.