stefunny

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 54 Imported by: 0

README

stefunny

Latest GitHub release Github Actions test Go Report Card License

stefunny is a deployment tool for AWS StepFunctions state machine and the accompanying AWS EventBridge rule and scheudle.

stefunny does,

  • Create a state machine.
  • Create a EventBridge rule and EventBridge Scheduler schedule.
  • Deploy state machine/ EventBridge rule / EventBridge Scheduler schedule/ StateMachine Alias.
  • Rollback to the previous version of the state machine.
  • Manage state machine versions.
  • Show status of the state machine.

That's all for now.

stefunny does not,

  • Manage resources related to the StepFunctions state machine.
    • e.g. IAM Role, Resources called by state machine, Trigger rule that is not a schedule, CloudWatch LogGroup, etc...
  • Manage StepFunctions Activities and Activity Worker.

If you hope to manage these resources collectively, we recommend other deployment tools (AWS SAM, Serverless Framework, etc.).

If you hope to manage these resources partially individually, we recommend the following tools:

Install

Homebrew (macOS and Linux)
$ brew install mashiike/tap/stefunny
aqua

aqua is a declarative CLI Version Manager.

$ aqua g -i mashiike/stefunny
Binary packages

Releases

GitHub Actions

Action mashiike/stefunny@v0 installs stefunny binary for Linux into /usr/local/bin. This action runs install only.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: mashiike/stefunny@v0
        with:
          version: v0.6.0 
      - run: |
          stefunny deploy

QuickStart

Try migrate your existing StepFunctions StateMachine to stefunny.

$ mkdir hello
$ cd hello
$ stefunny init --state-machine Hello     
2024/02/13 16:07:53 [notice] StateMachine/Hello save config to /home/user/hello/stefunny.yaml
2024/02/13 16:07:53 [notice] StateMachine/Hello save state machine definition to /home/user/hello/definition.asl.json

Edit the definition.asl.json and stefunny.yaml.

Now you can deploy state machine Hello using stefunny deploy.

$ stefunny deploy
2024/02/13 16:18:42 [info] Starting deploy 
2024/02/13 16:18:42 [info] update state machine `arn:aws:states:ap-northeast-1:123456789012:stateMachine:Hello:2`
2024/02/13 16:18:42 [info] update current alias `arn:aws:states:ap-northeast-1:123456789012:stateMachine:Hello:current`
2024/02/13 16:18:42 [info] deploy state machine `Hello`(at `2024-02-13 07:17:48.178 +0000 UTC`)
2024/02/13 16:18:43 [info] finish deploy 

Usage

Usage: stefunny <command>

stefunny is a deployment tool for AWS StepFunctions state machine

Flags:
  -h, --help                      Show context-sensitive help.
      --log-level="info"          Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"    Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING            URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...              external string values for Jsonnet
      --ext-code=,...             external code values for Jsonnet
      --region=""                 AWS region ($AWS_REGION)
      --alias="current"           Alias name for state machine ($STEFUNNY_ALIAS)

Commands:
  version
    Show version

  init --state-machine=STRING
    Initialize stefunny configuration

  delete
    Delete state machine and schedule rules

  deploy
    Deploy state machine and schedule rules

  rollback
    Rollback state machine

  schedule --enabled --disabled
    Enable or disable schedule rules (deprecated)

  render <targets> ...
    Render state machine definition

  execute
    Execute state machine

  versions
    Manage state machine versions

  diff
    Show diff of state machine definition and trigers

  pull
    Pull state machine definition

  studio
    Show Step Functions workflow studio URL

  status
    Show status of state machine

Run "stefunny <command> --help" for more information on a command.
Init

stepfunny init initialize stefunny.yaml and definition file by existing state machine.

Usage: stefunny init --state-machine=STRING

Initialize stefunny configuration

Flags:
  -h, --help                                Show context-sensitive help.
      --log-level="info"                    Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"              Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING                      URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...                        external string values for Jsonnet
      --ext-code=,...                       external code values for Jsonnet
      --region=""                           AWS region ($AWS_REGION)
      --alias="current"                     Alias name for state machine ($STEFUNNY_ALIAS)

      --state-machine=STRING                AWS StepFunctions state machine name ($STATE_MACHINE_NAME)
  -d, --definition="definition.asl.json"    Path to state machine definition file ($DEFINITION_FILE_PATH)
      --env=ENV,...                         templateize environment variables
      --must-env=MUST-ENV,...               templateize must environment variables
      --skip-trigger                        Skip trigger

created file foramt are checked file extension. .json saved as json, .jsonnet saved as jsonnet, .yaml or .yml saved as yaml.

If you manage the aws resources by terraform, you can use --tfstate flag with stefunny init command.

$ export ENV=dev
$ stefunny init --state-machine dev-Hello --tfstate s3://my-bucket/terraform.tfstate --must-env ENV

in this case, saved config and definition file are templatized by text/template

for example, the saved config file is like this.

aws_region: ap-northeast-1
required_version: ">=v0.6.0"
state_machine:
  definition: definition.asl.json
  logging_configuration:
    destinations:
    - cloudwatch_logs_log_group:
        log_group_arn: "{{ tfstate `aws_cloudwatch_log_group.state_machine.arn` }}:*"
    include_execution_data: true
    level: ALL
  name: "{{ must_env `ENV` }}-Hello"
  role_arn: "{{ tfstate `aws_iam_role.state_machine.arn` }}"
  tags:
  - key: Name
    value: "{{ must_env `ENV` }}-Hello"
  tracing_configuration:
    enabled: true
  type: STANDARD
Deploy
Usage: stefunny deploy

Deploy state machine and schedule rules

Flags:
  -h, --help                          Show context-sensitive help.
      --log-level="info"              Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"        Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING                URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...                  external string values for Jsonnet
      --ext-code=,...                 external code values for Jsonnet
      --region=""                     AWS region ($AWS_REGION)
      --alias="current"               Alias name for state machine ($STEFUNNY_ALIAS)

      --dry-run                       Dry run
      --skip-state-machine            Skip deploy state machine
      --skip-trigger                  Skip deploy trigger
      --version-description=STRING    Version description
      --keep-versions=0               Number of latest versions to keep. Older versions will be deleted. (Optional value: default 0)
      --trigger-enabled               Enable trigger
      --trigger-disabled              Disable trigger
      --[no-]unified                  when dry run, output unified diff

stefunny deploy works as below.

  • Create / Update State Machine from config file and definition file(yaml/json/jsonnet)
    • Replace {{ env FOO bar }} syntax in the config file and definition file to environment variable "FOO". If "FOO" is not defined, replaced by "bar"
    • Replace {{ must_env FOO }} syntax in the config file and definition file to environment variable "FOO". If "FOO" is not defined, abort immediately.
    • If a terraform state is given in config, replace the {{tfstate <tf resource name>}} syntax in the config file and definition file with reference to the state content.
  • Publish new version of the state machine.
  • Update the alias to the new version.
  • Create/ Update EventBridge rule.
  • Create/ Update EventBridge Scheduler schedule.

stefunny deploy always applies the current config as-is; it has no notion of "there is no diff, so skip". It always publishes a new state machine version and moves the alias, even when nothing changed. If you want to skip deploy when there is no change, check for a diff before calling deploy, e.g. with stefunny diff --exit-code in CI (see Diff below).

Diff
Usage: stefunny diff [flags]

Show diff of state machine definition and trigers

Flags:
  -h, --help                      Show context-sensitive help.
      --log-level="info"          Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"    Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING            URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...              external string values for Jsonnet
      --ext-code=,...             external code values for Jsonnet
      --region=""                 AWS region ($AWS_REGION)
      --alias="current"           Alias name for state machine ($STEFUNNY_ALIAS)

  -u, --[no-]unified              output in unified format
      --qualifier=""              qualifier for state machine
      --exit-code                 exit with code 2 if there are differences
      --skip-trigger              Skip trigger diff

stefunny diff shows the diff of the state machine definition and triggers (EventBridge rules / EventBridge Scheduler schedules) between the config and the deployed resources.

--skip-trigger skips the trigger diff (EventBridge rules / EventBridge Scheduler schedules), mirroring deploy --skip-trigger. Use it when triggers are managed outside of stefunny (e.g. by Terraform), so diff --exit-code reflects only what deploy --skip-trigger would actually change.

With --exit-code, the exit status reports whether a diff was found, matching lambroll's diff --exit-code: exit code 0 when there is no diff, 2 when there is a diff, and any other non-zero code on an actual error. This lets CI gate deploy on whether anything changed, without deploy itself having to decide:

- name: diff
  id: diff
  run: |
    set +e
    stefunny diff --exit-code
    code=$?
    set -e
    case $code in
      0) echo "changed=false" >> "$GITHUB_OUTPUT" ;;
      2) echo "changed=true"  >> "$GITHUB_OUTPUT" ;;
      *) exit $code ;;
    esac

