Skip to content

Commit

Permalink
Merge pull request #296 from ericzbeard/changesets
Browse files Browse the repository at this point in the history
Add changeset functionality
  • Loading branch information
ericzbeard authored Feb 29, 2024
2 parents d3c3a52 + bf13194 commit 095c0c4
Show file tree
Hide file tree
Showing 39 changed files with 438 additions and 201 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ Usage:
Stack commands:
cat Get the CloudFormation template from a running stack
cc Interact with templates using Cloud Control API instead of CloudFormation
deploy Deploy a CloudFormation stack from a local template
deploy Deploy a CloudFormation stack or changeset from a local template
logs Show the event log for the named stack
ls List running CloudFormation stacks
rm Delete a running CloudFormation stack
ls List running CloudFormation stacks or changesets
rm Delete a CloudFormation stack or changeset
stackset This command manipulates stack sets.
watch Display an updating view of a CloudFormation stack
Expand Down
14 changes: 14 additions & 0 deletions docs/bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,8 @@ _rain_deploy()
flags_with_completion=()
flags_completion=()

flags+=("--changeset")
local_nonpersistent_flags+=("--changeset")
flags+=("--config=")
two_word_flags+=("--config")
two_word_flags+=("-c")
Expand All @@ -919,6 +921,10 @@ _rain_deploy()
flags+=("-k")
local_nonpersistent_flags+=("--keep")
local_nonpersistent_flags+=("-k")
flags+=("--no-exec")
flags+=("-x")
local_nonpersistent_flags+=("--no-exec")
local_nonpersistent_flags+=("-x")
flags+=("--params=")
two_word_flags+=("--params")
local_nonpersistent_flags+=("--params")
Expand Down Expand Up @@ -1249,6 +1255,10 @@ _rain_ls()
flags+=("-a")
local_nonpersistent_flags+=("--all")
local_nonpersistent_flags+=("-a")
flags+=("--changeset")
flags+=("-c")
local_nonpersistent_flags+=("--changeset")
local_nonpersistent_flags+=("-c")
flags+=("--help")
flags+=("-h")
local_nonpersistent_flags+=("--help")
Expand Down Expand Up @@ -1380,6 +1390,10 @@ _rain_rm()
flags_with_completion=()
flags_completion=()

