Example of cobra go cli interacting with AWS API for automation tasks
|____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
- Prerequisites
Go installation https://golang.org/doc/install
- Go to project root (currently installation is for mac)
make install
- 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>
-
Add <your_profile> to config.yaml
-
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
Bug:
pem file created will need to have chmod modified chmod 400 efskeypair.pem before connecting to ec2 instance