- name: deploy
  if: steps.diff.outputs.changed == 'true'
  run: stefunny deploy --keep-versions 10
Rollback
Usage: stefunny rollback

Rollback state machine

Flags:
  -h, --help                      Show context-sensitive help.
      --log-level="info"          Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"    Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING            URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...              external string values for Jsonnet
      --ext-code=,...             external code values for Jsonnet
      --region=""                 AWS region ($AWS_REGION)
      --alias="current"           Alias name for state machine ($STEFUNNY_ALIAS)

      --dry-run                   Dry run
      --keep-version              Keep current version, no delete

stefunny deploy create/update alias current to the published state machine version on deploy.

stefunny rollback works as below.

  1. Find previous one version of state machine.
  2. Update alias current to the previous version.
  3. default delete old version of state machine. (when --keep-version specified, not delete old version of state machine)
Studio and Pull

If you use AWS Step Functions Workflow Studio, you can open the studio URL with stefunny studio command.

Usage: stefunny studio

Show Step Functions workflow studio URL

Flags:
  -h, --help                      Show context-sensitive help.
      --log-level="info"          Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"    Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING            URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...              external string values for Jsonnet
      --ext-code=,...             external code values for Jsonnet
      --region=""                 AWS region ($AWS_REGION)
      --alias="current"           Alias name for state machine ($STEFUNNY_ALIAS)

      --open                      open workflow studio

stefunny studio command shows the studio URL. If --open flag is specified, open the studio URL in the browser. Edit state machine on Workflow Studio, and pull the definition file with stefunny pull command.

Usage: stefunny pull

Pull state machine definition

Flags:
  -h, --help                      Show context-sensitive help.
      --log-level="info"          Set log level (debug, info, notice, warn, error) ($STEFUNNY_LOG_LEVEL)
  -c, --config="stefunny.yaml"    Path to config file ($STEFUNNY_CONFIG)
      --tfstate=STRING            URL to terraform.tfstate referenced in config ($STEFUNNY_TFSTATE)
      --ext-str=,...              external string values for Jsonnet
      --ext-code=,...             external code values for Jsonnet
      --region=""                 AWS region ($AWS_REGION)
      --alias="current"           Alias name for state machine ($STEFUNNY_ALIAS)

      --[no-]templateize          templateize output
      --qualifier=STRING          qualifier for the version

stefunny pull command pull the definition file from the state machine and save it to the file.

config file (yaml)
required_version: ">=v0.6.0"
aws_region: "{{ env `AWS_REGION` `ap-northeast-1` }}"

state_machine:
  name: "{{ must_env `ENV` }}-Hello"
  definition: definition.asl.json
  logging_configuration:
    destinations:
      - cloudwatch_logs_log_group:
          log_group_arn: "{{ tfstate `aws_cloudwatch_log_group.state_machine.arn` }}:*"
    include_execution_data: true
    level: ALL

  role_arn: "{{ tfstate `aws_iam_role.state_machine.arn` }}"
  tracing_configuration:
    enabled: true
  type: STANDARD

tfstate:
  - location: s3://my-tfstate-bucket/terraform.tfstate

trigger:
  schedule:
    - name: "{{ must_env `ENV` }}-stefunny-test"
      group_name: default
      action_after_completion: DELETE
      flexible_time_window:
        maximum_window_in_minutes: 240.0
        mode: FLEXIBLE
      schedule_expression: at(2024-02-29T00:01:00)
      target:
        retry_policy:
          maximum_event_age_in_seconds: 86400.0
          maximum_retry_attempts: 185.0
        role_arn: "{{ tfstate `aws_iam_role.event_bridge_scheduler.arn` }}"

  event:
    - name: "{{ must_env `ENV` }}-stefunny-test"
      event_bus_name: default
      event_pattern: "{{ file `event_pattern.json` | json_escape }}"
      role_arn: "{{ tfstate `aws_iam_role.event_bridge.arn` }}"

Configuration files and definition files are read with text/template, stefunny has template functions env, must_env, file, json_escape, tfstate and caller_identity.

Template syntax

stefunny uses the text/template standard package in Go to render template files, and parses as YAML/JSON/Jsonnet.

env
"{{ env `NAME` `default value` }}"

If the environment variable NAME is set, it will replace with its value. If it's not set, it will replace with "default value".

must_env
"{{ must_env `NAME` }}"

It replaces with the value of the environment variable NAME. If the variable isn't set at the time of execution, stefunny will panic and stop forcefully.

By defining values that can cause issues when running without meaningful values with must_env, you can prevent unintended deployments.

json_escape
"{{ must_env `JSON_VALUE` | json_escape }}"

It escapes values as JSON strings. Use it when you want to escape values that need to be embedded as strings and require escaping, like quotes.

file
"{{ file `path/to/file` }}"
tfstate

If written tfstate section in the configuration file, it will be use tfstate template function. as following.

stefunny.yaml

required_version: ">v0.0.0"

state_machine:
  name: send_sns
  definition: send_sns.asl.jsonnet
  role_arn: "{{ tfstae `aws_iam_role.stepfunctions.arn` }}"
  logging_configuration:
    level: OFF

tfstate:
  - path: "./terraform.tfstate"
  - url: s3://my-bucket/terraform.tfstate
    func_prefix: s3_

send_sns.asl.jsonnet

{
  Comment: "A simple AWS Step Functions state machine that sends a message to an SNS topic", 
  StartAt: "Send SNS Message",
  States: {
    "Send SNS Message": {
      Type: "Task",
      Resource: "arn:aws:states:::sns:publish",
      Parameters: {
        "TopicArn": "{{ s3_tfstate `aws_sns_topic.topic.arn` }}",
        "Message.$": "$"
      },
      End: true,
    }
  }
}

{{ tfstate "resource_type.resource_name.attr" }} will expand to an attribute value of the resource in tfstate.

{{ tfstatef "resource_type.resource_name['%s'].attr" "index" }} is similar to {{ tfstatef "resource_type.resource_name['index'].attr" }}. This function is useful to build a resource address with environment variables.

{{ tfstatef `aws_subnet.ecs['%s'].id` (must_env `SERVICE`) }}

This function uses tfstate-lookup to load tfstate.

caller_identity

caller_identity resolves the AWS account calling stefunny (the same information as aws sts get-caller-identity). It is available both as a text/template function and, in Jsonnet definition/config files, as a native function via std.native.

"{{ caller_identity.Account }}"
std.native('caller_identity')().Account

It returns an object with Account, Arn and UserId fields. The result is resolved at most once per stefunny invocation and reused for every subsequent reference.

Using caller_identity makes config/definition loading require resolvable AWS credentials, even for commands like render that would otherwise not need any AWS access. If a config doesn't use caller_identity (and doesn't rely on the deprecated state_machine.logging field with a non-ARN log group, which resolves AWS credentials for an unrelated reason), loading it never touches AWS.

If caller_identity is used inside the configuration file itself (not only in the definition file), it is resolved before that file has finished decoding, so aws_region and endpoints.sts written in the same file are not yet available; set AWS_REGION / AWS_ENDPOINT_URL_STS via environment variables instead if you need to control them in that case.

Because the result is memoized for the whole invocation, this also means: if caller_identity is used in the configuration file, the definition file reuses that same already-resolved value rather than re-resolving it with the now-decoded aws_region / endpoints.sts. In practice this rarely matters, since Account, Arn and UserId don't depend on region or endpoint.

Special Thanks

@fujiwara has given me naming idea of stefunny.

Inspire tools

LICENSE

MIT License

Copyright (c) 2021 IKEDA Masashi

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStateMachineDoesNotExist = errors.New("state machine does not exist")
	ErrRollbackTargetNotFound   = errors.New("rollback target not found")
)
View Source
var (
	ErrEventBridgeRuleDoesNotExist = errors.New("schedule rule does not exist")
)
View Source
var ErrHasDiff = errors.New("there are differences")

ErrHasDiff is returned by App.Diff when DiffOption.ExitCode is set and a difference was found, so the caller can map it to a distinct exit code.

View Source
var ErrScheduleNotFound = errors.New("schedule not found")
View Source
var Version = "v0.11.0"

Functions

func CamelToSnake added in v0.6.0

func CamelToSnake(s string) string

func JSON2Jsonnet added in v0.6.0

func JSON2Jsonnet(filename string, data []byte) ([]byte, error)

func JSONDiffString added in v0.6.0

func JSONDiffString(fromStr, toStr string, opts ...JSONDiffOption) (string, error)

JSONDiffString renders a color-highlighted diff between fromStr and toStr, applying opts (see JSONDiffFromURI, JSONDiffToURI, JSONDiffUnified, JSONDiffIgnore). Returns an error if a JSONDiffIgnore query is invalid or fails to apply.

func LoggerSetup added in v0.6.0

