From fa9e5cd85e46f9d10b289ba55c54ee15baf0f3e1 Mon Sep 17 00:00:00 2001 From: KC Date: Sat, 11 Jun 2022 05:50:37 -0300 Subject: [PATCH 1/9] cleanup infrastructure --- .circleci/config.yml | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a48e89..d668783 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -514,34 +514,38 @@ jobs: workflows: default: jobs: - - build-frontend - - build-backend - - test-frontend: - requires: [build-frontend] - - test-backend: - requires: [build-backend] - - scan-backend: - requires: [build-backend] - - scan-frontend: - requires: [build-frontend] - - deploy-infrastructure: - requires: [test-frontend, test-backend, scan-frontend, scan-backend] + # - build-frontend + # - build-backend + # - test-frontend: + # requires: [build-frontend] + # - test-backend: + # requires: [build-backend] + # - scan-backend: + # requires: [build-backend] + # - scan-frontend: + # requires: [build-frontend] + # - deploy-infrastructure: + # requires: [test-frontend, test-backend, scan-frontend, scan-backend] + # filters: + # branches: + # only: [master] + # - configure-infrastructure: + # requires: [deploy-infrastructure] + # - run-migrations: + # requires: [configure-infrastructure] + # - deploy-frontend: + # requires: [run-migrations] + # - deploy-backend: + # requires: [run-migrations] + # - smoke-test: + # requires: [deploy-backend, deploy-frontend] + # - cloudfront-update: + # requires: [smoke-test] + # - add-prometheus-node-exporter: + # requires: [smoke-test] + # - cleanup: + # requires: [cloudfront-update] + - cleanup: filters: branches: - only: [master] - - configure-infrastructure: - requires: [deploy-infrastructure] - - run-migrations: - requires: [configure-infrastructure] - - deploy-frontend: - requires: [run-migrations] - - deploy-backend: - requires: [run-migrations] - - smoke-test: - requires: [deploy-backend, deploy-frontend] - - cloudfront-update: - requires: [smoke-test] - - add-prometheus-node-exporter: - requires: [smoke-test] - - cleanup: - requires: [cloudfront-update] + only: [cleanup] From 33dea218fcdb59e6348c8e80f86b18e54e5c2cf9 Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 10:58:21 -0300 Subject: [PATCH 2/9] add approval --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d668783..968cf43 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -546,6 +546,7 @@ workflows: # - cleanup: # requires: [cloudfront-update] - cleanup: + type: approval filters: branches: only: [cleanup] From dfc9b0cb48eb2cb249efb0ca6f588ebd078bfb90 Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 11:00:15 -0300 Subject: [PATCH 3/9] cleanup --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 968cf43..d668783 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -546,7 +546,6 @@ workflows: # - cleanup: # requires: [cloudfront-update] - cleanup: - type: approval filters: branches: only: [cleanup] From cc9b569c85620dade5e4d6099f9cd245548869c0 Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 11:02:04 -0300 Subject: [PATCH 4/9] cleanup --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d668783..3ba70b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -466,7 +466,7 @@ jobs: --query "Exports[?Name==\`WorkflowID\`].Value" \ --no-paginate --output text) # export OldWorkflowID=<> - # echo OldWorkflowID: ${OldWorkflowID} + echo OldWorkflowID: ${OldWorkflowID} # echo CIRCLE_WORKFLOW_ID: ${CIRCLE_WORKFLOW_ID:0:7} export STACKS=$(aws cloudformation list-stacks \ --query "StackSummaries[*].StackName" \ From 527e30b4d1ac4d43025f62d16e4b175ae690c40c Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 11:08:59 -0300 Subject: [PATCH 5/9] cleanup --- .circleci/config.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3ba70b6..1a009a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -461,10 +461,7 @@ jobs: - run: name: Cleanup stacks command: | - # your code here - export OldWorkflowID=$(aws cloudformation list-exports \ - --query "Exports[?Name==\`WorkflowID\`].Value" \ - --no-paginate --output text) + export OldWorkflowID=$(aws cloudformation list-exports --query "Exports[?Name==\`WorkflowID\`].Value" --no-paginate --output text) # export OldWorkflowID=<> echo OldWorkflowID: ${OldWorkflowID} # echo CIRCLE_WORKFLOW_ID: ${CIRCLE_WORKFLOW_ID:0:7} From 25feee1a033fc3ba5f5b52b95f0214d0c1c10a6d Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 11:13:46 -0300 Subject: [PATCH 6/9] cleanup --- .circleci/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a009a7..a68953a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -461,8 +461,12 @@ jobs: - run: name: Cleanup stacks command: | - export OldWorkflowID=$(aws cloudformation list-exports --query "Exports[?Name==\`WorkflowID\`].Value" --no-paginate --output text) - # export OldWorkflowID=<> + echo WorkflowID=$WorkflowID + echo oldworkflowID=$(<>) + echo $(aws cloudformation list-exports --query "Exports[?Name==\`WorkflowID\`].Value" --no-paginate --output text) + echo $(aws cloudformation list-exports --query "Exports[*].Name" --output text) + # export OldWorkflowID=$(aws cloudformation list-exports --query "Exports[?Name==\`WorkflowID\`].Value" --no-paginate --output text) + export OldWorkflowID=<> echo OldWorkflowID: ${OldWorkflowID} # echo CIRCLE_WORKFLOW_ID: ${CIRCLE_WORKFLOW_ID:0:7} export STACKS=$(aws cloudformation list-stacks \ From 96e6a1e9630e598c8669e2cf26cd499d0d8b4180 Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 11:22:09 -0300 Subject: [PATCH 7/9] cleanup --- .circleci/config.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a68953a..f9725af 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -461,21 +461,14 @@ jobs: - run: name: Cleanup stacks command: | - echo WorkflowID=$WorkflowID - echo oldworkflowID=$(<>) - echo $(aws cloudformation list-exports --query "Exports[?Name==\`WorkflowID\`].Value" --no-paginate --output text) - echo $(aws cloudformation list-exports --query "Exports[*].Name" --output text) - # export OldWorkflowID=$(aws cloudformation list-exports --query "Exports[?Name==\`WorkflowID\`].Value" --no-paginate --output text) - export OldWorkflowID=<> + export OldWorkflowID=$(aws cloudformation list-exports --query "Exports[?Name==\`$WorkflowID\`].Value" --no-paginate --output text) echo OldWorkflowID: ${OldWorkflowID} - # echo CIRCLE_WORKFLOW_ID: ${CIRCLE_WORKFLOW_ID:0:7} export STACKS=$(aws cloudformation list-stacks \ --query "StackSummaries[*].StackName" \ --stack-status-filter CREATE_COMPLETE --no-paginate --output text) - # if [[ "${OldWorkflowID}" != "${OldWorkflowID}" ]] + echo $STACKS if [[ "${STACKS[@]}" =~ "${OldWorkflowID}" ]] then - # export OldWorkflowID="kelechi1" aws s3 rm "s3://udapeople-${OldWorkflowID}" --recursive aws cloudformation delete-stack --stack-name "udapeople-backend-${OldWorkflowID}" aws cloudformation delete-stack --stack-name "udapeople-frontend-${OldWorkflowID}" From 61b478ab07bbabf716be7a4ef8b502eaaf3da6fd Mon Sep 17 00:00:00 2001 From: KC Date: Sun, 26 Jun 2022 11:36:02 -0300 Subject: [PATCH 8/9] cleanup --- .circleci/config.yml | 10 ++++++---- .circleci/files/cloudfront.yml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f9725af..775e2bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -461,11 +461,13 @@ jobs: - run: name: Cleanup stacks command: | - export OldWorkflowID=$(aws cloudformation list-exports --query "Exports[?Name==\`$WorkflowID\`].Value" --no-paginate --output text) - echo OldWorkflowID: ${OldWorkflowID} + export OldWorkflowID=$(aws cloudformation list-exports \ + --query "Exports[?Name==\`WorkflowID\`].Value" \ + --no-paginate --output text) + echo OldWorkflowID=$OldWorkflowID export STACKS=$(aws cloudformation list-stacks \ - --query "StackSummaries[*].StackName" \ - --stack-status-filter CREATE_COMPLETE --no-paginate --output text) + --query "StackSummaries[*].StackName" \ + --stack-status-filter CREATE_COMPLETE --no-paginate --output text) echo $STACKS if [[ "${STACKS[@]}" =~ "${OldWorkflowID}" ]] then diff --git a/.circleci/files/cloudfront.yml b/.circleci/files/cloudfront.yml index 62ea0dd..c384c63 100644 --- a/.circleci/files/cloudfront.yml +++ b/.circleci/files/cloudfront.yml @@ -38,4 +38,4 @@ Outputs: Value: !Sub ${WorkflowID} Description: URL for website hosted on S3 Export: - Name: !Sub ${WorkflowID} + Name: WorkflowID From fed92205d28240b24d061be3b9364c2309d6b425 Mon Sep 17 00:00:00 2001 From: KC Date: Thu, 14 Jul 2022 05:21:09 -0300 Subject: [PATCH 9/9] merged --- .circleci/config.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b03e10b..0df6bea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -664,43 +664,6 @@ jobs: workflows: default: jobs: -<<<<<<< HEAD - # - build-frontend - # - build-backend - # - test-frontend: - # requires: [build-frontend] - # - test-backend: - # requires: [build-backend] - # - scan-backend: - # requires: [build-backend] - # - scan-frontend: - # requires: [build-frontend] - # - deploy-infrastructure: - # requires: [test-frontend, test-backend, scan-frontend, scan-backend] - # filters: - # branches: - # only: [master] - # - configure-infrastructure: - # requires: [deploy-infrastructure] - # - run-migrations: - # requires: [configure-infrastructure] - # - deploy-frontend: - # requires: [run-migrations] - # - deploy-backend: - # requires: [run-migrations] - # - smoke-test: - # requires: [deploy-backend, deploy-frontend] - # - cloudfront-update: - # requires: [smoke-test] - # - add-prometheus-node-exporter: - # requires: [smoke-test] - # - cleanup: - # requires: [cloudfront-update] - - cleanup: - filters: - branches: - only: [cleanup] -======= - get-aws-params: filters: branches: @@ -771,4 +734,3 @@ workflows: filters: branches: only: [master, dev-branch] ->>>>>>> master