Skip to content

Commit

Permalink
Merge pull request #274 from khmoryz/feat/console-logout
Browse files Browse the repository at this point in the history
Add logout option to rain console
  • Loading branch information
ericzbeard authored Feb 19, 2024
2 parents 14666af + 5851bc2 commit ff7bd65
Show file tree
Hide file tree
Showing 32 changed files with 452 additions and 63 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cfn-lint, Guard and more:

## Key features

* **Interactive deployments**: With `rain deploy`, rain packages your CloudFormation templates using [`aws cloudformation package`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/package.html), prompts you for any parameters that have not yet been defined, shows you a summary of the changes that will be made, and then displays real-time updates as your stack is being deployed. Once finished, you get a summary of the outcome along with any error messages collected along the way - including errors messages for stacks that have been rolled back and no longer exist.
* **Interactive deployments**: With `rain deploy`, rain packages your CloudFormation templates, prompts you for any parameters that have not yet been defined, shows you a summary of the changes that will be made, and then displays real-time updates as your stack is being deployed. Once finished, you get a summary of the outcome along with any error messages collected along the way - including errors messages for stacks that have been rolled back and no longer exist.

* **Consistent formatting of CloudFormation templates**: Using `rain fmt`, you can format your CloudFormation templates to a consistent standard or reformat a template from JSON to YAML (or YAML to JSON if you prefer). Rain preserves your comments when using YAML and switches use of [intrinsic functions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) to use the short syntax where possible.

Expand Down Expand Up @@ -51,8 +51,7 @@ Usage:
Stack commands:
cat Get the CloudFormation template from a running stack
ccdeploy Deploy a local template directly using the Cloud Control API (Experimental!)
ccrm Delete a deployment created by ccdeploy (Experimental!)
cc Interact with templates using Cloud Control API instead of CloudFormation
deploy Deploy a CloudFormation stack from a local template
logs Show the event log for the named stack
ls List running CloudFormation stacks
Expand Down
4 changes: 3 additions & 1 deletion cmd/aws-console/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

var printOnly = false
var logout = false
var userName = ""

// Cmd is the console command's entrypoint
Expand All @@ -28,12 +29,13 @@ Unless you specify the --name/-n flag, your AWS console user name will be derive
service = args[0]
}

console.Open(printOnly, service, "", userName)
console.Open(printOnly, logout, service, "", userName)
},
}

func init() {
Cmd.Flags().BoolVarP(&printOnly, "url", "u", false, "Just construct the sign-in URL; don't attempt to open it")
Cmd.Flags().BoolVarP(&logout, "logout", "l", false, "Log out of the AWS console")
Cmd.Flags().StringVarP(&config.Profile, "profile", "p", "", "AWS profile name; read from the AWS CLI configuration file")
Cmd.Flags().StringVarP(&config.Region, "region", "r", "", "AWS region to use")
Cmd.Flags().StringVarP(&userName, "name", "n", "", "Specify a user name to use in the AWS console")
Expand Down
236 changes: 214 additions & 22 deletions docs/bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,18 @@ _rain_build()
flags+=("-l")
local_nonpersistent_flags+=("--list")
local_nonpersistent_flags+=("-l")
flags+=("--omit-patches")
flags+=("-o")
local_nonpersistent_flags+=("--omit-patches")
local_nonpersistent_flags+=("-o")
flags+=("--prompt")
flags+=("-p")
local_nonpersistent_flags+=("--prompt")
local_nonpersistent_flags+=("-p")
flags+=("--schema")
flags+=("-s")
local_nonpersistent_flags+=("--schema")
local_nonpersistent_flags+=("-s")
flags+=("--no-colour")

must_have_one_flag=()
Expand Down Expand Up @@ -495,9 +503,9 @@ _rain_cat()
noun_aliases=()
}

