GitHub - aws-samples/aws-codedeploy-appspec-assistant (original) (raw)

aws-codedeploy-appspec-assistant

This repo contains Default AppSpec examples and a script to validate an AppSpec file

CodeDeploy AppSpec examples

Lambda

ECS

EC2/OnPrem

Lambda

ECS

EC2/OnPrem

Expected Server Zip File Structure

# CodeDeploy expects there to be no top-level folder around the AppSpec 
# So when it is unzipped, the AppSpec is put at the top level of the current directory
# NOTE: The scripts folder is optional and the scripts folder location in this example is just a suggestion. It can be put elsewhere in the zip

example.zip
- appspec.yml
- scripts/
 - afterAllowTrafficScript.sh
- Rest of the files/folders to be deployed

Validation Assistant Script

WARNING

This script validates basic expected syntax for the AppSpec. It does not guarantee that your deployment will succeed nor that your AppSpec will do what you expect it to.

Run validator script without having to deal with Golang

You can download a pre-built binary from this repo

Linux:

$ ./appSpecAssistant validate --filePath <FILE_PATH> --computePlatform <[server, lambda, or ecs]>

Windows:

./appSpecAssistantForWindows.exe validate --filePath <FILE_PATH> --computePlatform <[server, lambda, or ecs]>

Capabilities of the Validation Assistant Script

March 2020

Building the Golang Validation Assistant Script Locally

You must have Go 1.13 or later installed.

General workflow:

# Validate an AppSPec file
$ go run main.go validate --filePath <FILE_PATH> --computePlatform <[server, lambda, or ecs]>

Run go run main.go --help for full usage.

Install Script on your machine

You can install appSpecAssistant on your machine to run the commands without having to build the binary every time.

For Linux on Linux:

# Install the binary to your GOPATH (or you can just build it in the current directory $ go build -o appSpecAssistant)
$ go build -o $GOPATH/bin/appSpecAssistant
# Call appSpecAssistant
$ appSpecAssistant validate --filePath <FILE_PATH> --computePlatform <[server, lambda, or ecs]>

For Windows on Linux:https://github.com/golang/go/wiki/WindowsCrossCompiling

GOOS=windows GOARCH=386 go build -o appSpecAssistantForWindows.exe main.go

For Windows on Windows:https://github.com/golang/go/wiki/WindowsCrossCompiling

In cmd.exe instead of PowerShell:

$ set GOOS=windows
$ set GOARCH=386
$ go build -o hello.exe hello.go

Development (adding changes to the script)

You must have Go 1.13 or later installed.

This CLI uses cobra. See documentation for more information. Install the cobra CLI to auto-generate code for new CLI commands.

# Add a new command
$ cobra add commandName

The assistant uses YAML support: go-yaml V3. See documentation for more information. Install the YAML package for development.

Build the project:

Build and run in one shot:

Run unit tests

$ go test -v ./pkg/*

# Get percentage of test coverage
$ go test -coverprofile=cover.out ./pkg/*

Format code: