Skip to content

AlexGoja/cobra_cli_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cobra CLI

Example of cobra go cli interacting with AWS API for automation tasks

Structure

|____cmd
|      |____root_command.go -> root command definition
|____LICENSE -> licence
|____Makefile -> installation Makefile
|____config.yaml -> defining aws config profile and region
|____templates
|      |____distributed_file_system.yaml -> keeps cloudformation stacks
|____aws
|      |____version.go -> command to determine version of tool
|      |____session.go -> creates an aws session
|      |____cloudformation.go -> cloudformation aws client
|      |____ec2.go -> ec2 aws client
|____main.go

Install Devops-tool

  1. Prerequisites

Go installation https://golang.org/doc/install

  1. Go to project root (currently installation is for mac)

make install

  1. You will need a user with relevant permissions to interact with the tool. Setup aws with the user's credentials

aws configure --profile <your_profile>

  1. Add <your_profile> to config.yaml

  2. To interact with devops-tool examples

devops-tool help
devops-tool create-efs help
devops-tool delete-efs help

Example creating efs:
devops-tool create-efs -k efskeypair -s efsstack -v vpc-703***09 -m ami-035b3c7efe6d061d5 -n=subnet-49b**02,subnet-55d***79 -c CAPABILITY_NAMED_IAM

Example deleting efs:
devops-tool delete-efs -k efskeypair -s efsstack

Notes

Bug:

pem file created will need to have chmod modified chmod 400 efskeypair.pem before connecting to ec2 instance

Demo Video:

Watch the video

Architecture

Alt text

About

Example of cobra go cli creating a distributed efs system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published