Skip to content

Commit 6918b7b

Browse files
fix: ESS stack clean up steps (#9832)
* fix: specify terraform env var everywhere * fix: proper env vars for ESS Stack clean up * fix: error when terraform fails to destroy ESS stack * fix: pass ess_region in terraform destroy
1 parent 1907eb1 commit 6918b7b

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

.buildkite/bk.integration-fips.pipeline.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77
IMAGE_UBUNTU_2404_X86_64: "platform-ingest-elastic-agent-ubuntu-2404-1757120457"
88
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-elastic-agent-ubuntu-2204-fips-1757120457"
99
IMAGE_UBUNTU_ARM64_FIPS: "platform-ingest-elastic-agent-ubuntu-2204-fips-aarch64-1757120457"
10+
ASDF_TERRAFORM_VERSION: 1.9.2
1011

1112
# This section is used to define the plugins that will be used in the pipeline.
1213
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
@@ -21,7 +22,6 @@ steps:
2122
- label: Start ESS stack for FIPS integration tests
2223
key: integration-fips-ess
2324
env:
24-
ASDF_TERRAFORM_VERSION: 1.9.2
2525
FIPS: "true"
2626
EC_ENDPOINT: "https://api.staging.elastic-gov.com"
2727
ESS_REGION: "us-gov-east-1"
@@ -127,6 +127,13 @@ steps:
127127
- label: ESS FIPS stack cleanup
128128
depends_on:
129129
- integration-tests-ubuntu-fips
130+
env:
131+
FIPS: "true"
132+
EC_ENDPOINT: "https://api.staging.elastic-gov.com"
133+
ESS_REGION: "us-gov-east-1"
134+
TF_VAR_deployment_template_id: "aws-general-purpose"
135+
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips:git-${BUILDKITE_COMMIT:0:12}"
136+
TF_VAR_docker_images_name_suffix: "-fips"
130137
allow_dependency_failure: true
131138
command: |
132139
buildkite-agent artifact download "test_infra/ess/**" . --step "integration-fips-ess"

.buildkite/bk.integration.pipeline.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
IMAGE_DEBIAN_12: "platform-ingest-elastic-agent-debian-12-1757120457"
1313
IMAGE_WIN_2022: "platform-ingest-elastic-agent-windows-2022-1757120457"
1414
IMAGE_WIN_2025: "platform-ingest-elastic-agent-windows-2025-1757120457"
15+
ASDF_TERRAFORM_VERSION: 1.9.2
1516

1617
# This section is used to define the plugins that will be used in the pipeline.
1718
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
@@ -74,8 +75,6 @@ steps:
7475
notify:
7576
- github_commit_status:
7677
context: "buildkite/elastic-agent-extended-testing - ESS stack provision"
77-
env:
78-
ASDF_TERRAFORM_VERSION: 1.9.2
7978
command: .buildkite/scripts/steps/ess_start.sh
8079
retry:
8180
automatic:

.buildkite/scripts/steps/ess.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ function ess_up {
4040
}
4141

4242
function ess_down {
43+
param (
44+
[string]$EssRegion = "gcp-us-west2"
45+
)
4346
$Workspace = & git rev-parse --show-toplevel
4447
$TfDir = Join-Path -Path $Workspace -ChildPath "test_infra/ess/"
4548
$stateFilePath = Join-Path -Path $TfDir -ChildPath "terraform.tfstate"
@@ -52,7 +55,8 @@ function ess_down {
5255
try {
5356
Push-Location -Path $TfDir
5457
& terraform init
55-
& terraform destroy -auto-approve
58+
& terraform destroy -auto-approve `
59+
-var="ess_region=$EssRegion"
5660
Pop-Location
5761
} catch {
5862
Write-Output "Error: Failed to destroy ESS stack(it will be auto-deleted later): $_"

.buildkite/scripts/steps/ess.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ function ess_up() {
4040
}
4141

4242
function ess_down() {
43-
echo "~~~ Tearing down the ESS Stack"
43+
echo "~~~ Tearing down the ESS Stack"
44+
local ESS_REGION=${1:-"gcp-us-west2"}
4445
local WORKSPACE=$(git rev-parse --show-toplevel)
4546
local TF_DIR="${WORKSPACE}/test_infra/ess/"
4647

4748
pushd "${TF_DIR}"
4849
terraform init
49-
terraform destroy -auto-approve
50+
terraform destroy -auto-approve \
51+
-var="ess_region=${ESS_REGION}"
5052
popd
5153
}
5254

.buildkite/scripts/steps/ess_down.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ set -euo pipefail
33

44
source .buildkite/scripts/steps/ess.sh
55

6-
ess_down || echo "Failed to stop ESS stack" >&2
6+
ESS_REGION="${ESS_REGION:-gcp-us-west2}"
7+
8+
ess_down "$ESS_REGION"

0 commit comments

Comments
 (0)