Skip to content

build

cfnrain build makes starter templates from the CloudFormation resource schemas. The schemas are in the binary, so most uses need no AWS call.

Make a template with only the required properties of a type:

cfnrain build -b AWS::SQS::Queue
AWSTemplateFormatVersion: 2010-09-09

Description: Generated by rain

Resources:
  Queue:
    Type: AWS::SQS::Queue
    Properties: {}

Without -b, the template has every property that you can set. You can give more than one type.

List the resource types that start with a prefix:

cfnrain build -l AWS::SQS
AWS::SQS::Queue
AWS::SQS::QueueInlinePolicy
AWS::SQS::QueuePolicy
Flag What it does
-b, --bare Only the required properties
-j, --json JSON instead of YAML
-s, --schema Print the registry schema of a type
-l, --list List resource types, with an optional prefix
-o, --output Write to a file
--recommend Print a recommended template for a use case. With no more arguments, cfnrain shows a menu. cfnrain build --recommend bucket bucket prints the recommended bucket template.
--pkl-class Print a Pkl class for a type
--prompt Write a template with Amazon Bedrock from a text prompt. The default model is claude2, which is old. Bedrock usage costs money.
--model The Bedrock model ID for --prompt. The short names claude2, claude3haiku, claude3sonnet, claude3opus and claude3.5sonnet also work.
--prompt-lang What --prompt writes: cfn (CloudFormation YAML, the default), guard (CloudFormation Guard) or rego (Open Policy Agent Rego)
--omit-patches Use the raw registry schema. By default, cfnrain applies its own fixes to the schemas.
--no-cache Do not use the schemas in the binary. Get them from the CloudFormation registry.
--only-cache Meant to use only the schemas in the binary. See the warning below.

With no arguments, build shows an interactive menu.

--only-cache does the same as --no-cache

In the code, --only-cache sets the same switch as --no-cache. Both make cfnrain skip the cached schemas. See Known issues.