flags+=("--changeset")
flags+=("-c")
local_nonpersistent_flags+=("--changeset")
local_nonpersistent_flags+=("-c")
flags+=("--detach")
flags+=("-d")
local_nonpersistent_flags+=("--detach")
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ Rain is a command line tool for working with AWS CloudFormation templates and st
* [rain cat](rain_cat.md) - Get the CloudFormation template from a running stack
* [rain cc](rain_cc.md) - Interact with templates using Cloud Control API instead of CloudFormation
* [rain console](rain_console.md) - Login to the AWS console
* [rain deploy](rain_deploy.md) - Deploy a CloudFormation stack from a local template
* [rain deploy](rain_deploy.md) - Deploy a CloudFormation stack or changeset from a local template
* [rain diff](rain_diff.md) - Compare CloudFormation templates
* [rain fmt](rain_fmt.md) - Format CloudFormation templates
* [rain forecast](rain_forecast.md) - Predict deployment failures
* [rain info](rain_info.md) - Show your current configuration
* [rain logs](rain_logs.md) - Show the event log for the named stack
* [rain ls](rain_ls.md) - List running CloudFormation stacks
* [rain ls](rain_ls.md) - List running CloudFormation stacks or changesets
* [rain merge](rain_merge.md) - Merge two or more CloudFormation templates
* [rain pkg](rain_pkg.md) - Package local artifacts into a template
* [rain rm](rain_rm.md) - Delete a running CloudFormation stack
* [rain rm](rain_rm.md) - Delete a CloudFormation stack or changeset
* [rain stackset](rain_stackset.md) - This command manipulates stack sets.
* [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 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rain bootstrap

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ rain build [<resource type>] or <prompt>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_cat.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ rain cat <stack>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_cc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_cc_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ rain cc deploy <template> <name>

* [rain cc](rain_cc.md) - Interact with templates using Cloud Control API instead of CloudFormation

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_cc_drift.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ rain cc drift <name>

* [rain cc](rain_cc.md) - Interact with templates using Cloud Control API instead of CloudFormation

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_cc_rm.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ rain cc rm <name>

* [rain cc](rain_cc.md) - Interact with templates using Cloud Control API instead of CloudFormation

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_cc_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ rain cc state <name>

* [rain cc](rain_cc.md) - Interact with templates using Cloud Control API instead of CloudFormation

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_console.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ rain console [stack]

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
19 changes: 16 additions & 3 deletions docs/rain_deploy.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## rain deploy

Deploy a CloudFormation stack from a local template
Deploy a CloudFormation stack or changeset from a local template

### Synopsis

Creates or updates a CloudFormation stack named <stack> from the template file <template>.
Creates or updates a CloudFormation stack named <stack> from the template file <template>.
You can also create and execute changesets with this command.
If you don't specify a stack name, rain will use the template filename minus its extension.

If a template needs to be packaged before it can be deployed, rain will package the template first.
Expand Down Expand Up @@ -35,6 +36,16 @@ YAML:
TagKey: TagValue
...

To create a changeset:

rain deploy --no-exec <template> [stackName]

To execute a changeset:

rain deploy --changeset <stackName> <changeSetName>

To list and delete changesets, use the ls and rm commands.


```
rain deploy <template> [stack]
Expand All @@ -43,11 +54,13 @@ rain deploy <template> [stack]
### Options

```
--changeset execute the changeset, rain deploy --changeset <stackName> <changeSetName>
-c, --config string YAML or JSON file to set tags and parameters
-d, --detach once deployment has started, don't wait around for it to finish
-h, --help help for deploy
--ignore-unknown-params Ignore unknown parameters
-k, --keep keep deployed resources after a failure by disabling rollbacks
-x, --no-exec do not execute the changeset
--params strings set parameter values; use the format key1=value1,key2=value2
-p, --profile string AWS profile name; read from the AWS CLI configuration file
-r, --region string AWS region to use
Expand All @@ -70,4 +83,4 @@ rain deploy <template> [stack]

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ rain diff <from> <to>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_fmt.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ rain fmt <filename>...

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_forecast.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ rain forecast --experimental <template> [stackName]

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rain info

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ rain logs <stack> (<resource>)

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
9 changes: 5 additions & 4 deletions docs/rain_ls.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
## rain ls

List running CloudFormation stacks
List running CloudFormation stacks or changesets

### Synopsis

Displays a list of all running stacks or the contents of <stack> if provided.
Displays a list of all running stacks or the contents of <stack> if provided. If the -c arg is supplied, operates on changesets instead of stacks

```
rain ls <stack>
rain ls <stack> [changeset]
```

### Options

```
-a, --all list stacks in all regions; if you specify a stack, show more details
-c, --changeset List changesets instead of stacks
-h, --help help for ls
-p, --profile string AWS profile name; read from the AWS CLI configuration file
-r, --region string AWS region to use
Expand All @@ -30,4 +31,4 @@ rain ls <stack>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ rain merge <template> <template> ...

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ rain pkg <template>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
9 changes: 5 additions & 4 deletions docs/rain_rm.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
## rain rm

Delete a running CloudFormation stack
Delete a CloudFormation stack or changeset

### Synopsis

Deletes the CloudFormation stack named <stack> and waits for the action to complete.
Deletes the CloudFormation stack named <stack> and waits for the action to complete. With -c, deletes a changeset named [changeset].

```
rain rm <stack>
rain rm <stack> [changeset]
```

### Options

```
-c, --changeset delete a changeset
-d, --detach once removal has started, don't wait around for it to finish
-h, --help help for rm
-p, --profile string AWS profile name; read from the AWS CLI configuration file
Expand All @@ -32,4 +33,4 @@ rain rm <stack>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_stackset.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ This command manipulates stack sets. It has no action if specific stack set comm
* [rain stackset ls](rain_stackset_ls.md) - List a CloudFormation stack sets in a given region
* [rain stackset rm](rain_stackset_rm.md) - Delete a CloudFormation stack set and/or its instances.

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_stackset_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ rain stackset deploy <template> [stackset] [flags]

* [rain stackset](rain_stackset.md) - This command manipulates stack sets.

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_stackset_ls.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rain stackset ls <stack set>

* [rain stackset](rain_stackset.md) - This command manipulates stack sets.

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_stackset_rm.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rain stackset rm <stackset>

* [rain stackset](rain_stackset.md) - This command manipulates stack sets.

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rain tree [template]

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
2 changes: 1 addition & 1 deletion docs/rain_watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ rain watch <stack>

* [rain](index.md) -

###### Auto generated by spf13/cobra on 21-Feb-2024
###### Auto generated by spf13/cobra on 29-Feb-2024
27 changes: 27 additions & 0 deletions internal/aws/cfn/cfn.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,33 @@ func StackExists(stackName string) (bool, error) {
return false, nil
}

// List the active change sets associated with a stack
func ListChangeSets(stackName string) ([]types.ChangeSetSummary, error) {
var token *string
retval := make([]types.ChangeSetSummary, 0)
for {
res, err := getClient().ListChangeSets(context.Background(), &cloudformation.ListChangeSetsInput{
StackName: &stackName,
NextToken: token,
})

if err != nil {
return retval, nil
}

retval = append(retval, res.Summaries...)

if res.NextToken == nil {
break
}

token = res.NextToken
}

return retval, nil

}

// ListStacks returns a list of all existing stacks
func ListStacks() ([]types.StackSummary, error) {
stacks := make([]types.StackSummary, 0)
Expand Down
4 changes: 4 additions & 0 deletions internal/aws/cfn/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,7 @@ func ListResourceTypes() ([]string, error) {
func IsCCAPI(t string) (bool, error) {
return true, nil
}

func ListChangeSets(stackName string) ([]types.ChangeSetSummary, error) {
return make([]types.ChangeSetSummary, 0), nil
}
Loading

0 comments on commit 095c0c4

Please sign in to comment.