Skip to content

Commit

Permalink
ci: merge EE and OSS doc deploy together [INFENG-625] (#9162)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysauer authored Apr 15, 2024
1 parent 0b2eab0 commit fd45ed8
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 14 deletions.
11 changes: 11 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,21 @@ check-links: attributions.rst
sphinx-build -b linkcheck . build -a || true
! grep -n broken build/output.txt

# publish defaults to the deploy/Makefile default
.PHONY: publish
publish: pre-publish publish-check
$(MAKE) -C deploy publish

.PHONY: publish-oss
publish-oss: export DET_VARIANT ?= OSS
publish-oss:
$(MAKE) publish

.PHONY: publish-ee
publish-ee: export DET_VARIANT ?= EE
publish-ee:
$(MAKE) publish

.PHONY: preview
preview: build
python deploy/upload.py --preview
Expand Down
1 change: 1 addition & 0 deletions docs/deploy/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ override.tf.json

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
tfplan

# Ignore CLI configuration files
.terraformrc
Expand Down
11 changes: 7 additions & 4 deletions docs/deploy/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
export TF_VAR_det_version := $(shell cat ../../VERSION)
export DET_VARIANT ?= OSS
export TF_VAR_det_variant := ${DET_VARIANT}
export TF_CLI_ARGS_init := "-backend-config=backend_${DET_VARIANT}.conf"

.PHONY: clean
clean:
-rm -r .terraform
-rm state/terraform.tfstate.backup

.PHONY: verify
verify:
terraform --version
verify: init
terraform validate

.PHONY: init
init:
terraform init -upgrade
terraform init -upgrade -reconfigure

.PHONY: plan
plan: init
Expand All @@ -24,4 +27,4 @@ publish: init
.PHONY: check
check: init
terraform fmt -check=true -diff=true
terraform validate
$(MAKE) terraform verify
15 changes: 15 additions & 0 deletions docs/deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
To deploy OSS:
```shell
export DET_VARIANT=OSS
make publish
```

To deploy EE:
```shell
export DET_VARIANT=OSS
make publish
```

Before running local terraform commands, set the DET_VARIANT variable to OSS or
EE and run `make init`. Terraform commands will then work as normal once the
backend is changed to reflect the variant.
4 changes: 4 additions & 0 deletions docs/deploy/backend_EE.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# EE S3 backend config parameters
bucket = "hpe-mlde-docs-terraform"
key = "terraform.tfstate"
region = "us-west-2"
4 changes: 4 additions & 0 deletions docs/deploy/backend_OSS.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OSS S3 backend config parameters
bucket = "determined-ai-docs-terraform"
key = "terraform.tfstate"
region = "us-west-2"
8 changes: 4 additions & 4 deletions docs/deploy/cdn.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ resource "aws_cloudfront_distribution" "distribution" {

domain_name = aws_s3_bucket_website_configuration.docs.website_endpoint

origin_id = local.domain
origin_id = local.config.domain
}

enabled = true
default_root_object = "index.html"
aliases = [
local.domain,
local.config.domain,
]

default_cache_behavior {
Expand All @@ -24,7 +24,7 @@ resource "aws_cloudfront_distribution" "distribution" {
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]

target_origin_id = local.domain
target_origin_id = local.config.domain
min_ttl = 0
default_ttl = 3600
max_ttl = 31536000
Expand All @@ -45,7 +45,7 @@ resource "aws_cloudfront_distribution" "distribution" {
}

viewer_certificate {
acm_certificate_arn = "arn:aws:acm:us-east-1:573932760021:certificate/3f5a03d6-d95b-4d08-ade3-994799c658cf"
acm_certificate_arn = local.config.cdn.acm_certificate_arn
ssl_support_method = "sni-only"
}
}
10 changes: 9 additions & 1 deletion docs/deploy/input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ variable "det_version" {
type = string
description = "The Determined version the docs are currently built under"
}
variable "det_variant" {
type = string
description = "The Determined variant the docs are currently built under"
validation {
condition = contains(["EE", "OSS"], var.det_variant)
error_message = "The variant must be one of OSS or EE"
}
}

locals {
domain = "docs.determined.ai"
config = yamldecode(file("${path.module}/vars_${var.det_variant}.yaml"))
}
4 changes: 1 addition & 3 deletions docs/deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ terraform {
required_version = "~> 1.0"

backend "s3" {
bucket = "determined-ai-docs-terraform"
key = "terraform.tfstate"
region = "us-west-2"
# defined in backend_*.conf
}

required_providers {
Expand Down
6 changes: 4 additions & 2 deletions docs/deploy/s3.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_s3_bucket" "docs" {
bucket = "determined-ai-docs"
bucket = local.config.s3.bucket
}

# Set bucket object ownership if possible
Expand Down Expand Up @@ -86,10 +86,12 @@ resource "aws_s3_object" "index" {
resource "aws_s3_object" "robots" {
bucket = aws_s3_bucket.docs.id
key = "robots.txt"
content = "User-agent: *\nSitemap: https://docs.determined.ai/latest/sitemap.xml"
content = local.config.s3.robots.content
content_type = "text"
}

# TODO: replace deprecated null_resource with terraform_data
# https://developer.hashicorp.com/terraform/language/resources/terraform-data
resource "null_resource" "upload" {
triggers = {
version = "${var.det_version}"
Expand Down
8 changes: 8 additions & 0 deletions docs/deploy/vars_EE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
domain: "hpe-mlde.determined.ai"
cdn:
acm_certificate_arn: "arn:aws:acm:us-east-1:573932760021:certificate/f117a2ed-a377-4a71-b42e-d00c9339adff"
s3:
bucket: "hpe-mlde-docs"
robots:
content: "User-agent: *\nSitemap: https://hpe-mlde.determined.ai/latest/sitemap.xml"
8 changes: 8 additions & 0 deletions docs/deploy/vars_OSS.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
domain: "docs.determined.ai"
cdn:
acm_certificate_arn: "arn:aws:acm:us-east-1:573932760021:certificate/3f5a03d6-d95b-4d08-ade3-994799c658cf"
s3:
bucket: "determined-ai-docs"
robots:
content: "User-agent: *\nSitemap: https://docs.determined.ai/latest/sitemap.xml"

0 comments on commit fd45ed8

Please sign in to comment.