Skip to content

Commit 46f80f8

Browse files
Use integration/.env ELASTICSEARCH_VERSION as stack version for cloude2e (#5252)
1 parent 78bd648 commit 46f80f8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

dev-tools/cloud/terraform/main.tf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,28 @@ variable "pull_request" {
2828
description = "The github pull request number."
2929
}
3030

31+
variable "ess_region" {
32+
type = string
33+
default = "gcp-us-west2"
34+
description = "The ESS region to use"
35+
}
36+
3137
locals {
32-
match = regex("const DefaultVersion = \"(.*)\"", file("${path.module}/../../../version/version.go"))[0]
33-
stack_version = format("%s-SNAPSHOT", local.match)
38+
// strip hash found in ELASTICSEARCH_VERSION in integration/.env to get stack_version
39+
dra_match = regex("ELASTICSEARCH_VERSION=([0-9]+\\.[0-9]+\\.[0-9]+)(?:-[[:alpha:]]+-)?-?(SNAPSHOT)?", file("${path.module}/../../integration/.env"))
40+
stack_version = local.dra_match[1] == "SNAPSHOT" ? format("%s-SNAPSHOT", local.dra_match[0]) : local.dra_match[0]
3441
docker_image_ea = var.elastic_agent_docker_image
3542
}
3643

44+
data "ec_stack" "latest" {
45+
version_regex = local.stack_version
46+
region = var.ess_region
47+
}
48+
3749
resource "ec_deployment" "deployment" {
3850
name = format("fleet server PR-%s-%s", var.pull_request, var.git_commit)
39-
region = "gcp-us-west2"
40-
version = local.stack_version
51+
region = var.ess_region
52+
version = data.ec_stack.latest.version
4153
deployment_template_id = "gcp-general-purpose"
4254

4355
tags = {

dev-tools/cloud/terraform/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output "stack_version" {
2-
value = local.stack_version
2+
value = data.ec_stack.latest.version
33
description = "Stack version"
44
}
55

0 commit comments

Comments
 (0)