- Mais recentes
- Mais votos
- Mais comentários
I'm not aware of any official style guides for CDK or CloudFormation.
For CDK, start with PEP8 and it's style checker (many IDEs will also apply PEP8 formatting).
From there it is really up to your team to devise (or borrow) a coding standard as you would for any other Python project.
For CloudFormation a great policy enforcement tool is CloudFormation Guard. It has basic canned rules and you can also add your own. As for "ordering" (keys?), CFn templates are simply data structures so you could read them into Python as dictionaries, sort by key, then re-export.
Beyond CloudFormation Guard, which was mentioned on the previous answer, here are a couple of tools that I use on a daily basis with CloudFormation templates:
- cfn-lint CloudFormation linter
- cfn-nag CloudFormation security linter
- cfn-include CloudFormation pre-processor. This is a great simple way to break up a template into more manageable, smaller files.
There is an open source CFN formatter by AWS that you could use to pre-process templates into a standard format before committing. cfn-format.
That can be used in conjunction with a tool like pre-commit to automatically format templates into a standard format.
An example of that is here: https://github.com/aws-cloudformation/rain/blob/main/.pre-commit-hooks.yaml
- id: cfn-format name: Format CloudFormation templates entry: cfn-format -w language: golang files: \.template$ description: Format CloudFormation templates
We're in the same boat... and an official CDK style guide is sorely lacking.
Naming conventions are not merely opinionated as some styles will hang up @ synth.
This unofficial guide is heading in the right direction --> https://github.com/kevinslin/open-cdk
Ironically it's from a former AWS'er that they probibly should have kept around.
Good luck on your own project!
Conteúdo relevante
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há um ano