func LoggerSetup(w io.Writer, minLevel string) func()

func MarshalJSONString added in v0.6.0

func MarshalJSONString(s interface{}, overrides ...any) string

func SnakeToCamel added in v0.6.0

func SnakeToCamel(s string) string

Types

type App

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

App runs stefunny commands against a state machine and its triggers.

sfnSvc, eventbridgeSvc and schedulerSvc are constructed lazily, on first use, via sfnService/eventBridgeService/schedulerService: a command that never needs one of them (e.g. render) never resolves AWS credentials for it. mu guards all four fields.

func New

func New(_ context.Context, cfg *Config, opts ...NewAppOption) (*App, error)

New creates a new App

func (*App) Delete

func (app *App) Delete(ctx context.Context, opt DeleteOption) error

func (*App) Deploy

func (app *App) Deploy(ctx context.Context, opt DeployOption) error

func (*App) Diff added in v0.6.0

func (app *App) Diff(ctx context.Context, opt DiffOption) error

Diff prints the diff between the config and the deployed state machine, EventBridge rules and EventBridge Scheduler schedules. If opt.SkipTrigger is set, the EventBridge rules and EventBridge Scheduler schedules diff is skipped, matching the scope of DeployOption.SkipTrigger. The state machine's tag diff is computed under opt.TagStrategy (see TagStrategy), matching what DeployOption.TagStrategy would actually apply, so a tag that deploy would never touch never counts toward the diff. If opt.Ignore is set, paths it matches are excluded from every comparison except the state machine's Definition; an invalid jq query returns an error before any AWS call is made. Returns ErrHasDiff if opt.ExitCode is set and a difference was found.

func (*App) Execute added in v0.3.0

func (app *App) Execute(ctx context.Context, opt ExecuteOption) error

Execute starts a state machine execution with the given input and waits for it to finish unless opt.Async is set. Returns an error if the execution fails to start, or if the execution itself fails when its result is awaited.

func (*App) Init added in v0.1.0

func (app *App) Init(ctx context.Context, opt InitOption) error

func (*App) Pull added in v0.6.0

func (app *App) Pull(ctx context.Context, opt PullOption) error

func (*App) Render

func (app *App) Render(ctx context.Context, opt RenderOption) error

func (*App) Rollback added in v0.6.0

func (app *App) Rollback(ctx context.Context, opt RollbackOption) error

func (*App) SetAliasName added in v0.6.0

func (app *App) SetAliasName(aliasName string)

func (*App) SetManagedByTagKey added in v0.11.0

func (app *App) SetManagedByTagKey(key string)

SetManagedByTagKey overrides the tag key App uses to mark and recognize resources it manages, falling back to tagManagedBy when key is empty. It propagates to cfg and to any already-constructed sfnSvc/eventbridgeSvc.

func (*App) StateMachineAliasName added in v0.6.0

func (app *App) StateMachineAliasName() string

func (*App) Status added in v0.6.0

func (app *App) Status(ctx context.Context, opt StatusOption) error

func (*App) Studio added in v0.6.0

func (app *App) Studio(ctx context.Context, opt StudioOption) error

func (*App) Versions added in v0.6.0

func (app *App) Versions(ctx context.Context, opt VersionsOption) error

Versions lists the deployed versions of the state machine, optionally purging older ones. Returns an error if describing, listing, or (when opt.Delete is set) purging the versions fails.

type CLI added in v0.6.0

type CLI struct {
	LogLevel        string   `` /* 139-byte string literal not displayed */
	Config          string   `` /* 132-byte string literal not displayed */
	TFState         string   `name:"tfstate" help:"URL to terraform.tfstate referenced in config" env:"STEFUNNY_TFSTATE" json:"tfstate,omitempty"`
	ExtStr          []string `name:"ext-str" help:"external string values for Jsonnet" default:"" json:"ext_str,omitempty"`
	ExtCode         []string `name:"ext-code" help:"external code values for Jsonnet" default:"" json:"ext_code,omitempty"`
	AWSRegion       string   `name:"region" help:"AWS region" default:"" env:"AWS_REGION" json:"region,omitempty"`
	AliasName       string   `name:"alias" help:"Alias name for state machine" default:"current" env:"STEFUNNY_ALIAS" json:"alias,omitempty"`
	ManagedByTagKey string   `` /* 173-byte string literal not displayed */

	Version  struct{}              `cmd:"" help:"Show version" json:"version,omitempty"`
	Init     InitOption            `cmd:"" help:"Initialize stefunny configuration" json:"init,omitempty"`
	Delete   DeleteOption          `cmd:"" help:"Delete state machine and schedule rules" json:"delete,omitempty"`
	Deploy   DeployCommandOption   `cmd:"" help:"Deploy state machine and schedule rules" json:"deploy,omitempty"`
	Rollback RollbackOption        `cmd:"" help:"Rollback state machine" json:"rollback,omitempty"`
	Schedule ScheduleCommandOption `cmd:"" help:"Enable or disable schedule rules (deprecated)" json:"schedule,omitempty"`
	Render   RenderOption          `cmd:"" help:"Render state machine definition" json:"render,omitempty"`
	Execute  ExecuteOption         `cmd:"" help:"Execute state machine" json:"execute,omitempty"`
	Versions VersionsOption        `cmd:"" help:"Manage state machine versions" json:"versions,omitempty"`
	Diff     DiffOption            `cmd:"" help:"Show diff of state machine definition and trigers" json:"diff,omitempty"`
	Pull     PullOption            `cmd:"" help:"Pull state machine definition" json:"pull,omitempty"`
	Studio   StudioOption          `cmd:"" help:"Show Step Functions workflow studio URL" json:"studio,omitempty"`
	Status   StatusOption          `cmd:"" help:"Show status of state machine" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func NewCLI added in v0.6.0

func NewCLI() *CLI

func (*CLI) Exit added in v0.6.0

func (cli *CLI) Exit(exitFunc func(int))

Exit sets the exit function. for testing

func (*CLI) Main added in v0.9.4

func (cli *CLI) Main(ctx context.Context, args []string) error

Main runs the command

func (*CLI) NewApp added in v0.6.0

func (cli *CLI) NewApp(ctx context.Context) (*App, error)

NewApp creates a new App instance from the CLI configuration

func (*CLI) NoExpandPath added in v0.6.0

func (cli *CLI) NoExpandPath()

NoExpandPath disables path expansion. for testing

func (*CLI) Parse added in v0.6.0

func (cli *CLI) Parse(args []string) (string, error)

Parse parses the command line arguments and returns the command name

func (*CLI) Writers added in v0.6.0

func (cli *CLI) Writers(stdout, stderr io.Writer)

Writers sets the writers for stdout and stderr. for testing

type CloudWatchLogsClient added in v0.6.0

type CloudWatchLogsClient interface {
	cloudwatchlogs.DescribeLogGroupsAPIClient
}

type Config

type Config struct {
	RequiredVersion string `` /* 153-byte string literal not displayed */
	AWSRegion       string `` /* 128-byte string literal not displayed */

	StateMachine *StateMachineConfig `yaml:"state_machine,omitempty" json:"state_machine,omitempty"`
	Trigger      *TriggerConfig      `yaml:"trigger,omitempty" json:"trigger,omitempty"`
	Schedule     []*ScheduleConfig   `yaml:"schedule,omitempty" json:"schedule,omitempty"`
	Tags         map[string]string   `yaml:"tags,omitempty" json:"tags,omitempty"`

	Endpoints *EndpointsConfig `yaml:"endpoints,omitempty" json:"endpoints,omitempty"`

	TFState []*TFStateConfig `yaml:"tfstate,omitempty" json:"tfstate,omitempty"`

	ConfigDir      string                     `yaml:"-" json:"-"`
	ConfigFileName string                     `yaml:"-" json:"-"`
	Envs           *OrderdMap[string, string] `yaml:"-" json:"-"`
	MustEnvs       *OrderdMap[string, string] `yaml:"-" json:"-"`
	Files          *OrderdMap[string, string] `yaml:"-" json:"-"`
	TemplateFiles  *OrderdMap[string, string] `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) LoadAWSConfig added in v0.6.0

func (cfg *Config) LoadAWSConfig(ctx context.Context) (aws.Config, error)

func (*Config) ManagedByTagKey added in v0.11.0

func (cfg *Config) ManagedByTagKey() string

ManagedByTagKey returns the tag key stefunny uses to mark resources it manages, defaulting to tagManagedBy when unset.

func (*Config) NewCloudWatchLogsClientFromConfig added in v0.9.4

func (cfg *Config) NewCloudWatchLogsClientFromConfig(awsCfg aws.Config) *cloudwatchlogs.Client

func (*Config) NewEventBridgeClientFromConfig added in v0.9.4

func (cfg *Config) NewEventBridgeClientFromConfig(awsCfg aws.Config) *eventbridge.Client

