From 9034aafd6d02c5c5ea0e4931baea569131a0c821 Mon Sep 17 00:00:00 2001 From: Nathan VTG Date: Fri, 6 May 2022 11:29:31 -0300 Subject: [PATCH] feat(aws-rds): create formula snapshot db --- vkpr/aws/rds/snapshot/README.md | 1 + vkpr/aws/rds/snapshot/build.sh | 13 ++++++++ vkpr/aws/rds/snapshot/config.json | 33 +++++++++++++++++++ vkpr/aws/rds/snapshot/help.json | 4 +++ vkpr/aws/rds/snapshot/metadata.json | 18 ++++++++++ vkpr/aws/rds/snapshot/src/main.sh | 12 +++++++ .../rds/snapshot/src/unix/formula/formula.sh | 13 ++++++++ 7 files changed, 94 insertions(+) create mode 100755 vkpr/aws/rds/snapshot/README.md create mode 100755 vkpr/aws/rds/snapshot/build.sh create mode 100755 vkpr/aws/rds/snapshot/config.json create mode 100644 vkpr/aws/rds/snapshot/help.json create mode 100755 vkpr/aws/rds/snapshot/metadata.json create mode 100755 vkpr/aws/rds/snapshot/src/main.sh create mode 100755 vkpr/aws/rds/snapshot/src/unix/formula/formula.sh diff --git a/vkpr/aws/rds/snapshot/README.md b/vkpr/aws/rds/snapshot/README.md new file mode 100755 index 00000000..8b137891 --- /dev/null +++ b/vkpr/aws/rds/snapshot/README.md @@ -0,0 +1 @@ + diff --git a/vkpr/aws/rds/snapshot/build.sh b/vkpr/aws/rds/snapshot/build.sh new file mode 100755 index 00000000..c58d72d8 --- /dev/null +++ b/vkpr/aws/rds/snapshot/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +BIN_FOLDER=bin +BINARY_NAME_UNIX=run.sh +ENTRY_POINT_UNIX=main.sh +LIB_RESOURCES="../../../../lib/functions/*" + +#bash-build: + mkdir -p $BIN_FOLDER/src + cp $LIB_RESOURCES $BIN_FOLDER/src + cp -r src/* $BIN_FOLDER + mv $BIN_FOLDER/$ENTRY_POINT_UNIX $BIN_FOLDER/$BINARY_NAME_UNIX + chmod +x $BIN_FOLDER/$BINARY_NAME_UNIX diff --git a/vkpr/aws/rds/snapshot/config.json b/vkpr/aws/rds/snapshot/config.json new file mode 100755 index 00000000..c70c33e4 --- /dev/null +++ b/vkpr/aws/rds/snapshot/config.json @@ -0,0 +1,33 @@ +{ + "inputs": [ + { + "tutorial": "Specifies the AWS Access Key Credential.", + "name": "aws_access_key", + "type": "CREDENTIAL_AWS_ACCESSKEYID" + }, + { + "tutorial": "Specifies the AWS Secret Key Credential.", + "name": "aws_secret_key", + "type": "CREDENTIAL_AWS_SECRETACCESSKEY" + }, + { + "tutorial": "Specifies the AWS Region to set the environment.", + "name": "aws_region", + "type": "CREDENTIAL_AWS_REGION" + }, + { + "tutorial": "Specifies the RDS instance name to create SNAPSHOT.", + "label": "RDS instance name:", + "name": "rds_instance_name", + "type": "text", + "default": "rds-sample", + "required": true, + "pattern": { + "regex": "^([A-Za-z0-9-]+)$", + "mismatchText": "Invalid Cluster name" + } + } + ], + "template": "shell-bat", + "templateRelease:": "2.16.2" +} \ No newline at end of file diff --git a/vkpr/aws/rds/snapshot/help.json b/vkpr/aws/rds/snapshot/help.json new file mode 100644 index 00000000..8cfcf2e7 --- /dev/null +++ b/vkpr/aws/rds/snapshot/help.json @@ -0,0 +1,4 @@ +{ + "short": "", + "long": "" +} diff --git a/vkpr/aws/rds/snapshot/metadata.json b/vkpr/aws/rds/snapshot/metadata.json new file mode 100755 index 00000000..40c9a94c --- /dev/null +++ b/vkpr/aws/rds/snapshot/metadata.json @@ -0,0 +1,18 @@ +{ + "execution": [ + "local" + ], + "os": { + "deps": [], + "support": [ + "mac", + "linux" + ] + }, + "tags": [ + "vkpr", + "aws", + "rds", + "snapshot" + ] +} diff --git a/vkpr/aws/rds/snapshot/src/main.sh b/vkpr/aws/rds/snapshot/src/main.sh new file mode 100755 index 00000000..5e51318f --- /dev/null +++ b/vkpr/aws/rds/snapshot/src/main.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# shellcheck source=/dev/null +source src/log.sh +source src/var.sh +source src/helper.sh +source src/validate.sh +source src/versions.sh + +. "$(dirname "$0")"/unix/formula/formula.sh --source-only + +runFormula diff --git a/vkpr/aws/rds/snapshot/src/unix/formula/formula.sh b/vkpr/aws/rds/snapshot/src/unix/formula/formula.sh new file mode 100755 index 00000000..54ebc612 --- /dev/null +++ b/vkpr/aws/rds/snapshot/src/unix/formula/formula.sh @@ -0,0 +1,13 @@ +#!/bin/bash + + +runFormula() { + + validateAwsSecretKey "$AWS_SECRET_KEY" + validateAwsAccessKey "$AWS_ACCESS_KEY" + validateAwsRegion "$AWS_REGION" + + aws rds create-db-snapshot \ + --db-instance-identifier $RDS_INSTANCE_NAME \ + --db-snapshot-identifier mydbsnapshot 1> /dev/null && echo "Snapshot created" +}