### StackSet Deploy Configuration Example (YAML) Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_stackset_deploy.md An example of a YAML configuration file for 'rain stackset deploy'. This file can specify parameters, tags, stack set details, and instance configurations for accounts and regions. ```yaml Parameters: Name: Value Tags: Name: Value StackSet: description: "test description" ... StackSetInstances: accounts: - "123456789123" regions: - us-east-1 - us-east-2 ... ``` -------------------------------- ### YAML Configuration File Example Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_deploy.md This is an example of a YAML configuration file for setting stack parameters and tags. It offers an alternative format to JSON for the same purpose. Values in this file can be overridden by command-line flags. ```yaml Parameters: NameOfTemplateParameter: ValueOfParameter ... Tags: TagKey: TagValue ... ``` -------------------------------- ### JSON Configuration File Example Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_deploy.md This is an example of a JSON configuration file used to specify parameters and tags for a CloudFormation stack deployment. Command-line arguments will override values set in this file. ```json { "Parameters" : { "NameOfTemplateParameter" : "ValueOfParameter", ... }, "Tags" : { "TagKey" : "TagValue", ... } } ``` -------------------------------- ### Display Rain Version Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_version.md Use this command to display the installed version of the rain tool. No additional arguments or setup are required. ```bash rain version ``` -------------------------------- ### Rain Module Install Options Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_module_install.md These options configure the installation process, such as enabling debug output, specifying the CodeArtifact domain and repository, and setting the target AWS region or profile. ```bash --debug Output debugging information ``` ```bash --domain string The CodeArtifact domain (default "cloudformation") ``` ```bash -x, --experimental Acknowledge that this is an experimental feature ``` ```bash -h, --help help for install ``` ```bash --path string The local path for module files, defaults to the current directory (default ".") ``` ```bash -p, --profile string AWS profile name; read from the AWS CLI configuration file ``` ```bash -r, --region string AWS region to use ``` ```bash --repo string The CodeArtifact repository (default "rain") ``` ```bash --version string Version of the module to install ``` -------------------------------- ### Pkl CloudFormation Template Example Source: https://github.com/aws-cloudformation/rain/blob/main/README.md Example of a CloudFormation template written in Pkl, demonstrating type-safe resource definition and imports from the cloudformation-pkl package. ```pkl amends "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/cloudformation@0.1.1/cloudformation@0.1.1#/template.pkl" import "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/cloudformation@0.1.1/cloudformation@0.1.1#/cloudformation.pkl" as cfn import "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/cloudformation@0.1.1/cloudformation@0.1.1#/aws/s3/bucket.pkl" as bucket Description = "Create a bucket" Parameters { ["Name"] { Type = "String" Default = "baz" } } Resources { ["MyBucket"] = new bucket.Bucket { BucketName = cfn.Ref("Name") } } ``` -------------------------------- ### Install a Rain Module Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_module_install.md Use this command to install a package of Rain modules from CodeArtifact. Specify the module name and any desired flags for customization. ```bash rain module install [flags] ``` -------------------------------- ### Process CloudFormation Template with Installed Modules Source: https://context7.com/aws-cloudformation/rain/llms.txt Processes a CloudFormation template that references installed Rain modules. ```bash rain pkg template.yaml --experimental ``` -------------------------------- ### Reference Installed Module in CloudFormation Template Source: https://context7.com/aws-cloudformation/rain/llms.txt Example of how to reference an installed Rain module within a CloudFormation template using the '$' prefix for the module source. ```yaml Modules: Vpc: Source: $my-modules/simple-vpc.yaml Properties: Env: prod ``` -------------------------------- ### Inherited Options for Rain Module Install Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_module_install.md This option is inherited from parent commands and controls the output format. ```bash --no-colour Disable colour output ``` -------------------------------- ### Install Rain Modules from CodeArtifact Source: https://context7.com/aws-cloudformation/rain/llms.txt Downloads and installs a package of Rain modules from AWS CodeArtifact. Specify the target path, version, domain, and repository. ```bash rain module install my-modules --experimental \ --version 1.2.0 \ --path ./installed-modules \ --domain cloudformation \ --repo rain ``` -------------------------------- ### Rain Artifacts Bucket Structure Source: https://github.com/aws-cloudformation/rain/blob/main/internal/cmd/cc/README.md An example of the directory structure within the rain artifacts bucket, showing how deployment state files are organized by name and region. ```text rain-artifacts-0123456789012-us-east-1/ deployments/ name1.yaml name2.yaml ``` -------------------------------- ### Display Current AWS Configuration Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_info.md Use this command to view the AWS account and region you are currently configured to use. No setup or imports are required. ```bash rain info ``` -------------------------------- ### Bootstrap CodeArtifact Domain and Repository Source: https://context7.com/aws-cloudformation/rain/llms.txt Initializes the AWS CodeArtifact domain and repository for managing Rain modules. This is a one-time setup. ```bash rain module bootstrap --experimental ``` -------------------------------- ### Implement a Custom Forecast Plugin Source: https://github.com/aws-cloudformation/rain/blob/main/internal/cmd/forecast/README.md Example of a Go plugin for the rain forecast command. This plugin implements a prediction function for AWS::Lambda::Function resources. ```go package main import ( fc "github.com/aws-cloudformation/rain/plugins/forecast" ) type PluginImpl struct{} // A sample prediction function. func predictLambda(input fc.PredictionInput) fc.Forecast { forecast := fc.MakeForecast(&input) // Implement whatever checks you want to make here forecast.Add("CODE", false, "testing plugin", 0) return forecast } // GetForecasters must be implemented by forecast plugins // This function returns all predictions functions implemented by the plugin func (p *PluginImpl) GetForecasters() map[string]func(input fc.PredictionInput) fc.Forecast { retval := make(map[string]func(input fc.PredictionInput) fc.Forecast) retval["AWS::Lambda::Function"] = predictLambda return retval } // Leave main empty func main() { } // This variable is required to allow rain to find the implementation var Plugin = PluginImpl{} ``` -------------------------------- ### Parse CloudFormation Templates from File, String, or Reader Source: https://context7.com/aws-cloudformation/rain/llms.txt Use `parse.File`, `parse.String`, or `parse.Reader` to load CloudFormation templates into a `*cft.Template` for manipulation. The `*cft.Template` object provides methods to check for sections, retrieve resources, and get resource types. ```go package main import ( "fmt" "os" "github.com/aws-cloudformation/rain/cft/parse" "github.com/aws-cloudformation/rain/cft/format" ) func main() { // Parse from a file path t, err := parse.File("template.yaml") if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } fmt.Println("Template name:", t.Name) // Parse from a YAML/JSON string tStr, err := parse.String(` AWSTemplateFormatVersion: "2010-09-09" Resources: MyBucket: Type: AWS::S3::Bucket Properties: BucketName: my-test-bucket `) if err != nil { panic(err) } // Check for a section if tStr.HasSection("Resources") { fmt.Println("Has Resources section") } // Get a specific resource node node, err := tStr.GetResource("MyBucket") if err != nil { panic(err) } fmt.Printf("MyBucket node kind: %d\n", node.Kind) // Get all resource types types, _ := tStr.GetTypes() fmt.Println("Types:", types) // [AWS::S3::Bucket] // Convert back to formatted YAML string yaml := format.CftToYaml(tStr) fmt.Print(yaml) // Parse from an io.Reader f, _ := os.Open("template.yaml") defer f.Close() tReader, _ := parse.Reader(f) _ = tReader // Verify semantic equivalence after round-tripping output := format.String(tStr, format.Options{JSON: false, Unsorted: false}) if err := parse.Verify(tStr, output); err != nil { fmt.Println("Semantic difference detected:", err) } else { fmt.Println("Round-trip verified OK") } } ``` -------------------------------- ### Rain S3Http Directive Example Source: https://github.com/aws-cloudformation/rain/blob/main/README.md Demonstrates the !Rain::S3Http directive for uploading files or directories to S3 and inserting the HTTPS URL into the template. Rain will create an artifact bucket if one doesn't exist and use the default AWS profile. ```yaml Resources: Test: Type: A::B::C Properties: TheS3URL: !Rain::S3Http s3http.txt ``` ```yaml Resources: Test: Type: A::B::C Properties: TheS3URL: https://rain-artifacts-012345678912-us-east-1.s3.us-east-1.amazonaws.com/a84b588aa54068ed4b027b6e06e5e0bb283f83cf0d5a6720002d36af2225dfc3 ``` -------------------------------- ### Rain Embed Directive Example Source: https://github.com/aws-cloudformation/rain/blob/main/README.md Demonstrates how to use the !Rain::Embed directive to insert file content into a CloudFormation template. Ensure the 'embed.txt' file is in the same directory as the template. ```yaml Resources: Test: Type: AWS::CloudFormation::WaitConditionHandle Metadata: Comment: !Rain::Embed embed.txt ``` ```txt This is a test ``` ```yaml Resources: Test: Type: AWS::CloudFormation::WaitConditionHandle Metadata: Comment: This is a test ``` -------------------------------- ### Download Deployed Templates with Rain Cat Source: https://context7.com/aws-cloudformation/rain/llms.txt Use `rain cat` to download and print the deployed CloudFormation template for a stack. Options include getting the transformed template, the Rain config file, or the raw unformatted template. It can also be piped to `rain diff`. ```bash rain cat my-stack ``` ```bash rain cat my-stack --transformed ``` ```bash rain cat my-stack --config ``` ```bash rain cat my-stack --unformatted ``` ```bash rain cat my-stack | rain diff - local-template.yaml ``` -------------------------------- ### Deploy with Parameters and Skip Confirmation Source: https://context7.com/aws-cloudformation/rain/llms.txt Deploys a template using Cloud Control API with specified parameters and bypasses the confirmation prompt. ```bash rain cc deploy --experimental template.yaml my-deployment \ --params BucketName=my-bucket \ --yes ``` -------------------------------- ### Using a Module with Properties and Overrides Source: https://github.com/aws-cloudformation/rain/blob/main/README.md Demonstrates how to use a module, passing properties and overriding specific resource configurations. The 'Overrides' attribute allows for fine-grained control over module content. ```yaml Modules: Content: Source: ./module.yaml Properties: Name: foo Overrides: Bucket: Metadata: OverrideMe: def Outputs: TheArn: Value: !GetAtt Content.BucketArn ``` -------------------------------- ### Rain CC Deploy Command Syntax Source: https://github.com/aws-cloudformation/rain/blob/main/docs/rain_cc_deploy.md Use this command to create or update resources directly using the Cloud Control API from a specified template file. The --experimental flag must be used. ```bash rain cc deploy