_rain_ccdeploy()
_rain_cc_deploy()
{
last_command="rain_ccdeploy"
last_command="rain_cc_deploy"

command_aliases=()

Expand Down Expand Up @@ -525,6 +533,8 @@ _rain_ccdeploy()
flags+=("-h")
local_nonpersistent_flags+=("--help")
local_nonpersistent_flags+=("-h")
flags+=("--ignore-unknown-params")
local_nonpersistent_flags+=("--ignore-unknown-params")
flags+=("--params=")
two_word_flags+=("--params")
local_nonpersistent_flags+=("--params")
Expand Down Expand Up @@ -553,16 +563,26 @@ _rain_ccdeploy()
two_word_flags+=("--tags")
local_nonpersistent_flags+=("--tags")
local_nonpersistent_flags+=("--tags=")
flags+=("--unlock=")
two_word_flags+=("--unlock")
two_word_flags+=("-u")
local_nonpersistent_flags+=("--unlock")
local_nonpersistent_flags+=("--unlock=")
local_nonpersistent_flags+=("-u")
flags+=("--yes")
flags+=("-y")
local_nonpersistent_flags+=("--yes")
local_nonpersistent_flags+=("-y")
flags+=("--no-colour")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_rain_ccrm()
_rain_cc_drift()
{
last_command="rain_ccrm"
last_command="rain_cc_drift"

command_aliases=()

Expand All @@ -574,10 +594,82 @@ _rain_ccrm()
flags_with_completion=()
flags_completion=()

flags+=("--detach")
flags+=("-d")
local_nonpersistent_flags+=("--detach")
local_nonpersistent_flags+=("-d")
flags+=("--debug")
local_nonpersistent_flags+=("--debug")
flags+=("--experimental")
flags+=("-x")
local_nonpersistent_flags+=("--experimental")
local_nonpersistent_flags+=("-x")
flags+=("--help")
flags+=("-h")
local_nonpersistent_flags+=("--help")
local_nonpersistent_flags+=("-h")
flags+=("--profile=")
two_word_flags+=("--profile")
two_word_flags+=("-p")
local_nonpersistent_flags+=("--profile")
local_nonpersistent_flags+=("--profile=")
local_nonpersistent_flags+=("-p")
flags+=("--region=")
two_word_flags+=("--region")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--region")
local_nonpersistent_flags+=("--region=")
local_nonpersistent_flags+=("-r")
flags+=("--s3-bucket=")
two_word_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket=")
flags+=("--s3-prefix=")
two_word_flags+=("--s3-prefix")
local_nonpersistent_flags+=("--s3-prefix")
local_nonpersistent_flags+=("--s3-prefix=")
flags+=("--no-colour")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_rain_cc_help()
{
last_command="rain_cc_help"

command_aliases=()

commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--debug")
flags+=("--no-colour")

must_have_one_flag=()
must_have_one_noun=()
has_completion_function=1
noun_aliases=()
}

_rain_cc_rm()
{
last_command="rain_cc_rm"

command_aliases=()

commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--debug")
local_nonpersistent_flags+=("--debug")
flags+=("--experimental")
flags+=("-x")
local_nonpersistent_flags+=("--experimental")
Expand All @@ -598,10 +690,6 @@ _rain_ccrm()
local_nonpersistent_flags+=("--region")
local_nonpersistent_flags+=("--region=")
local_nonpersistent_flags+=("-r")
flags+=("--role-arn=")
two_word_flags+=("--role-arn")
local_nonpersistent_flags+=("--role-arn")
local_nonpersistent_flags+=("--role-arn=")
flags+=("--s3-bucket=")
two_word_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket")
Expand All @@ -614,6 +702,115 @@ _rain_ccrm()
flags+=("-y")
local_nonpersistent_flags+=("--yes")
local_nonpersistent_flags+=("-y")
flags+=("--no-colour")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_rain_cc_state()
{
last_command="rain_cc_state"

command_aliases=()

commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--debug")
local_nonpersistent_flags+=("--debug")
flags+=("--experimental")
flags+=("-x")
local_nonpersistent_flags+=("--experimental")
local_nonpersistent_flags+=("-x")
flags+=("--help")
flags+=("-h")
local_nonpersistent_flags+=("--help")
local_nonpersistent_flags+=("-h")
flags+=("--profile=")
two_word_flags+=("--profile")
two_word_flags+=("-p")
local_nonpersistent_flags+=("--profile")
local_nonpersistent_flags+=("--profile=")
local_nonpersistent_flags+=("-p")
flags+=("--region=")
two_word_flags+=("--region")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--region")
local_nonpersistent_flags+=("--region=")
local_nonpersistent_flags+=("-r")
flags+=("--s3-bucket=")
two_word_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket=")
flags+=("--s3-prefix=")
two_word_flags+=("--s3-prefix")
local_nonpersistent_flags+=("--s3-prefix")
local_nonpersistent_flags+=("--s3-prefix=")
flags+=("--no-colour")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_rain_cc()
{
last_command="rain_cc"

command_aliases=()

commands=()
commands+=("deploy")
commands+=("drift")
commands+=("help")
commands+=("rm")
if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then
command_aliases+=("ccdel")
aliashash["ccdel"]="rm"
command_aliases+=("ccdelete")
aliashash["ccdelete"]="rm"
command_aliases+=("ccremove")
aliashash["ccremove"]="rm"
fi
commands+=("state")

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--help")
flags+=("-h")
local_nonpersistent_flags+=("--help")
local_nonpersistent_flags+=("-h")
flags+=("--profile=")
two_word_flags+=("--profile")
two_word_flags+=("-p")
local_nonpersistent_flags+=("--profile")
local_nonpersistent_flags+=("--profile=")
local_nonpersistent_flags+=("-p")
flags+=("--region=")
two_word_flags+=("--region")
two_word_flags+=("-r")
local_nonpersistent_flags+=("--region")
local_nonpersistent_flags+=("--region=")
local_nonpersistent_flags+=("-r")
flags+=("--s3-bucket=")
two_word_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket")
local_nonpersistent_flags+=("--s3-bucket=")
flags+=("--s3-prefix=")
two_word_flags+=("--s3-prefix")
local_nonpersistent_flags+=("--s3-prefix")
local_nonpersistent_flags+=("--s3-prefix=")
flags+=("--debug")
flags+=("--no-colour")

Expand All @@ -640,6 +837,10 @@ _rain_console()
flags+=("-h")
local_nonpersistent_flags+=("--help")
local_nonpersistent_flags+=("-h")
flags+=("--logout")
flags+=("-l")
local_nonpersistent_flags+=("--logout")
local_nonpersistent_flags+=("-l")
flags+=("--name=")
two_word_flags+=("--name")
two_word_flags+=("-n")
Expand Down Expand Up @@ -1532,16 +1733,7 @@ _rain_root_command()
fi
commands+=("build")
commands+=("cat")
commands+=("ccdeploy")
commands+=("ccrm")
if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then
command_aliases+=("ccdel")
aliashash["ccdel"]="ccrm"
command_aliases+=("ccdelete")
aliashash["ccdelete"]="ccrm"
command_aliases+=("ccremove")
aliashash["ccremove"]="ccrm"
fi
commands+=("cc")
commands+=("console")
commands+=("deploy")
commands+=("diff")
Expand Down
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ Rain is a command line tool for working with AWS CloudFormation templates and st
* [rain bootstrap](rain_bootstrap.md) - Creates the artifacts bucket
* [rain build](rain_build.md) - Create CloudFormation templates
* [rain cat](rain_cat.md) - Get the CloudFormation template from a running stack
* [rain ccdeploy](rain_ccdeploy.md) - Deploy a local template directly using the Cloud Control API (Experimental!)
* [rain ccrm](rain_ccrm.md) - Delete a deployment created by ccdeploy (Experimental!)
* [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 diff](rain_diff.md) - Compare CloudFormation templates
Expand All @@ -36,4 +35,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 16-Jan-2024
###### Auto generated by spf13/cobra on 11-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 16-Jan-2024
###### Auto generated by spf13/cobra on 11-Feb-2024
Loading

0 comments on commit ff7bd65

Please sign in to comment.