awsc

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 19 Imported by: 0

README

awsc

awsc (AWS cli with Caution) is wrapper for AWS CLI. It displays AWS account information before running any AWS CLI subcommands.

Synopsis

$ awsc [args for AWS CLI]

Example

Installation

$ brew install handlename/tap/awsc

Alternatively, download the binary from the releases page.

Configuration

Configuration file path

You can customize awsc's behavior using a configuration file. The search paths for the configuration file (in order of priority) are as follows:

  • $AWSC_CONFIG_PATH
  • $XDG_CONFIG_PATH/awsc/config.yaml
  • ~/.config/awsc/config.yaml
  • ~/.awsc/config.yaml
Configuration file syntax
# "rules" is a list of conditions for displaying caution.
# The first matched rule will be applied.
rules:
  - # "expression" is a regular expression to trigger caution.
    expression: '(production|pro?d)'
    # "color" specifies the caution's foreground color.
    # Available options: red, green, yellow, blue, magenta, cyan, white, black
    color: red
    # "confirm_on_modify" determines whether to confirm on run modification command by AWS CLI
    confirm_on_modify: true
  - expression: '(staging|stg)'
    color: green
  - expression: '(development|dev|sandbox)'
    color: blue

# "template" defines the format of the caution message.
# If empty, the default template will be used.
# You can use Go's `text/template` syntax.
# Available variables:
# - .Profile: AWS profile name
# - .Region: AWS region
# - .ID: AWS account ID (requires "extra_info" to be true)
# - .UserID: AWS user ID (requires "extra_info" to be true)
# - .Arn: AWS ARN (requires "extra_info" to be true)
# - .Now: The timestamp when the command is executed, formatted by `time_format`
# Additionally, you can embed environment variables using `<< env "ENV_NAME" >>` or `<< must_env "ENV_NAME" >>`.
# See https://github.com/kayac/go-config for more details.
template: |-
  {{ .Now }} # {{ .Profile }} in {{ .Region }}

# "extra_info" determines whether to display extra information.
# If true, awsc makes one or more API calls to AWS to gather extra data.
extra_info: true

# "time_format" specifies the format for the timestamp in the caution message.
# It follows Go's `time.Format` syntax.
time_format: '15:04:05'

Environment variables

var description
$AWSC_LOG_LEVEL Log level: trace, debug, info(default), warn, error, panic
$AWSC_CONFIG_PATH Path to the configuration file.
$AWSC_SHOW_VERSION Show version

Lisence

MIT

Author

@handlename

Documentation

Index

Constants

View Source
const (
	AWSProfileFlag = "--profile"
	AWSProfileEnv  = "AWS_PROFILE"
)
View Source
const Version = "0.2.2"

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(level string)

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp(configPath string) (*App, error)

func (*App) Confirm added in v0.2.0

func (a *App) Confirm(account *entity.Account, argv []string) bool

Confirm returns true if user confirms to execute the command

func (*App) Highlight

func (a *App) Highlight(account *entity.Account, rule *entity.Rule) error

func (*App) Run

func (a *App) Run(ctx context.Context, argv []string) error

func (*App) ShouldHighlight

func (a *App) ShouldHighlight(account *entity.Account) *entity.Rule

Directories

Path Synopsis
cmd
internal
env

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL