Skip to content

Commit

Permalink
Update CLI for new Cfn database template (#12)
Browse files Browse the repository at this point in the history
* Update CLI for new Cfn database template

* Trigger initial build

* Check error on confirm delete

* Fix CI

* Fix aurora flag handling

* Handle RDS instance or cluster

* Test Redis too

* Only build databases nightly and on-demand
  • Loading branch information
ipmb authored Feb 12, 2021
1 parent f421128 commit 6afadcd
Show file tree
Hide file tree
Showing 5 changed files with 392 additions and 82 deletions.
241 changes: 241 additions & 0 deletions .github/workflows/databases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
name: databases

on:
workflow_dispatch: {}
schedule:
- cron: '0 1 * * *'

jobs:
init:
name: init
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
-
name: Build
run: go build -o bin/apppack
-
name: AppPack Init
run: |
./bin/apppack create region --region us-east-2 \
--dockerhub-username $DOCKERHUB_USERNAME \
--dockerhub-access-token $DOCKERHUB_ACCESS_TOKEN
./bin/apppack create cluster --region us-east-2 \
--domain testclusters.apppack.io \
--instance-class t3.micro
timeout-minutes: 9
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
uses: actions/upload-artifact@master
with:
name: apppack
path: bin
standard-mysql:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@master
with:
name: apppack
path: bin
-
name: Create standard MySQL
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--non-interactive \
--instance-class db.t3.micro \
--engine mysql \
--allocated-storage 10 \
--max-allocated-storage 20 \
standard-mysql
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy standard MySQL
run: |
yes yes | ./bin/apppack destroy database standard-mysql \
--region us-east-2
if: always()
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
standard-postgres:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@master
with:
name: apppack
path: bin
-
name: Create standard Postgres
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--non-interactive \
--instance-class db.t3.micro \
--engine postgres \
--allocated-storage 10 \
--max-allocated-storage 20 \
standard-postgres
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy standard Postgres
run: |
yes yes | ./bin/apppack destroy database standard-postgres \
--region us-east-2
if: always()
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aurora-mysql:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@master
with:
name: apppack
path: bin
-
name: Create Aurora MySQL
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--non-interactive \
--instance-class db.t3.small \
--aurora \
--engine mysql \
--allocated-storage 10 \
--max-allocated-storage 20 \
aurora-mysql
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy Aurora MySQL
run: |
yes yes | ./bin/apppack destroy database aurora-mysql \
--region us-east-2
if: always()
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aurora-postgres:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@master
with:
name: apppack
path: bin
-
name: Create Aurora Postgres
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--non-interactive \
--instance-class db.t3.medium \
--aurora \
--engine postgres \
aurora-postgres
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy Aurora Postgres
run: |
yes yes | ./bin/apppack destroy database aurora-postgres \
--region us-east-2
if: always()
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
redis:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@master
with:
name: apppack
path: bin
-
name: Create Redis
run: |
chmod +x ./bin/apppack
./bin/apppack create redis --region us-east-2 \
--non-interactive
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy Redis
run: |
yes yes | ./bin/apppack destroy redis apppack \
--region us-east-2
if: always()
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
destroy:
runs-on: ubuntu-latest
if: always()
needs:
- standard-mysql
- standard-postgres
- aurora-mysql
- aurora-postgres
- redis
steps:
-
uses: actions/download-artifact@master
with:
name: apppack
path: bin
-
name: Destroy cluster
run: |
chmod +x ./bin/apppack
yes yes | ./bin/apppack destroy cluster apppack --region us-east-2
if: always()
timeout-minutes: 8
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy region
run: yes yes | ./bin/apppack destroy region --region us-east-2
if: always()
timeout-minutes: 3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5 changes: 2 additions & 3 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ const (
clusterFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/cluster.json"
accountFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/account.json"
regionFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/region.json"
postgresFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/postgres.json"
mysqlFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/mysql.json"
databaseFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/database.json"
redisFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/redis.json"
customDomainFormationURL = "https://s3.amazonaws.com/apppack-cloudformations/latest/custom-domain.json"
redisStackNameTmpl = "apppack-redis-%s"
Expand Down Expand Up @@ -740,7 +739,7 @@ var createRedisCmd = &cobra.Command{
clusterStack, err := stackFromDDBItem(sess, fmt.Sprintf("CLUSTER#%s", *cluster))
checkErr(err)
var multiAZParameter string
if *(getArgValue(cmd, &answers, "multi-az", false)) == "true" {
if isTruthy((getArgValue(cmd, &answers, "multi-az", false))) {
multiAZParameter = "yes"
} else {
multiAZParameter = "no"
Expand Down
Loading

0 comments on commit 6afadcd

Please sign in to comment.