From b370d98d1e2cdf499b5419774fb18bcce3ba3248 Mon Sep 17 00:00:00 2001 From: Shyam Date: Thu, 21 Jul 2022 10:39:41 -0400 Subject: [PATCH 01/16] updated required field --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2ebeee..62e00a5 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,9 @@ Calls `aws cloudformation validate-template` * **BitOps Property:** `stack-action` * **Environment Variable:** `BITOPS_CFN_STACK_ACTION` * **default:** `deploy` +* **required:** `"True"` -Controls what cloudformation action to apply on the stack +Controls what cloudformation action to apply on the stack. This config is a required parameter. ------------------- @@ -85,8 +86,9 @@ Controls what cloudformation action to apply on the stack * **BitOps Property:** `cfn-stack-name` * **Environment Variable:** `BITOPS_CFN_STACK_NAME` * **default:** `""` +* **required:** `"True"` -Cloudformation stack name +Cloudformation stack name. This config is a required parameter. ------------------- ### capabilities @@ -118,10 +120,14 @@ Cloudformation capabilities * **BitOps Property:** `cfn-files` Allows for param files to be used. Has the following child-properties + #### template-file * **BitOps Property:** `cfn-files.template-file` +* **Environment Variable:** `BITOPS_CFN_TEMPLATE_FILENAME` +* **required:** `"True"` + +Template file to apply the params against. This config is a required parameter. -Template file to apply the params against #### parameters * **BitOps Property:** `cfn-files.parameters` From 2e69609fa1542e09df9a0423127fc0d941ef0267 Mon Sep 17 00:00:00 2001 From: Shyam Date: Thu, 28 Jul 2022 11:08:34 -0400 Subject: [PATCH 02/16] added table of contents --- INSTALL.md | 27 +++++++++++++++++++++++++++ README.md | 33 ++++++++------------------------- 2 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 INSTALL.md diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..c6fd22c --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,27 @@ +## Installation + +This plugin gets installed through ```bitops.config.yaml``` in the bitops core level. This file is located [here](https://github.com/bitovi/bitops/blob/plugins/bitops.config.yaml) + + +### Sample Config + +``` +bitops: + fail_fast: true + run_mode: default + logging: + level: DEBUG + color: + enabled: true + filename: bitops-run + err: bitops.logs + path: /var/logs/bitops + opsrepo_root_default_dir: _default + plugins: + cloudformation: + source: https://github.com/bitops-plugins/cloudformation +... +... +... + +``` diff --git a/README.md b/README.md index 62e00a5..a39ac03 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,19 @@ # Bitops Plugin for Cloudformation -## Introduction -This plugin will let BitOps to automatically deploy ``cloudformation`` templates on AWS platform. +## Table of contents -This plugin also manages ``create-stack`` or ``update-stack`` natively at the plugin level. +1. [Introduction](#Introduction) +2. [Installation](https://github.com/bitops-plugins/cloudformation/blob/main/INSTALL.md) +3. [Deployment](#Deployment) -## Installation +--- -This plugin gets installed through ```bitops.config.yaml```. -### Sample Config +## Introduction +This plugin will let BitOps to automatically deploy ``cloudformation`` templates on AWS platform. -``` -bitops: - fail_fast: true - run_mode: default - logging: - level: DEBUG - color: - enabled: true - filename: bitops-run - err: bitops.logs - path: /var/logs/bitops - opsrepo_root_default_dir: _default - plugins: - cloudformation: - source: https://github.com/bitops-plugins/cloudformation -... -... -... +This plugin also manages ``create-stack`` or ``update-stack`` natively at the plugin level. -``` ## Deployment From 7fbe48eef9cc50975ea06d70963ea06adda75c49 Mon Sep 17 00:00:00 2001 From: Roger Wu Date: Tue, 4 Oct 2022 15:04:45 -0700 Subject: [PATCH 03/16] add pass through of CFN_CAPABILITY if set via BITOPS_CFN_CAPABILITY in an earlier stage --- deploy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy.sh b/deploy.sh index e4be059..37fd6a9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -19,6 +19,7 @@ export CFN_TEMPLATE_PARAMS_FILENAME="$BITOPS_CFN_TEMPLATE_PARAMS_FILENAME" export CFN_TEMPLATE_VALIDATION="$BITOPS_CFN_TEMPLATE_VALIDATION" export CFN_STACK_ACTION="$BITOPS_CFN_STACK_ACTION" export CFN_PARAMS_FLAG="$BITOPS_CFN_PARAMS_FLAG" +export CFN_CAPABILITY="$BITOPS_CFN_CAPABILITY" export CLOUDFORMATION_BITOPS_CONFIG="$CLOUDFORMATION_ROOT_OPERATIONS/bitops.config.yaml" export BITOPS_SCHEMA_ENV_FILE="$CLOUDFORMATION_ROOT_OPERATIONS/ENV_FILE" From 3c747129ff4a63b1482c0c493ef6845248227437 Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Thu, 3 Nov 2022 15:53:25 -0400 Subject: [PATCH 04/16] Update bitops.schema.yaml --- bitops.schema.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bitops.schema.yaml b/bitops.schema.yaml index 1591d18..d700d2f 100644 --- a/bitops.schema.yaml +++ b/bitops.schema.yaml @@ -20,6 +20,10 @@ cloudformation: type: string export_env: CFN_STACK_NAME required: true + skip-deploy: + type: boolean + parameter: skip-deploy + export_env: CFN_SKIP_DEPLOY s3bucket: type: string export_env: CFN_TEMPLATE_S3_BUCKET From c4c7c0baa7d8eca60e284f030dc5748830fe5643 Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Thu, 3 Nov 2022 15:54:16 -0400 Subject: [PATCH 05/16] Update deploy.sh --- deploy.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deploy.sh b/deploy.sh index 37fd6a9..f88461c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -27,6 +27,11 @@ export BITOPS_CONFIG_SCHEMA="$CLOUDFORMATION_ROOT_SCRIPTS/bitops.schema.yaml" export SCRIPTS_DIR="$CLOUDFORMATION_ROOT_SCRIPTS/scripts" +if [ "$SKIP_DEPLOY_CFN" == "true" ] || [ "$CFN_SKIP_DEPLOY" == "true" ]; then + echo "CFN_SKIP_DEPLOY is set. Skipping." + exit 0 +fi + if [ ! -d "$CLOUDFORMATION_ROOT_OPERATIONS" ]; then echo "No cloudformation directory. Skipping." exit 0 From 1df68df09022d297fc61aaf1cca27865a28baac3 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Wed, 9 Nov 2022 15:40:11 -0500 Subject: [PATCH 06/16] removing `SKIP_DEPLOY_CFN` --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index f88461c..749d90d 100755 --- a/deploy.sh +++ b/deploy.sh @@ -27,7 +27,7 @@ export BITOPS_CONFIG_SCHEMA="$CLOUDFORMATION_ROOT_SCRIPTS/bitops.schema.yaml" export SCRIPTS_DIR="$CLOUDFORMATION_ROOT_SCRIPTS/scripts" -if [ "$SKIP_DEPLOY_CFN" == "true" ] || [ "$CFN_SKIP_DEPLOY" == "true" ]; then +if [ "$CFN_SKIP_DEPLOY" == "true" ]; then echo "CFN_SKIP_DEPLOY is set. Skipping." exit 0 fi From 646b9be2634dd594a9445efbbc65654c15c4fc75 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Wed, 9 Nov 2022 15:48:23 -0500 Subject: [PATCH 07/16] Updating README with skip-deploy option --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index a39ac03..2bd2850 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,13 @@ Calls `aws cloudformation validate-template` Controls what cloudformation action to apply on the stack. This config is a required parameter. +### skip-deploy +* **BitOps Property:** `skip-deploy` +* **Environment Variable:** `TERRAFORM_SKIP_DEPLOY` +* **default:** `none` +* **Required:** `false` +* **Description:** If set to true, regardless of the stack-action, deployment actions will be skipped. + ------------------- ## Options Configuration From 1f090455725797c8d03e8aa9f0b11a6ae45f140b Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Wed, 9 Nov 2022 15:50:52 -0500 Subject: [PATCH 08/16] Updating README skip-deploy option --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bd2850..2c662f3 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Controls what cloudformation action to apply on the stack. This config is a requ ### skip-deploy * **BitOps Property:** `skip-deploy` -* **Environment Variable:** `TERRAFORM_SKIP_DEPLOY` +* **Environment Variable:** `CFN_SKIP_DEPLOY` * **default:** `none` * **Required:** `false` * **Description:** If set to true, regardless of the stack-action, deployment actions will be skipped. From c1d876b9fc48cab6be3164dd464901cf03e13ee9 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Thu, 10 Nov 2022 09:38:09 -0500 Subject: [PATCH 09/16] Removing bad SKIP_DEPLOY env var and adding sanity check --- README.md | 4 ++-- deploy.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c662f3..061ed7b 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Controls what cloudformation action to apply on the stack. This config is a requ ### skip-deploy * **BitOps Property:** `skip-deploy` * **Environment Variable:** `CFN_SKIP_DEPLOY` -* **default:** `none` +* **default:** `""` * **Required:** `false` * **Description:** If set to true, regardless of the stack-action, deployment actions will be skipped. @@ -155,5 +155,5 @@ The directory within the ansible workspace that contains json files that will be Although not captured in `bitops.config.yml`, the following environment variables can be set to further customize behaviour ------------------- -### SKIP_DEPLOY_CLOUDFORMATION +### CFN_SKIP_DEPLOY Will skill all cloudformation executions. This superseeds all other configuration \ No newline at end of file diff --git a/deploy.sh b/deploy.sh index 749d90d..8b579fa 100755 --- a/deploy.sh +++ b/deploy.sh @@ -27,7 +27,8 @@ export BITOPS_CONFIG_SCHEMA="$CLOUDFORMATION_ROOT_SCRIPTS/bitops.schema.yaml" export SCRIPTS_DIR="$CLOUDFORMATION_ROOT_SCRIPTS/scripts" -if [ "$CFN_SKIP_DEPLOY" == "true" ]; then +SANITIZED_CFN_SKIP_DEPLOY=$(echo "$CFN_SKIP_DEPLOY" | tr '[:upper:]' '[:lower:]') +if [ "$SANITIZED_CFN_SKIP_DEPLOY" == "true" ]; then echo "CFN_SKIP_DEPLOY is set. Skipping." exit 0 fi From 2570430ff15be72541254c808d8f4f426f4420df Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Thu, 10 Nov 2022 10:19:34 -0500 Subject: [PATCH 10/16] removing sanity check --- deploy.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 8b579fa..749d90d 100755 --- a/deploy.sh +++ b/deploy.sh @@ -27,8 +27,7 @@ export BITOPS_CONFIG_SCHEMA="$CLOUDFORMATION_ROOT_SCRIPTS/bitops.schema.yaml" export SCRIPTS_DIR="$CLOUDFORMATION_ROOT_SCRIPTS/scripts" -SANITIZED_CFN_SKIP_DEPLOY=$(echo "$CFN_SKIP_DEPLOY" | tr '[:upper:]' '[:lower:]') -if [ "$SANITIZED_CFN_SKIP_DEPLOY" == "true" ]; then +if [ "$CFN_SKIP_DEPLOY" == "true" ]; then echo "CFN_SKIP_DEPLOY is set. Skipping." exit 0 fi From 12cb17a48e559af4e4eeeb9f7603bc9e392705a8 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Thu, 10 Nov 2022 10:22:47 -0500 Subject: [PATCH 11/16] Removing required attribute --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 061ed7b..e7cc44e 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,6 @@ Controls what cloudformation action to apply on the stack. This config is a requ * **BitOps Property:** `skip-deploy` * **Environment Variable:** `CFN_SKIP_DEPLOY` * **default:** `""` -* **Required:** `false` * **Description:** If set to true, regardless of the stack-action, deployment actions will be skipped. ------------------- From a5bc4b068d16203eabb8b3eb00d1ab035aa4f59f Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 11 Nov 2022 14:13:59 -0300 Subject: [PATCH 12/16] Boolean to lowercase --- README.md | 6 +++--- bitops.schema.yaml | 2 +- deploy.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e7cc44e..331c4f7 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Calls `aws cloudformation validate-template` * **BitOps Property:** `stack-action` * **Environment Variable:** `BITOPS_CFN_STACK_ACTION` * **default:** `deploy` -* **required:** `"True"` +* **required:** `"true"` Controls what cloudformation action to apply on the stack. This config is a required parameter. @@ -75,7 +75,7 @@ Controls what cloudformation action to apply on the stack. This config is a requ * **BitOps Property:** `cfn-stack-name` * **Environment Variable:** `BITOPS_CFN_STACK_NAME` * **default:** `""` -* **required:** `"True"` +* **required:** `"true"` Cloudformation stack name. This config is a required parameter. @@ -113,7 +113,7 @@ Allows for param files to be used. Has the following child-properties #### template-file * **BitOps Property:** `cfn-files.template-file` * **Environment Variable:** `BITOPS_CFN_TEMPLATE_FILENAME` -* **required:** `"True"` +* **required:** `"true"` Template file to apply the params against. This config is a required parameter. diff --git a/bitops.schema.yaml b/bitops.schema.yaml index d700d2f..9162e61 100644 --- a/bitops.schema.yaml +++ b/bitops.schema.yaml @@ -39,7 +39,7 @@ cloudformation: template-file: type: string export_env: CFN_TEMPLATE_FILENAME - required: True + required: true parameters: type: object properties: diff --git a/deploy.sh b/deploy.sh index 749d90d..1aff3c4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -98,7 +98,7 @@ cd $CLOUDFORMATION_ROOT_OPERATIONS # bash $SCRIPTS_DIR/aws/sts.get-caller-identity.sh # always run cfn template validation first -if [[ "${CFN_TEMPLATE_VALIDATION}" == "True" ]] || [[ "${CFN_TEMPLATE_VALIDATION}" == "true" ]]; then +if [[ "${CFN_TEMPLATE_VALIDATION}" == "true" ]] || [[ "${CFN_TEMPLATE_VALIDATION}" == "True" ]]; then echo "Running Cloudformation Template Validation" bash $CLOUDFORMATION_ROOT_SCRIPTS/scripts/cloudformation_validate.sh "$CFN_TEMPLATE_FILENAME" fi From 7e1331df5381d537550343b47ada2d9020d877cf Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Fri, 11 Nov 2022 16:13:13 -0500 Subject: [PATCH 13/16] Adding cloudprovider check + meaningful message --- deploy.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deploy.sh b/deploy.sh index 749d90d..5024a4a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -60,6 +60,10 @@ else fi fi +if [ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]; then + echo "AWS ACCESS KEY or SECRET isn't set. Check out our doc to understand what you're missing https://bitops.sh/examples/#docker-run-examples" +fi + # Check for Before Deploy Scripts # bash $SCRIPTS_DIR/deploy/before-deploy.sh "$CLOUDFORMATION_ROOT_OPERATIONS" From 67051962929d8c311dbd0e2f49e2e6c2e3afd8fb Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Mon, 21 Nov 2022 11:37:10 -0500 Subject: [PATCH 14/16] Updating AWS CONFIGURE check to use AWS CLI and return code --- deploy.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 5024a4a..4a1355a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -60,8 +60,11 @@ else fi fi -if [ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]; then - echo "AWS ACCESS KEY or SECRET isn't set. Check out our doc to understand what you're missing https://bitops.sh/examples/#docker-run-examples" +aws sts get-caller-identity +result=$? +if [ $result != 0 ]; then + echo "AWS ACCESS KEY or SECRET isn't set. Check out our doc to understand what you're missing https://bitops.sh/examples/#docker-run-examples" + exit $result fi From 8956fb12e816a676b9401222eecf10a4be6cb9a3 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Mon, 21 Nov 2022 12:08:00 -0500 Subject: [PATCH 15/16] Updating `BITOPS_PLUGIN_DIR` to `BITOPS_INSTALLED_PLUGIN_DIR` --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 749d90d..99250f0 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,7 +11,7 @@ echo "Welcome to the CloudFormation BitOps plugin!" # export BITOPS_SCHEMA_ENV_FILE="$CLOUDFORMATION_ROOT/ENV_FILE" # export BITOPS_CONFIG_SCHEMA="$PLUGINS_DIR/cloudformation/bitops.schema.yaml" export PLUGINS_ROOT_DIR="$BITOPS_PLUGINS_DIR" -export CLOUDFORMATION_ROOT_SCRIPTS="$BITOPS_PLUGIN_DIR" +export CLOUDFORMATION_ROOT_SCRIPTS="$BITOPS_INSTALLED_PLUGIN_DIR" export CLOUDFORMATION_ROOT_OPERATIONS="$BITOPS_OPSREPO_ENVIRONMENT_DIR" export CFN_STACK_NAME="$BITOPS_CFN_STACK_NAME" export CFN_TEMPLATE_FILENAME="$BITOPS_CFN_TEMPLATE_FILENAME" From 6ebf4b8d2bfabb785bb3d680e810fcd8c09ee9c3 Mon Sep 17 00:00:00 2001 From: PhillypHenning Date: Tue, 22 Nov 2022 09:18:35 -0500 Subject: [PATCH 16/16] Updating cloud provider check error message --- deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 4a1355a..6fe7432 100755 --- a/deploy.sh +++ b/deploy.sh @@ -63,7 +63,8 @@ fi aws sts get-caller-identity result=$? if [ $result != 0 ]; then - echo "AWS ACCESS KEY or SECRET isn't set. Check out our doc to understand what you're missing https://bitops.sh/examples/#docker-run-examples" + echo "AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY required for AWS authentication are not set or invalid." + echo "Check out BitOps documentation to understand what you're missing https://bitops.sh/examples/#docker-run-examples" exit $result fi