func (*Config) NewEventBridgeRules added in v0.6.0

func (cfg *Config) NewEventBridgeRules() EventBridgeRules

func (*Config) NewSchedulerClientFromConfig added in v0.9.4

func (cfg *Config) NewSchedulerClientFromConfig(awsCfg aws.Config) *scheduler.Client

func (*Config) NewSchedules added in v0.6.0

func (cfg *Config) NewSchedules() Schedules

func (*Config) NewStateMachine added in v0.6.0

func (cfg *Config) NewStateMachine() *StateMachine

func (*Config) NewStepFunctionsClientFromConfig added in v0.9.4

func (cfg *Config) NewStepFunctionsClientFromConfig(awsCfg aws.Config) *sfn.Client

func (*Config) NewStsClientFromConfig added in v0.9.4

func (cfg *Config) NewStsClientFromConfig(awsCfg aws.Config) *sts.Client

func (*Config) Restrict

func (cfg *Config) Restrict() error

Restrict restricts a configuration.

func (*Config) SetManagedByTagKey added in v0.11.0

func (cfg *Config) SetManagedByTagKey(key string)

SetManagedByTagKey overrides the tag key ManagedByTagKey returns.

func (*Config) StateMachineDefinition added in v0.6.0

func (cfg *Config) StateMachineDefinition() string

func (*Config) StateMachineName added in v0.6.0

func (cfg *Config) StateMachineName() string

func (*Config) ValidateVersion

func (cfg *Config) ValidateVersion(version string) error

ValidateVersion validates a version satisfies required_version.

type ConfigLoader added in v0.6.0

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

func NewConfigLoader added in v0.6.0

func NewConfigLoader(extStr, extCode map[string]string) *ConfigLoader

func (*ConfigLoader) AppendFuncMap added in v0.6.0

func (l *ConfigLoader) AppendFuncMap(prefix string, funcMap template.FuncMap) error

func (*ConfigLoader) AppendTFState added in v0.6.0

func (l *ConfigLoader) AppendTFState(ctx context.Context, prefix string, tfState string) error

func (*ConfigLoader) Load added in v0.6.0

func (l *ConfigLoader) Load(ctx context.Context, path string) (*Config, error)

func (*ConfigLoader) SetCloudWatchLogsClient added in v0.6.0

func (l *ConfigLoader) SetCloudWatchLogsClient(client CloudWatchLogsClient)

func (*ConfigLoader) SetSTSClient added in v0.10.0

func (l *ConfigLoader) SetSTSClient(client STSClient)

SetSTSClient injects the STS client used to resolve caller_identity. this is for testing

type DeleteOption

type DeleteOption struct {
	DryRun bool `name:"dry-run" help:"Dry run" json:"dry_run,omitempty"`
	Force  bool `name:"force" help:"delete without confirmation" json:"force,omitempty"`
}

func (DeleteOption) DryRunString

func (opt DeleteOption) DryRunString() string

type DeployCommandOption added in v0.6.0

type DeployCommandOption struct {
	DryRun             bool    `name:"dry-run" help:"Dry run" json:"dry_run,omitempty"`
	SkipStateMachine   bool    `name:"skip-state-machine" help:"Skip deploy state machine" json:"skip_state_machine,omitempty"`
	SkipTrigger        bool    `name:"skip-trigger" help:"Skip deploy trigger" json:"skip_trigger,omitempty"`
	VersionDescription string  `name:"version-description" help:"Version description" json:"version_description,omitempty"`
	KeepVersions       int     `` /* 144-byte string literal not displayed */
	TriggerEnabled     bool    `name:"trigger-enabled" help:"Enable trigger" xor:"trigger" json:"trigger_enabled,omitempty"`
	TriggerDisabled    bool    `name:"trigger-disabled" help:"Disable trigger" xor:"trigger" json:"trigger_disabled,omitempty"`
	Unified            bool    `name:"unified" help:"when dry run, output unified diff" negatable:"" default:"true" json:"unified,omitempty"`
	TagStrategy        *string `` /* 142-byte string literal not displayed */
}

func (*DeployCommandOption) DeployOption added in v0.6.0

func (cmd *DeployCommandOption) DeployOption() DeployOption

type DeployOption

type DeployOption struct {
	DryRun             bool
	TriggerEnabled     *bool
	SkipStateMachine   bool
	SkipTrigger        bool
	VersionDescription string
	KeepVersions       int
	Unified            bool
	TagStrategy        *string
}

func (DeployOption) DryRunString

func (opt DeployOption) DryRunString() string

type DeployStateMachineOutput

type DeployStateMachineOutput struct {
	CreationDate           *time.Time
	UpdateDate             *time.Time
	StateMachineArn        *string
	StateMachineVersionArn *string
}

type DescribeStateMachineInput added in v0.6.0

type DescribeStateMachineInput struct {
	Name      string
	Qualifier string
}

type DiffOption added in v0.6.0

type DiffOption struct {
	Unified     bool    `name:"unified" help:"output in unified format" short:"u" default:"true" negatable:"" json:"unified,omitempty"`
	Qualifier   string  `name:"qualifier" help:"qualifier for state machine" default:"" json:"qualifier,omitempty"`
	ExitCode    bool    `name:"exit-code" help:"exit with code 2 if there are differences" default:"false" json:"exit_code,omitempty"`
	SkipTrigger bool    `name:"skip-trigger" help:"Skip trigger diff" default:"false" json:"skip_trigger,omitempty"`
	TagStrategy *string `` /* 142-byte string literal not displayed */
	Ignore      string  `` /* 141-byte string literal not displayed */
}

DiffOption configures App.Diff.

type DiffStringOption added in v0.11.0

type DiffStringOption struct {
	Unified bool
	// TagStrategy is used by StateMachine.DiffString to project the tag
	// set diff would compare against what deploy would actually leave in
	// place under the same strategy.
	TagStrategy TagStrategy
	// ManagedByTagKey is used by EventBridgeRules.DiffString to decide
	// whether a rule slated for deletion is one stefunny manages. The
	// zero value falls back to tagManagedBy.
	ManagedByTagKey string
	// Ignore is a jq query for paths to exclude from the diff. It applies
	// to StateMachine's configuration comparison and to
	// EventBridgeRule(s)/Schedule(s)'s comparison, but not to
	// StateMachine's Definition comparison.
	Ignore string
}

DiffStringOption configures the DiffString methods of StateMachine, EventBridgeRule(s) and Schedule(s). Not every field applies to every method: TagStrategy is StateMachine-only, ManagedByTagKey is EventBridgeRule(s)-only, and Ignore does not apply to StateMachine's Definition comparison.

type EndpointsConfig

type EndpointsConfig struct {
	StepFunctions  string `yaml:"stepfunctions,omitempty" json:"step_functions,omitempty"`
	CloudWatchLogs string `yaml:"cloudwatchlogs,omitempty" json:"cloud_watch_logs,omitempty"`
	STS            string `yaml:"sts,omitempty" json:"sts,omitempty"`
	EventBridge    string `yaml:"eventbridge,omitempty" json:"event_bridge,omitempty"`
	Scheduler      string `yaml:"scheduler,omitempty" json:"scheduler,omitempty"`
}

type EventBridgeRule added in v0.6.0

type EventBridgeRule struct {
	eventbridge.PutRuleInput
	RuleArn           *string                   `yaml:"RuleArn,omitempty" json:"RuleArn,omitempty"`
	CreatedBy         *string                   `yaml:"CreatedBy,omitempty" json:"CreatedBy,omitempty"`
	Target            eventbridgetypes.Target   `yaml:"Target,omitempty" json:"Target,omitempty"`
	AdditionalTargets []eventbridgetypes.Target `yaml:"AdditionalTargets,omitempty" json:"AdditionalTargets,omitempty"`
	ConfigFilePath    *string                   `yaml:"ConfigFilePath,omitempty" json:"ConfigFilePath,omitempty"`
	ConfigFileIndex   int                       `yaml:"ConfigFileIndex,omitempty" json:"ConfigFileIndex,omitempty"`
}

func (*EventBridgeRule) AppendTags added in v0.6.0

func (rule *EventBridgeRule) AppendTags(tags map[string]string)

func (*EventBridgeRule) DeleteTag added in v0.6.0

func (rule *EventBridgeRule) DeleteTag(key string)

func (*EventBridgeRule) DiffString added in v0.6.0

func (rule *EventBridgeRule) DiffString(newRule *EventBridgeRule, opt DiffStringOption) (string, error)

DiffString renders the diff between rule (the current state, possibly nil) and newRule (the desired state). opt.Ignore excludes matching paths from the comparison. Returns an error if opt.Ignore is an invalid jq query.

func (*EventBridgeRule) IsManagedBy added in v0.6.0

func (rule *EventBridgeRule) IsManagedBy(key string) bool

func (*EventBridgeRule) SetEnabled added in v0.6.0

func (rule *EventBridgeRule) SetEnabled(enabled bool)

func (*EventBridgeRule) SetStateMachineQualifiedArn added in v0.6.0

func (rule *EventBridgeRule) SetStateMachineQualifiedArn(stateMachineArn string)

func (*EventBridgeRule) Source added in v0.8.4

func (rule *EventBridgeRule) Source() string

func (*EventBridgeRule) String added in v0.6.0

func (rule *EventBridgeRule) String() string

type EventBridgeRules added in v0.6.0

type EventBridgeRules []*EventBridgeRule

func (EventBridgeRules) AppendTags added in v0.7.3

func (rules EventBridgeRules) AppendTags(tags map[string]string)

func (EventBridgeRules) DiffString added in v0.6.0

func (rules EventBridgeRules) DiffString(newRules EventBridgeRules, opt DiffStringOption) (string, error)

DiffString renders the diff between rules (the current state) and newRules (the desired state), matched by name. A rule slated for deletion is skipped unless it is managed by opt.ManagedByTagKey, which defaults to tagManagedBy when left at its zero value. opt.Ignore excludes matching paths from each rule's comparison. Returns an error if opt.Ignore is an invalid jq query.

func (EventBridgeRules) FindByName added in v0.6.0

func (rules EventBridgeRules) FindByName(name string) (*EventBridgeRule, bool)

func (EventBridgeRules) Len added in v0.6.0

func (rules EventBridgeRules) Len() int

sort.Interfaces

func (EventBridgeRules) Less added in v0.6.0

func (rules EventBridgeRules) Less(i, j int) bool

func (EventBridgeRules) Names added in v0.6.0

func (rules EventBridgeRules) Names() []string

func (EventBridgeRules) SetEnabled added in v0.6.0

func (rules EventBridgeRules) SetEnabled(enabled bool)

func (EventBridgeRules) SetStateMachineQualifiedArn added in v0.6.0

func (rules EventBridgeRules) SetStateMachineQualifiedArn(stateMachineArn string)

func (EventBridgeRules) String added in v0.6.0

func (rules EventBridgeRules) String() string

func (EventBridgeRules) Swap added in v0.6.0

func (rules EventBridgeRules) Swap(i, j int)

func (EventBridgeRules) SyncState added in v0.6.0

func (rules EventBridgeRules) SyncState(other EventBridgeRules)

type EventBridgeService added in v0.6.0

type EventBridgeService interface {
	SearchRelatedRules(ctx context.Context, params *SearchRelatedRulesInput) (EventBridgeRules, error)
	DeployRules(ctx context.Context, stateMachineArn string, rules EventBridgeRules, keepState bool) error
	SetManagedByTagKey(key string)
}

type EventBridgeServiceImpl added in v0.6.0

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

func NewEventBridgeService added in v0.6.0

func NewEventBridgeService(client EventBridgeClient) *EventBridgeServiceImpl

func (*EventBridgeServiceImpl) DeployRules added in v0.6.0

func (svc *EventBridgeServiceImpl) DeployRules(ctx context.Context, stateMachineArn string, rules EventBridgeRules, keepState bool) error

func (*EventBridgeServiceImpl) SearchRelatedRules added in v0.6.0

func (svc *EventBridgeServiceImpl) SearchRelatedRules(ctx context.Context, params *SearchRelatedRulesInput) (EventBridgeRules, error)

func (*EventBridgeServiceImpl) SetManagedByTagKey added in v0.11.0

func (svc *EventBridgeServiceImpl) SetManagedByTagKey(key string)

SetManagedByTagKey overrides the tag key putRule and deleteRule use to mark and recognize rules stefunny manages.

type ExecuteOption added in v0.3.0

type ExecuteOption struct {
	Stdout io.Writer `kong:"-" json:"-"`
	Stderr io.Writer `kong:"-" json:"-"`

	Input         string  `name:"input" help:"input JSON string" default:"-" type:"existingfile" json:"input,omitempty"`
	ExecutionName string  `name:"name" help:"execution name" default:"" json:"name,omitempty"`
	Async         bool    `name:"async" help:"start execution and return immediately" json:"async,omitempty"`
	DumpHistory   bool    `name:"dump-history" help:"dump execution history" json:"dump_history,omitempty"`
	Qualifier     *string `name:"qualifier" help:"state machine version qualifier" json:"qualifier,omitempty"`
}

type GetStateMachineArnInput added in v0.6.0

type GetStateMachineArnInput struct {
	Name string
}

type HistoryEvent added in v0.3.0

type HistoryEvent struct {
	StartDate time.Time
	Step      string
	sfntypes.HistoryEvent
}

func (HistoryEvent) Elapsed added in v0.3.0

func (event HistoryEvent) Elapsed() time.Duration

type InitOption added in v0.6.0

type InitOption struct {
	StateMachineName   string   ``                                                                                  /* 137-byte string literal not displayed */
	DefinitionFilePath string   ``                                                                                  /* 149-byte string literal not displayed */
	TFState            string   `kong:"-" help:"Path to terraform state file" type:"path" json:"tfstate,omitempty"` // TODO: if removed global flag, not ignore this flag for kong
	Envs               []string `name:"env" help:"templateize environment variables" json:"envs,omitempty"`
	MustEnvs           []string `name:"must-env" help:"templateize must environment variables" json:"must_envs,omitempty"`
	SkipTrigger        bool     `name:"skip-trigger" help:"Skip trigger" json:"skip_trigger,omitempty"`
	ConfigPath         string   `kong:"-" json:"-"`
	AWSRegion          string   `kong:"-" json:"-"`
}

type JSONDiffOption added in v0.6.0

type JSONDiffOption func(*jsonDiffParams)

func JSONDiffFromURI added in v0.6.0

func JSONDiffFromURI(uri string) JSONDiffOption

func JSONDiffIgnore added in v0.11.0

func JSONDiffIgnore(query string) JSONDiffOption

JSONDiffIgnore sets a jq query whose matched paths are removed from both sides before they are compared. query is wrapped as del(<query>); an empty query disables filtering.

func JSONDiffToURI added in v0.6.0

func JSONDiffToURI(uri string) JSONDiffOption

func JSONDiffUnified added in v0.6.0

func JSONDiffUnified(b bool) JSONDiffOption

type KeysToSnakeCase added in v0.6.0

type KeysToSnakeCase[T any] struct {
	Value  T
	Strict bool `yaml:"-"`
}

KeysToSnakeCase converts the keys of the given object to snake case. The given object is expected struct, json struct key is CamelCase.

func NewKeysToSnakeCase added in v0.6.0

func NewKeysToSnakeCase[T any](v T) KeysToSnakeCase[T]

func (KeysToSnakeCase[T]) MarshalJSON added in v0.6.0

func (k KeysToSnakeCase[T]) MarshalJSON() ([]byte, error)

func (KeysToSnakeCase[T]) MarshalYAML added in v0.6.0

func (k KeysToSnakeCase[T]) MarshalYAML() (interface{}, error)

func (*KeysToSnakeCase[T]) UnmarshalJSON added in v0.6.0

func (k *KeysToSnakeCase[T]) UnmarshalJSON(bs []byte) error

type ListStateMachineVersionsOutput added in v0.6.0

type ListStateMachineVersionsOutput struct {
	StateMachineArn string
	Versions        []StateMachineVersionListItem
}

type NewAppOption added in v0.6.0

type NewAppOption func(*App)

NewAppOption configures an App constructed by New.

func WithEventBridgeClient added in v0.6.0

func WithEventBridgeClient(eventBridgeClient EventBridgeClient) NewAppOption

WithEventBridgeClient sets the EventBridge client for New(ctx, cfg, opts...) this is for testing

func WithEventBridgeService added in v0.6.0

func WithEventBridgeService(eventBridgeService EventBridgeService) NewAppOption

WithEventBridgeService sets the EventBridge service for New(ctx, cfg, opts...)

func WithSFnClient added in v0.6.0

func WithSFnClient(sfnClient SFnClient) NewAppOption

WithSFNClient sets the SFn client for New(ctx, cfg, opts...) this is for testing

func WithSFnService added in v0.6.0

func WithSFnService(sfnService SFnService) NewAppOption

WithSFnService sets the SFn service for New(ctx, cfg, opts...)

func WithSchedulerClient added in v0.6.0

func WithSchedulerClient(schedulerClient SchedulerClient) NewAppOption

func WithSchedulerService added in v0.6.0

func WithSchedulerService(schedulerService SchedulerService) NewAppOption

type OrderdMap added in v0.6.0

type OrderdMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func ListResourcesFromTFState added in v0.6.0

func ListResourcesFromTFState(ctx context.Context, loc string) (*OrderdMap[string, string], error)

ListResourcesFromTFState returns resource arn, security group id, vpc id, subnet id, and caller account_id

func NewOrderdMap added in v0.6.0

func NewOrderdMap[K comparable, V any]() *OrderdMap[K, V]

func (*OrderdMap[K, V]) Get added in v0.6.0

func (m *OrderdMap[K, V]) Get(key K) (V, bool)

func (*OrderdMap[K, V]) Keys added in v0.6.0

func (m *OrderdMap[K, V]) Keys() []K

func (*OrderdMap[K, V]) Len added in v0.6.0

func (m *OrderdMap[K, V]) Len() int

func (*OrderdMap[K, V]) Set added in v0.6.0

func (m *OrderdMap[K, V]) Set(key K, value V)

func (*OrderdMap[K, V]) Values added in v0.6.0

func (m *OrderdMap[K, V]) Values() []V

type OutputFormatter added in v0.6.0

type OutputFormatter struct {
	Data   *ListStateMachineVersionsOutput
	Format string
}

func (OutputFormatter) JSON added in v0.6.0

func (f OutputFormatter) JSON() (string, error)

JSON renders f.Data.Versions as an indented JSON string. Returns an error if marshaling or indenting fails.

func (OutputFormatter) Render added in v0.10.0

func (f OutputFormatter) Render() (string, error)

Render returns f's string representation according to f.Format ("json", "tsv", or table by default). Returns an error if the table format fails to render (see Table).

Named Render rather than String because f can fail to format and therefore does not satisfy fmt.Stringer.

func (OutputFormatter) TSV added in v0.6.0

func (f OutputFormatter) TSV() string

func (OutputFormatter) Table added in v0.6.0

func (f OutputFormatter) Table() (string, error)

Table renders f.Data.Versions as a table string. Returns an error if the underlying tablewriter fails to append rows or render.

type PullOption added in v0.6.0

type PullOption struct {
	Templateize bool   `name:"templateize" default:"true" negatable:"" help:"templateize output"`
	Qualifier   string `name:"qualifier" help:"qualifier for the version"`
}

type RenderOption

type RenderOption struct {
	Writer  io.Writer `kong:"-" json:"-"`
	Targets []string  `arg:"" help:"target to render (config, definition, def)" enum:"config,definition,def" json:"targets,omitempty"`
	Format  string    `name:"format" help:"output format(json, jsonnet, yaml)" default:"" enum:",json,jsonnet,yaml" json:"format,omitempty"`
}

type Renderer added in v0.6.0

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

func NewRenderer added in v0.6.0

func NewRenderer(cfg *Config) *Renderer

func (*Renderer) CreateConfigFile added in v0.6.0

func (r *Renderer) CreateConfigFile(ctx context.Context, path string, template bool) error

func (*Renderer) CreateDefinitionFile added in v0.6.0

func (r *Renderer) CreateDefinitionFile(ctx context.Context, path string, template bool) error

func (*Renderer) RenderConfig added in v0.6.0

func (r *Renderer) RenderConfig(ctx context.Context, w io.Writer, format string, template bool) error

RenderConfig renders the stefunny config (excluding the state machine definition body) to w. In json/jsonnet format, keys whose value is null, false, an empty string, or an empty array are dropped, since those AWS SDK-derived fields treat the zero value as "unset".

func (*Renderer) RenderStateMachine added in v0.6.0

func (r *Renderer) RenderStateMachine(ctx context.Context, w io.Writer, format string, template bool) error

RenderStateMachine renders the state machine definition to w. Unlike RenderConfig, the definition is a user-authored document, so in json/jsonnet format its null/false/empty-string/ empty-array values are preserved as-is rather than pruned.

type RollbackOption added in v0.6.0

type RollbackOption struct {
	DryRun      bool `name:"dry-run" help:"Dry run" json:"dry_run,omitempty"`
	KeepVersion bool `name:"keep-version" help:"Keep current version, no delete" json:"keep_version,omitempty"`
}

func (RollbackOption) DryRunString added in v0.6.0

func (opt RollbackOption) DryRunString() string

type RulesStatus added in v0.6.0

type RulesStatus struct {
	RuleArn            string  `json:"rule_arn,omitempty"`
	RuleName           string  `json:"rule_name"`
	Status             string  `json:"status"`
	ScheduleExpression *string `json:"schedule_expression,omitempty"`
	EventPattern       *string `json:"event_pattern,omitempty"`
	Target             string  `json:"target,omitempty"`
}

func (*RulesStatus) String added in v0.6.0

func (r *RulesStatus) String() string

type SFnClient

type SFnClient interface {
	sfn.ListStateMachinesAPIClient
	sfnx.ListStateMachineAliasesAPIClient
	sfnx.ListStateMachineVersionsAPIClient
	CreateStateMachine(ctx context.Context, params *sfn.CreateStateMachineInput, optFns ...func(*sfn.Options)) (*sfn.CreateStateMachineOutput, error)
	CreateStateMachineAlias(ctx context.Context, params *sfn.CreateStateMachineAliasInput, optFns ...func(*sfn.Options)) (*sfn.CreateStateMachineAliasOutput, error)
	DescribeStateMachine(ctx context.Context, params *sfn.DescribeStateMachineInput, optFns ...func(*sfn.Options)) (*sfn.DescribeStateMachineOutput, error)
	DescribeStateMachineAlias(ctx context.Context, params *sfn.DescribeStateMachineAliasInput, optFns ...func(*sfn.Options)) (*sfn.DescribeStateMachineAliasOutput, error)
	UpdateStateMachine(ctx context.Context, params *sfn.UpdateStateMachineInput, optFns ...func(*sfn.Options)) (*sfn.UpdateStateMachineOutput, error)
	UpdateStateMachineAlias(ctx context.Context, params *sfn.UpdateStateMachineAliasInput, optFns ...func(*sfn.Options)) (*sfn.UpdateStateMachineAliasOutput, error)
	DeleteStateMachine(ctx context.Context, params *sfn.DeleteStateMachineInput, optFns ...func(*sfn.Options)) (*sfn.DeleteStateMachineOutput, error)
	DeleteStateMachineVersion(ctx context.Context, params *sfn.DeleteStateMachineVersionInput, optFns ...func(*sfn.Options)) (*sfn.DeleteStateMachineVersionOutput, error)
	ListTagsForResource(ctx context.Context, params *sfn.ListTagsForResourceInput, optFns ...func(*sfn.Options)) (*sfn.ListTagsForResourceOutput, error)
	StartExecution(ctx context.Context, params *sfn.StartExecutionInput, optFns ...func(*sfn.Options)) (*sfn.StartExecutionOutput, error)
	StartSyncExecution(ctx context.Context, params *sfn.StartSyncExecutionInput, optFns ...func(*sfn.Options)) (*sfn.StartSyncExecutionOutput, error)
	DescribeExecution(ctx context.Context, params *sfn.DescribeExecutionInput, optFns ...func(*sfn.Options)) (*sfn.DescribeExecutionOutput, error)
	StopExecution(ctx context.Context, params *sfn.StopExecutionInput, optFns ...func(*sfn.Options)) (*sfn.StopExecutionOutput, error)
	GetExecutionHistory(ctx context.Context, params *sfn.GetExecutionHistoryInput, optFns ...func(*sfn.Options)) (*sfn.GetExecutionHistoryOutput, error)
	TagResource(ctx context.Context, params *sfn.TagResourceInput, optFns ...func(*sfn.Options)) (*sfn.TagResourceOutput, error)
	UntagResource(ctx context.Context, params *sfn.UntagResourceInput, optFns ...func(*sfn.Options)) (*sfn.UntagResourceOutput, error)
}

type SFnService added in v0.6.0

type SFnService interface {
	DescribeStateMachine(ctx context.Context, params *DescribeStateMachineInput) (*StateMachine, error)
	GetStateMachineArn(ctx context.Context, params *GetStateMachineArnInput) (string, error)
	DeployStateMachine(ctx context.Context, stateMachine *StateMachine, tagStrategy TagStrategy) (*DeployStateMachineOutput, error)
	DeleteStateMachine(ctx context.Context, stateMachine *StateMachine) error
	RollbackStateMachine(ctx context.Context, stateMachine *StateMachine, keepVersion bool, dryRun bool) error
	ListStateMachineVersions(ctx context.Context, stateMachine *StateMachine) (*ListStateMachineVersionsOutput, error)
	PurgeStateMachineVersions(ctx context.Context, stateMachine *StateMachine, keepVersions int) error
	StartExecution(ctx context.Context, stateMachine *StateMachine, params *StartExecutionInput) (*StartExecutionOutput, error)
	GetExecutionHistory(ctx context.Context, executionArn string) ([]HistoryEvent, error)
	SetAliasName(aliasName string)
	SetManagedByTagKey(key string)
}

type SFnServiceImpl added in v0.6.0

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

func NewSFnService added in v0.6.0

func NewSFnService(client SFnClient) *SFnServiceImpl

func (*SFnServiceImpl) DeleteStateMachine added in v0.6.0

