Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stopping instances if there are error #155

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/run_e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,18 @@ jobs:
files: |
${{ inputs.test_report_filename }}

tear_down_test_executor_instances:
name: Tear down test executor instances
needs: report_test_results
stop_executor_instances:
name: Stop executor instances
needs: [ provision_and_execute_tests, report_test_results ]
uses: ./.github/workflows/run_task.yml
with:
container_make_target: "terraform/ec2-test-executors/clean PRE_RELEASE_NAME=${{ inputs.gh_release_name }}"
container_make_target: "terraform/ec2-stop-instances/stop"
secrets: inherit

# tear_down_test_executor_instances:
# name: Tear down test executor instances
# needs: report_test_results
# uses: ./.github/workflows/run_task.yml
# with:
# container_make_target: "terraform/ec2-test-executors/clean PRE_RELEASE_NAME=${{ inputs.gh_release_name }}"
# secrets: inherit
4 changes: 4 additions & 0 deletions terraform/ec2-instances-creator/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ module "ec2_instance" {
instance_type = var.instance_type
fb_package_name = each.value.targetPackageName
})
}

output "instance_ids" {
value = { for k, v in module.ec2_instance : k => v.id }
}
9 changes: 9 additions & 0 deletions terraform/ec2-stop-instances/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Terraform-stop
.PHONY: stop
stop:
terraform init -reconfigure
terraform refresh
#terraform output -json instance_ids | jq -r '.[]' | paste -sd ' ' -
terraform destroy -auto-approve
#terraform apply -target null_resource.stop_instances -auto-approve
@echo "Stopping all the instances"
9 changes: 9 additions & 0 deletions terraform/ec2-stop-instances/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# creates a resource named null_resource
resource "null_resource" "stop_instances" {
provisioner "local-exec" {
on_failure = continue
command = <<EOT
aws ec2 stop-instances --region us-east-2 --instance-ids $(terraform output -json instance_ids | jq -r '.[]' | paste -sd ' ' -)
EOT
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading