aws

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AWSAccessKeyID string
	AWSSecretKey   string
	AWSRegion      string
)
View Source
var Cmd = &cobra.Command{
	Version: "v0.0.1",
	Use:     "aws",
	Long: `The 'aws' command automate and perform several aws-related actions (E.
g: push images to ECR, deploy into ECS, etc.).
You can specify the tasks you want to perform using the provided --task flag.`,
	Example: `
  # Push an image into ECR:
  stiletto aws ecr --task=push`,
	Run: func(cmd *cobra.Command, args []string) {
		_ = cmd.Help()
	},
}
View Source
var ECRCmd = &cobra.Command{
	Version: "v0.0.1",
	Use:     "ecr",
	Long: `The 'ecr' command automates and implement actions on top of AWS Elastic Container
Registry`,
	Example: `
  # Push an image into ECR:
  stiletto aws ecr --task=push`,
	Run: func(cmd *cobra.Command, args []string) {

		ux := tui.TUITitle{}
		msg := tui.NewTUIMessage()
		config.ShowCLITitle()

		cliGlobalArgs := config.GetCLIGlobalArgs()

		p, err := pipeline.New(cliGlobalArgs.WorkingDir, cliGlobalArgs.MountDir,
			cliGlobalArgs.TargetDir, cliGlobalArgs.TaskName,
			cliGlobalArgs.ScanEnvVarKeys,
			cliGlobalArgs.EnvKeyValuePairsToSetString, cliGlobalArgs.ScanAWSKeys,
			cliGlobalArgs.ScanTerraformVars, cliGlobalArgs.InitDaggerWithWorkDirByDefault)

		if err != nil {
			msg.ShowError("INIT", "Failed pipeline initialization", err)
			os.Exit(1)
		}

		ux.ShowSubTitle("JOB:", "AWS-ECR")
		ux.ShowInitDetails("ECR", cliGlobalArgs.TaskName, p.PipelineOpts.WorkDirPath,
			p.PipelineOpts.TargetDirPath, p.PipelineOpts.MountDirPath)

		j, err := job.NewJob(p, job.InitOptions{
			Name:  cliGlobalArgs.TaskName,
			Stack: "AWS",

			PipelineCfg: p,

			WorkDir:   p.PipelineOpts.WorkDir,
			TargetDir: p.PipelineOpts.TargetDir,
			MountDir:  p.PipelineOpts.MountDir,

			ScanAWSEnvVars:       cliGlobalArgs.ScanAWSKeys,
			ScanTerraformEnvVars: cliGlobalArgs.ScanTerraformVars,
			EnvVarsToSet:         cliGlobalArgs.EnvKeyValuePairsToSetString,
			EnvVarsToScan:        cliGlobalArgs.ScanEnvVarKeys,
		})

		if err != nil {
			msg.ShowError("INIT", "Failed job initialization", err)
			os.Exit(1)
		}

		ux.ShowSubTitle("TASK:", cliGlobalArgs.TaskName)
		ux.ShowTaskDetails("DOCKER", cliGlobalArgs.TaskName, j.WorkDirPath, j.TargetDirPath, j.MountDirPath)
		taskErr := task.RunTaskAWSECR(task.InitOptions{

			Task:           cliGlobalArgs.TaskName,
			Stack:          "AWS",
			PipelineCfg:    p,
			JobCfg:         j,
			WorkDir:        p.PipelineOpts.WorkDir,
			MountDir:       p.PipelineOpts.MountDir,
			TargetDir:      p.PipelineOpts.TargetDir,
			ActionCommands: cliGlobalArgs.CustomCommands,
		})

		if taskErr != nil {
			msg.ShowError("", "Failed to run task", taskErr)
			os.Exit(1)
		}
	},
}
View Source
var ECSCmd = &cobra.Command{
	Version: "v0.0.1",
	Use:     "ecs",
	Long: `The 'ecs' command automates and implement several Elastic Container Service actions,
E.g.: 'deploy'`,
	Example: `
  # Deploy a new version of a task running in a ECS service:
  stiletto aws ecs --task=deploy`,
	Run: func(cmd *cobra.Command, args []string) {

		ux := tui.TUITitle{}
		msg := tui.NewTUIMessage()
		config.ShowCLITitle()

		cliGlobalArgs := config.GetCLIGlobalArgs()

		p, err := pipeline.New(cliGlobalArgs.WorkingDir, cliGlobalArgs.MountDir,
			cliGlobalArgs.TargetDir, cliGlobalArgs.TaskName,
			cliGlobalArgs.ScanEnvVarKeys,
			cliGlobalArgs.EnvKeyValuePairsToSetString, cliGlobalArgs.ScanAWSKeys,
			cliGlobalArgs.ScanTerraformVars, cliGlobalArgs.InitDaggerWithWorkDirByDefault)

		if err != nil {
			msg.ShowError("INIT", "Failed pipeline initialization", err)
			os.Exit(1)
		}

		ux.ShowSubTitle("JOB:", "AWS-ECS")
		ux.ShowInitDetails("ECR", cliGlobalArgs.TaskName, p.PipelineOpts.WorkDirPath,
			p.PipelineOpts.TargetDirPath, p.PipelineOpts.MountDirPath)

		j, err := job.NewJob(p, job.InitOptions{
			Name:  cliGlobalArgs.TaskName,
			Stack: "AWS",

			PipelineCfg: p,

			WorkDir:   p.PipelineOpts.WorkDir,
			TargetDir: p.PipelineOpts.TargetDir,
			MountDir:  p.PipelineOpts.MountDir,

			ScanAWSEnvVars:       cliGlobalArgs.ScanAWSKeys,
			ScanTerraformEnvVars: cliGlobalArgs.ScanTerraformVars,
			EnvVarsToSet:         cliGlobalArgs.EnvKeyValuePairsToSetString,
			EnvVarsToScan:        cliGlobalArgs.ScanEnvVarKeys,
		})

		if err != nil {
			msg.ShowError("INIT", "Failed job initialization", err)
			os.Exit(1)
		}

		ux.ShowSubTitle("TASK:", cliGlobalArgs.TaskName)
		ux.ShowTaskDetails("AWS:ECS", cliGlobalArgs.TaskName, j.WorkDirPath, j.TargetDirPath,
			j.MountDirPath)
		taskErr := task.RunTaskAWSECS(task.InitOptions{

			Task:           cliGlobalArgs.TaskName,
			Stack:          "AWS",
			PipelineCfg:    p,
			JobCfg:         j,
			WorkDir:        p.PipelineOpts.WorkDir,
			MountDir:       p.PipelineOpts.MountDir,
			TargetDir:      p.PipelineOpts.TargetDir,
			ActionCommands: cliGlobalArgs.CustomCommands,
		})

		if taskErr != nil {
			msg.ShowError("", "Failed to run task", taskErr)
			os.Exit(1)
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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