func (svc *SFnServiceImpl) DeleteStateMachine(ctx context.Context, stateMachine *StateMachine) error

func (*SFnServiceImpl) DeployStateMachine added in v0.6.0

func (svc *SFnServiceImpl) DeployStateMachine(ctx context.Context, stateMachine *StateMachine, tagStrategy TagStrategy) (*DeployStateMachineOutput, error)

DeployStateMachine creates or updates the state machine. tagStrategy governs the update path only (see updateStateMachineTags); a create always tags the new resource with stateMachine.Tags regardless of tagStrategy, since creation is a single API call rather than the TagResource/UntagResource calls tagStrategy reconciles.

func (*SFnServiceImpl) DescribeStateMachine added in v0.6.0

func (svc *SFnServiceImpl) DescribeStateMachine(ctx context.Context, params *DescribeStateMachineInput) (*StateMachine, error)

func (*SFnServiceImpl) GetExecutionHistory added in v0.6.0

func (svc *SFnServiceImpl) GetExecutionHistory(ctx context.Context, executionArn string) ([]HistoryEvent, error)

func (*SFnServiceImpl) GetStateMachineArn added in v0.6.0

func (svc *SFnServiceImpl) GetStateMachineArn(ctx context.Context, params *GetStateMachineArnInput) (string, error)

func (*SFnServiceImpl) ListStateMachineVersions added in v0.6.0

func (svc *SFnServiceImpl) ListStateMachineVersions(ctx context.Context, stateMachine *StateMachine) (*ListStateMachineVersionsOutput, error)

func (*SFnServiceImpl) PurgeStateMachineVersions added in v0.6.0

func (svc *SFnServiceImpl) PurgeStateMachineVersions(ctx context.Context, stateMachine *StateMachine, keepVerions int) error

func (*SFnServiceImpl) RollbackStateMachine added in v0.6.0

func (svc *SFnServiceImpl) RollbackStateMachine(ctx context.Context, stateMachine *StateMachine, keepVersion bool, dryRun bool) error

func (*SFnServiceImpl) SetAliasName added in v0.6.0

func (svc *SFnServiceImpl) SetAliasName(aliasName string)

func (*SFnServiceImpl) SetManagedByTagKey added in v0.11.0

func (svc *SFnServiceImpl) SetManagedByTagKey(key string)

SetManagedByTagKey overrides the tag key DeployStateMachine uses to mark state machines stefunny manages.

func (*SFnServiceImpl) StartExecution added in v0.6.0

func (svc *SFnServiceImpl) StartExecution(ctx context.Context, stateMachine *StateMachine, params *StartExecutionInput) (*StartExecutionOutput, error)

type STSClient added in v0.10.0

type STSClient interface {
	GetCallerIdentity(ctx context.Context, params *sts.GetCallerIdentityInput, optFns ...func(*sts.Options)) (*sts.GetCallerIdentityOutput, error)
}

STSClient is the subset of the STS API used to resolve caller_identity.

type Schedule added in v0.6.0

type Schedule struct {
	scheduler.CreateScheduleInput
	ScheduleArn     *string    `min:"1" type:"string"`
	CreationDate    *time.Time `type:"timestamp"`
	ConfigFilePath  *string
	ConfigFileIndex int
}

func (*Schedule) DiffString added in v0.6.0

func (s *Schedule) DiffString(newSchedule *Schedule, opt DiffStringOption) (string, error)

DiffString renders the diff between s (the current state, possibly nil) and newSchedule (the desired state). opt.Ignore excludes matching paths from the comparison. Returns an error if opt.Ignore is an invalid jq query.

func (*Schedule) HasItPassed added in v0.6.0

func (s *Schedule) HasItPassed() bool

func (*Schedule) SetEnabled added in v0.6.0

func (s *Schedule) SetEnabled(enabled bool)

func (*Schedule) SetStateMachineQualifiedArn added in v0.6.0

func (s *Schedule) SetStateMachineQualifiedArn(stateMachineArn string)

func (*Schedule) Source added in v0.8.4

func (s *Schedule) Source() string

func (*Schedule) String added in v0.6.0

func (s *Schedule) String() string

type ScheduleCommandOption added in v0.6.0

type ScheduleCommandOption struct {
	DryRun   bool `name:"dry-run" help:"Dry run" json:"dry_run,omitempty"`
	Enabled  bool `name:"enabled" help:"Enable schedule" xor:"schedule" required:"" json:"enabled,omitempty"`
	Disabled bool `name:"disabled" help:"Disable schedule" xor:"schedule" required:"" json:"disabled,omitempty"`
}

func (*ScheduleCommandOption) DeployOption added in v0.6.0

func (cmd *ScheduleCommandOption) DeployOption() DeployOption

type ScheduleConfig

type ScheduleConfig struct {
	ID          string `yaml:"id,omitempty" json:"id,omitempty"`
	RuleName    string `yaml:"rule_name,omitempty" json:"rule_name,omitempty"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
	Expression  string `yaml:"expression,omitempty" json:"expression,omitempty"`
	RoleArn     string `yaml:"role_arn,omitempty" json:"role_arn,omitempty"`
}

type ScheduleStatus added in v0.6.0

type ScheduleStatus struct {
	ScheduleName               string `json:"schedule_name"`
	ScheduleArn                string `json:"schedule_arn,omitempty"`
	Status                     string `json:"status"`
	ScheduleExpression         string `json:"schedule_expression"`
	ScheduleExpressionTimezone string `json:"schedule_expression_timezone"`
	Target                     string `json:"target,omitempty"`
}

func (*ScheduleStatus) String added in v0.6.0

func (s *ScheduleStatus) String() string

type SchedulerClient added in v0.6.0

type SchedulerClient interface {
	CreateSchedule(ctx context.Context, params *scheduler.CreateScheduleInput, optFns ...func(*scheduler.Options)) (*scheduler.CreateScheduleOutput, error)
	DeleteSchedule(ctx context.Context, params *scheduler.DeleteScheduleInput, optFns ...func(*scheduler.Options)) (*scheduler.DeleteScheduleOutput, error)
	GetSchedule(ctx context.Context, params *scheduler.GetScheduleInput, optFns ...func(*scheduler.Options)) (*scheduler.GetScheduleOutput, error)
	ListSchedules(ctx context.Context, params *scheduler.ListSchedulesInput, optFns ...func(*scheduler.Options)) (*scheduler.ListSchedulesOutput, error)
	ListScheduleGroups(ctx context.Context, params *scheduler.ListScheduleGroupsInput, optFns ...func(*scheduler.Options)) (*scheduler.ListScheduleGroupsOutput, error)
	UpdateSchedule(ctx context.Context, params *scheduler.UpdateScheduleInput, optFns ...func(*scheduler.Options)) (*scheduler.UpdateScheduleOutput, error)
}

type SchedulerService added in v0.6.0

type SchedulerService interface {
	SearchRelatedSchedules(ctx context.Context, params *SearchRelatedSchedulesInput) (Schedules, error)
	DeploySchedules(ctx context.Context, stateMachineArn string, rules Schedules, keepState bool) error
}

type SchedulerServiceImpl added in v0.6.0

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

func NewSchedulerService added in v0.6.0

func NewSchedulerService(client SchedulerClient) *SchedulerServiceImpl

func (*SchedulerServiceImpl) DeploySchedules added in v0.6.0

func (svc *SchedulerServiceImpl) DeploySchedules(ctx context.Context, stateMachineArn string, schedules Schedules, keepState bool) error

func (*SchedulerServiceImpl) SearchRelatedSchedules added in v0.6.0

func (svc *SchedulerServiceImpl) SearchRelatedSchedules(ctx context.Context, params *SearchRelatedSchedulesInput) (Schedules, error)

type Schedules added in v0.6.0

type Schedules []*Schedule

func (Schedules) DiffString added in v0.6.0

func (s Schedules) DiffString(newSchedules Schedules, opt DiffStringOption) (string, error)

DiffString renders the diff between s (the current state) and newSchedules (the desired state), matched by name. opt.Ignore excludes matching paths from each schedule's comparison. Returns an error if opt.Ignore is an invalid jq query.

func (Schedules) FilterPassed added in v0.6.0

func (s Schedules) FilterPassed() (result, passed Schedules)

func (Schedules) FindByName added in v0.6.0

func (s Schedules) FindByName(name string) (*Schedule, bool)

func (Schedules) Len added in v0.6.0

func (s Schedules) Len() int

func (Schedules) Less added in v0.6.0

func (s Schedules) Less(i, j int) bool

func (Schedules) Names added in v0.6.0

func (s Schedules) Names() []string

func (Schedules) SetEnabled added in v0.6.0

func (s Schedules) SetEnabled(enabled bool)

func (Schedules) SetStateMachineQualifiedArn added in v0.6.0

func (s Schedules) SetStateMachineQualifiedArn(stateMachineArn string)

func (Schedules) String added in v0.6.0

func (s Schedules) String() string

func (Schedules) Swap added in v0.6.0

func (s Schedules) Swap(i, j int)

func (Schedules) SyncState added in v0.6.0

func (s Schedules) SyncState(other Schedules)

type SearchRelatedRulesInput added in v0.6.0

type SearchRelatedRulesInput struct {
	StateMachineQualifiedArn string
	RuleNames                []string
}

type SearchRelatedSchedulesInput added in v0.6.0

type SearchRelatedSchedulesInput struct {
	StateMachineQualifiedArn string
	ScheduleNames            []string
}

type StartExecutionInput added in v0.6.0

type StartExecutionInput struct {
	ExecutionName string
	Input         string
	Qualifier     *string
	Target        string
	Async         bool
}

type StartExecutionOutput added in v0.3.0

type StartExecutionOutput struct {
	CanNotDumpHistory bool
	ExecutionArn      string
	StartDate         time.Time
	Success           *bool
	Failed            *bool
	StopDate          *time.Time
	Output            *string
	Datail            interface{}
}

func (*StartExecutionOutput) Elapsed added in v0.6.0

func (o *StartExecutionOutput) Elapsed() time.Duration

type StateMachine

type StateMachine struct {
	sfn.CreateStateMachineInput
	CreationDate    *time.Time
	LastUpdateDate  *time.Time
	StateMachineArn *string
	Status          sfntypes.StateMachineStatus
	ConfigFilePath  *string
	DefinitionPath  *string
}

func (*StateMachine) AppendTags added in v0.6.0

func (s *StateMachine) AppendTags(tags map[string]string)

func (*StateMachine) DefinitionSource added in v0.8.4

func (s *StateMachine) DefinitionSource() string

func (*StateMachine) DeleteTag added in v0.6.0

func (s *StateMachine) DeleteTag(key string)

func (*StateMachine) DiffString

func (s *StateMachine) DiffString(newStateMachine *StateMachine, opt DiffStringOption) (string, error)

DiffString renders the diff between s (the current state, possibly nil) and newStateMachine (the desired state). The tag portion of the diff reflects the tag set opt.TagStrategy would actually leave in place, not newStateMachine's raw tags, so it stays consistent with what a deploy under the same strategy would do. opt.Ignore applies to the configuration comparison only, not to the Definition comparison. Returns an error if opt.Ignore is an invalid jq query.

func (*StateMachine) QualifiedArn added in v0.6.0

func (s *StateMachine) QualifiedArn(name string) string

func (*StateMachine) Source added in v0.8.4

func (s *StateMachine) Source() string

func (*StateMachine) String

func (s *StateMachine) String() string

type StateMachineConfig

type StateMachineConfig struct {
	KeysToSnakeCase[sfn.CreateStateMachineInput] `yaml:",inline" json:",inline"`
	DefinitionPath                               string `yaml:"definition_path,omitempty" json:"definition_path,omitempty"`

	Logging *StateMachineLogging           `yaml:"-,omitempty"`
	Tracing *sfntypes.TracingConfiguration `yaml:"-,omitempty"`
}

func (*StateMachineConfig) Restrict

func (cfg *StateMachineConfig) Restrict() error

Restrict restricts a configuration.

func (*StateMachineConfig) SetDefinition added in v0.6.0

func (cfg *StateMachineConfig) SetDefinition(definition string)

func (*StateMachineConfig) SetDetinitionPath added in v0.6.0

func (cfg *StateMachineConfig) SetDetinitionPath(path string)

func (*StateMachineConfig) UnmarshalJSON added in v0.6.0

func (cfg *StateMachineConfig) UnmarshalJSON(b []byte) error

type StateMachineLogging added in v0.6.0

type StateMachineLogging struct {
	Level                string                          `yaml:"level,omitempty" json:"level,omitempty"`
	IncludeExecutionData bool                            `yaml:"include_execution_data,omitempty" json:"include_execution_data,omitempty"`
	Destination          *StateMachineLoggingDestination `yaml:"destination,omitempty" json:"destination,omitempty"`
}

type StateMachineLoggingDestination added in v0.6.0

type StateMachineLoggingDestination struct {
	LogGroup string `yaml:"log_group,omitempty" json:"log_group,omitempty"`
}

type StateMachineStatus added in v0.6.0

type StateMachineStatus struct {
	Arn            string `json:"arn"`
	Name           string `json:"name"`
	CurrentVersion int    `json:"current_version"`
	Status         string `json:"status"`
	CreatedAt      string `json:"created_at"`
}

func (*StateMachineStatus) String added in v0.6.0

func (s *StateMachineStatus) String() string

type StateMachineVersionListItem added in v0.6.0

type StateMachineVersionListItem struct {
	StateMachineVersionArn string
	Version                int       `json:"version"`
	Aliases                []string  `json:"aliases,omitempty"`
	Description            string    `json:"description,omitempty"`
	CreationDate           time.Time `json:"creation_date"`
	RevisionID             string    `json:"revision_id,omitempty"`
}

type StatusOption added in v0.6.0

type StatusOption struct {
	Format string `name:"format" help:"output format(text,json)" default:"text" enum:"text,json" json:"format,omitempty"`
	Latest bool   `name:"latest" help:"show latest state machine" default:"false" json:"latest,omitempty"`
}

type StatusOutput added in v0.6.0

type StatusOutput struct {
	StateMachine         *StateMachineStatus `json:"state_machine"`
	EventBridge          []*RulesStatus      `json:"event_bridge,omitempty"`
	EventBridgeScheduler []*ScheduleStatus   `json:"event_bridge_scheduler,omitempty"`
}

func (*StatusOutput) String added in v0.6.0

func (s *StatusOutput) String() string

type StudioOption added in v0.6.0

type StudioOption struct {
	Open bool `name:"open" help:"open workflow studio"`
}

type TFStateConfig added in v0.6.0

type TFStateConfig struct {
	FuncPrefix string `yaml:"func_prefix,omitempty" json:"func_prefix,omitempty"`
	Location   string `yaml:"location,omitempty" json:"location,omitempty"`
}

type TagStrategy added in v0.11.0

type TagStrategy string

TagStrategy controls how deploy reconciles a state machine's tags with the config, and how diff reports tag differences accordingly.

const (
	// TagStrategyAppendOnly adds or updates tags found in the config but
	// never removes a tag that only exists on the live resource.
	TagStrategyAppendOnly TagStrategy = "append_only"
	// TagStrategySync makes the live resource's tags match the config
	// exactly, removing any tag not present in the config.
	TagStrategySync TagStrategy = "sync"
	// TagStrategyNone leaves the live resource's tags untouched.
	TagStrategyNone TagStrategy = "none"
)

type TriggerConfig added in v0.6.0

type TriggerConfig struct {
	Schedule []TriggerScheduleConfig `yaml:"schedule,omitempty" json:"schedule,omitempty"`
	Event    []TriggerEventConfig    `yaml:"event,omitempty" json:"event,omitempty"`
}

func (*TriggerConfig) Restrict added in v0.6.0

func (cfg *TriggerConfig) Restrict(stateMachineName string) error

type TriggerEventConfig added in v0.6.0

type TriggerEventConfig struct {
	KeysToSnakeCase[TriggerEventConfigInner] `yaml:",inline" json:",inline"`
}

func (*TriggerEventConfig) Restrict added in v0.6.0

func (cfg *TriggerEventConfig) Restrict(i int, stateMachineName string) error

func (*TriggerEventConfig) UnmarshalJSON added in v0.6.0

func (cfg *TriggerEventConfig) UnmarshalJSON(b []byte) error

type TriggerEventConfigInner added in v0.6.0

type TriggerEventConfigInner struct {
	eventbridge.PutRuleInput `yaml:",inline"`
	Target                   eventbridgetypes.Target `yaml:"Target,omitempty" json:"Target,omitempty"`
}

type TriggerScheduleConfig added in v0.6.0

type TriggerScheduleConfig struct {
	KeysToSnakeCase[scheduler.CreateScheduleInput] `yaml:",inline" json:",inline"`
}

func (*TriggerScheduleConfig) Restrict added in v0.6.0

func (cfg *TriggerScheduleConfig) Restrict(i int, stateMachineName string) error

func (*TriggerScheduleConfig) UnmarshalJSON added in v0.6.0

func (cfg *TriggerScheduleConfig) UnmarshalJSON(b []byte) error

type VersionsOption added in v0.6.0

type VersionsOption struct {
	Format       string `help:"versions list format" default:"table" enum:"table,json,tsv" json:"format,omitempty"`
	Delete       bool   `help:"delete older versions" default:"false" json:"delete,omitempty"`
	KeepVersions int    `` /* 130-byte string literal not displayed */
}

Directories

Path Synopsis
cmd
stefunny command
internal
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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