diff --git a/README.md b/README.md index 29cd2049..0dbcd129 100644 --- a/README.md +++ b/README.md @@ -497,9 +497,71 @@ Resources { BucketName = cfn.Ref("Name") } } +``` + +## Constants + +You can put constants into the `Rain` section in the template and then refer to +those constants later in the template. Constants can be strings or entire +objects (but only strings can be used later in Sub functions). Use the +`!Rain::Constant` directive to refer to a constant in the template. For +strings, you can add constants to `!Sub` string with the +`${Rain::ConstantName}` pseudo-parameter. Constants can contain previosuly +declared constants in Sub strings using the same format. The `Rain` section +gets removed during packaging. + +```yaml +Parameters: + Prefix: + Type: String + +Rain: + Constants: + Test1: ezbeard-rain-test-constants + Test2: !Sub ${Prefix}-${Rain::Test1}-SubTest + +Resources: + Bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: !Rain::Constant Test1 + + Bucket2: + Type: AWS::S3::Bucket + Properties: + BucketName: !Rain::Constant Test2 + + Bucket3: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub "pre-${Prefix}-${Rain::Test1}-suffix" +``` + +Run `rain pkg` on that template to produce the following output: + +```yaml +Parameters: + Prefix: + Type: String + +Resources: + Bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: ezbeard-rain-test-constants + Bucket2: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub ${Prefix}-ezbeard-rain-test-constants-SubTest + + Bucket3: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub pre-${Prefix}-ezbeard-rain-test-constants-suffix ``` + ## Other CloudFormation tools * [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint) diff --git a/docs/README.tmpl b/docs/README.tmpl index d2a39118..2c3e0d73 100644 --- a/docs/README.tmpl +++ b/docs/README.tmpl @@ -469,9 +469,71 @@ Resources { BucketName = cfn.Ref("Name") } } +``` + +## Constants + +You can put constants into the `Rain` section in the template and then refer to +those constants later in the template. Constants can be strings or entire +objects (but only strings can be used later in Sub functions). Use the +`!Rain::Constant` directive to refer to a constant in the template. For +strings, you can add constants to `!Sub` string with the +`${Rain::ConstantName}` pseudo-parameter. Constants can contain previosuly +declared constants in Sub strings using the same format. The `Rain` section +gets removed during packaging. + +```yaml +Parameters: + Prefix: + Type: String + +Rain: + Constants: + Test1: ezbeard-rain-test-constants + Test2: !Sub ${Prefix}-${Rain::Test1}-SubTest + +Resources: + Bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: !Rain::Constant Test1 + + Bucket2: + Type: AWS::S3::Bucket + Properties: + BucketName: !Rain::Constant Test2 + + Bucket3: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub "pre-${Prefix}-${Rain::Test1}-suffix" +``` + +Run `rain pkg` on that template to produce the following output: + +```yaml +Parameters: + Prefix: + Type: String + +Resources: + Bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: ezbeard-rain-test-constants + Bucket2: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub ${Prefix}-ezbeard-rain-test-constants-SubTest + + Bucket3: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub pre-${Prefix}-ezbeard-rain-test-constants-suffix ``` + ## Other CloudFormation tools * [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint) diff --git a/docs/bash_completion.sh b/docs/bash_completion.sh index 502e4a9d..6ea950a8 100644 --- a/docs/bash_completion.sh +++ b/docs/bash_completion.sh @@ -943,6 +943,8 @@ _rain_deploy() flags+=("-k") local_nonpersistent_flags+=("--keep") local_nonpersistent_flags+=("-k") + flags+=("--nested-change-set") + local_nonpersistent_flags+=("--nested-change-set") flags+=("--no-exec") flags+=("-x") local_nonpersistent_flags+=("--no-exec") diff --git a/docs/index.md b/docs/index.md index 8d7d0d45..bd88ac24 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,4 +36,4 @@ Rain is a command line tool for working with AWS CloudFormation templates and st * [rain tree](rain_tree.md) - Find dependencies of Resources and Outputs in a local template * [rain watch](rain_watch.md) - Display an updating view of a CloudFormation stack -###### Auto generated by spf13/cobra on 3-Oct-2024 +###### Auto generated by spf13/cobra on 21-Oct-2024 diff --git a/docs/rain_bootstrap.md b/docs/rain_bootstrap.md index 0cf631cc..6591dc97 100644 --- a/docs/rain_bootstrap.md +++ b/docs/rain_bootstrap.md @@ -30,4 +30,4 @@ rain bootstrap * [rain](index.md) - -###### Auto generated by spf13/cobra on 3-Oct-2024 +###### Auto generated by spf13/cobra on 21-Oct-2024 diff --git a/docs/rain_build.md b/docs/rain_build.md index eec646c5..a14a8ea9 100644 --- a/docs/rain_build.md +++ b/docs/rain_build.md @@ -41,4 +41,4 @@ rain build [] or * [rain](index.md) - -###### Auto generated by spf13/cobra on 3-Oct-2024 +###### Auto generated by spf13/cobra on 21-Oct-2024 diff --git a/docs/rain_cat.md b/docs/rain_cat.md index cf9cfc47..f608b3fc 100644 --- a/docs/rain_cat.md +++ b/docs/rain_cat.md @@ -35,4 +35,4 @@ rain cat * [rain](index.md) - -###### Auto generated by spf13/cobra on 3-Oct-2024 +###### Auto generated by spf13/cobra on 21-Oct-2024 diff --git a/docs/rain_cc.md b/docs/rain_cc.md index 2df7d431..fa12124e 100644 --- a/docs/rain_cc.md +++ b/docs/rain_cc.md @@ -32,4 +32,4 @@ You must pass the --experimental (-x) flag to use this command, to acknowledge t * [rain cc rm](rain_cc_rm.md) - Delete a deployment created by cc deploy (Experimental!) * [rain cc state](rain_cc_state.md) - Download the state file for a template deployed with cc deploy -###### Auto generated by spf13/cobra on 3-Oct-2024 +###### Auto generated by spf13/cobra on 21-Oct-2024 diff --git a/docs/rain_cc_deploy.md b/docs/rain_cc_deploy.md index a1a01248..2962a6fd 100644 --- a/docs/rain_cc_deploy.md +++ b/docs/rain_cc_deploy.md @@ -40,4 +40,4 @@ rain cc deploy