aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpmikus <peter.mikus@protonmail.ch>2023-01-25 12:54:28 +0000
committerPeter Mikus <peter.mikus@protonmail.ch>2023-01-25 15:12:35 +0000
commitcb10650c50c286040002a19ac7237e144a923610 (patch)
treeb334f4e4496d80e159e55a1bdf9710a7ff177e8b
parent4fcfee7452af484688fd2372b6a37a3a59a8fb02 (diff)
feat(terraform): Refactor application version deploy
Signed-off-by: pmikus <peter.mikus@protonmail.ch> Change-Id: I065a018745a82762c816de96d8a69116416aa0ce (cherry picked from commit 61cf4d230c3bd88cd0a6f3782796cc3949485b72)
-rwxr-xr-xcsit.infra.dash/do_release.sh16
-rw-r--r--fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/main.tf21
-rw-r--r--fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/output.tf3
-rw-r--r--fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/variables.tf22
-rw-r--r--fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/versions.tf4
-rw-r--r--fdio.infra.terraform/terraform-aws-elastic-beanstalk-application/versions.tf4
-rw-r--r--fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/main.tf13
-rw-r--r--fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/output.tf3
-rw-r--r--fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/variables.tf30
-rw-r--r--fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/versions.tf5
10 files changed, 88 insertions, 33 deletions
diff --git a/csit.infra.dash/do_release.sh b/csit.infra.dash/do_release.sh
index e4d7e3a3a6..63aff04dca 100755
--- a/csit.infra.dash/do_release.sh
+++ b/csit.infra.dash/do_release.sh
@@ -11,3 +11,19 @@ find . -type d -name "__pycache__" -exec rm -rf "{}" \;
find . -type d -name ".webassets-cache" -exec rm -rf "{}" \;
zip -r ../app.zip .
popd
+
+pushd "../fdio.infra.terraform/"
+pushd "terraform-aws-fdio-csit-dash-app-base"
+export BUILD_ID=41
+export TF_VAR_application_version="${BUILD_ID-}"
+export TF_LOG=INFO
+terraform validate
+terraform init
+terraform apply -no-color -auto-approve
+application_version="$(terraform output application_version)"
+popd
+popd
+
+#aws --region eu-central-1 elasticbeanstalk update-environment \
+# --environment-name fdio-csit-dash-env \
+# --version-label "${application_version}"
diff --git a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/main.tf b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/main.tf
index 4a9f473baa..ace3aebbbc 100644
--- a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/main.tf
+++ b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/main.tf
@@ -1,7 +1,5 @@
locals {
- bucket = "${var.application_name}-bucket"
- key = "${var.application_name}.zip"
- source = "app.zip"
+ key = "${var.application_name_version}-${uuid()}.zip"
tags = {
"Name" = "${var.application_name}"
"Environment" = "${var.application_name}"
@@ -9,23 +7,22 @@ locals {
}
# Create elastic beanstalk Application Version
-resource "aws_s3_bucket" "bucket" {
- bucket = local.bucket
- tags = local.tags
-}
-
+# resource "aws_s3_bucket" "bucket" {
+# bucket = var.application_bucket
+# tags = local.tags
+# }
resource "aws_s3_object" "object" {
- bucket = aws_s3_bucket.bucket.id
+ bucket = var.application_bucket
key = local.key
- source = local.source
+ source = var.application_source
tags = local.tags
}
resource "aws_elastic_beanstalk_application_version" "application_version" {
application = var.application_name
description = var.application_description
- bucket = aws_s3_bucket.bucket.id
+ bucket = var.application_bucket
key = aws_s3_object.object.id
- name = var.application_version_name
+ name = var.application_name_version
tags = local.tags
}
diff --git a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/output.tf b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/output.tf
index e69de29bb2..4262bbe6cf 100644
--- a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/output.tf
+++ b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/output.tf
@@ -0,0 +1,3 @@
+output "application_version" {
+ value = aws_elastic_beanstalk_application_version.application_version.name
+}
diff --git a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/variables.tf b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/variables.tf
index 6ac2ae7bfe..8d7dd45755 100644
--- a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/variables.tf
+++ b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/variables.tf
@@ -1,3 +1,9 @@
+variable "application_bucket" {
+ description = "The name of the bucket."
+ type = string
+ default = "elasticbeanstalk-eu-central-1"
+}
+
variable "application_description" {
description = "Short description of the Application Version."
type = string
@@ -5,13 +11,19 @@ variable "application_description" {
}
variable "application_name" {
- description = "Name of the Beanstalk Application the version is associated."
+ description = "Name of the Beanstalk Application."
+ type = string
+ default = "beanstalk"
+}
+
+variable "application_name_version" {
+ description = "Version of the Beanstalk Application."
type = string
- default = "Beanstalk"
+ default = "beanstalk-1"
}
-variable "application_version_name" {
- description = "Unique name for the this Application Version."
+variable "application_source" {
+ description = "The source file with application code."
type = string
- default = "Beanstalk Version"
+ default = "app.zip"
}
diff --git a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/versions.tf b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/versions.tf
index 66b9c17f9b..ccf48ef975 100644
--- a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/versions.tf
+++ b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application-version/versions.tf
@@ -2,8 +2,8 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = "~> 4.3.0"
+ version = "~> 4.51.0"
}
}
- required_version = ">= 1.1.4"
+ required_version = ">= 1.3.7"
}
diff --git a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application/versions.tf b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application/versions.tf
index 66b9c17f9b..ccf48ef975 100644
--- a/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application/versions.tf
+++ b/fdio.infra.terraform/terraform-aws-elastic-beanstalk-application/versions.tf
@@ -2,8 +2,8 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = "~> 4.3.0"
+ version = "~> 4.51.0"
}
}
- required_version = ">= 1.1.4"
+ required_version = ">= 1.3.7"
}
diff --git a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/main.tf b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/main.tf
index 7cc6185df9..aa76701f15 100644
--- a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/main.tf
+++ b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/main.tf
@@ -1,6 +1,9 @@
locals {
- name = "fdio-csit-dash-app"
- version = "fdio-csit-dash-app-base-${var.version}"
+ bucket = var.application_bucket
+ description = var.application_description
+ name = var.application_name
+ name_version = "${var.application_name}-base-${var.application_version}"
+ source = var.application_source
}
data "vault_aws_access_credentials" "creds" {
@@ -10,7 +13,9 @@ data "vault_aws_access_credentials" "creds" {
module "elastic_beanstalk_application_version" {
source = "../terraform-aws-elastic-beanstalk-application-version"
- application_description = "FD.io CDASH"
+ application_bucket = local.bucket
+ application_description = local.description
application_name = local.name
- application_version_name = local.version
+ application_name_version = local.name_version
+ application_source = local.source
}
diff --git a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/output.tf b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/output.tf
index e69de29bb2..0126e7a9c7 100644
--- a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/output.tf
+++ b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/output.tf
@@ -0,0 +1,3 @@
+output "application_version" {
+ value = module.elastic_beanstalk_application_version.application_version
+}
diff --git a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/variables.tf b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/variables.tf
index cfa9c3ecd8..cfd3f06c81 100644
--- a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/variables.tf
+++ b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/variables.tf
@@ -19,7 +19,7 @@ variable "vault_provider_skip_tls_verify" {
variable "vault_provider_token" {
description = "Vault root token."
type = string
- sensitive = true
+ default = "s.4z5PsufFwV3sHbCzK9Y2Cojd"
}
variable "vault_name" {
@@ -27,8 +27,32 @@ variable "vault_name" {
default = "dynamic-aws-creds-vault-fdio-csit-jenkins"
}
-variable "version" {
+variable "application_bucket" {
+ description = "The name of the bucket."
+ type = string
+ default = "elasticbeanstalk-eu-central-1-407116685360"
+}
+
+variable "application_description" {
+ description = "Short description of the Application Version."
+ type = string
+ default = "FD.io CDASH"
+}
+
+variable "application_name" {
+ description = "Name of the Beanstalk Application."
+ type = string
+ default = "fdio-csit-dash-app"
+}
+
+variable "application_source" {
+ description = "The source file with application code."
+ type = string
+ default = "../../csit.infra.dash/app.zip"
+}
+
+variable "application_version" {
description = "Application version string."
type = number
- default = 39
+ default = 41
}
diff --git a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/versions.tf b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/versions.tf
index 1d5fd15e82..319faaab21 100644
--- a/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/versions.tf
+++ b/fdio.infra.terraform/terraform-aws-fdio-csit-dash-app-base/versions.tf
@@ -1,9 +1,4 @@
terraform {
- backend "consul" {
- address = "consul.service.consul:8500"
- scheme = "http"
- path = "terraform/app-base"
- }
required_providers {
aws = {
source = "hashicorp/aws"