Skip to content

Commit

Permalink
target s3 bucket with docs refresh script (digital-asset#1287)
Browse files Browse the repository at this point in the history
There is no simple way to configure GCS to serve the desired security
headers, so instead the script will keep updating the existing s3
bucket.

Consequent changes:

- Add aws cli tool to dev-env
- Remove docs bucket from Terraform
  • Loading branch information
garyverhaegen-da authored and mergify[bot] committed May 21, 2019
1 parent be2457c commit c762d49
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 105 deletions.
25 changes: 17 additions & 8 deletions azure-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
- bash: |
set -euo pipefail
CUR_SHA=$(git rev-parse HEAD)
robustly_download_nix_pkgs() {
# In recent commits, this is part of the dev-env-install script.
# However, we have to copy it here to apply it to older versions.
Expand Down Expand Up @@ -66,16 +68,23 @@ jobs:
mkdir -p $DOCDIR/${version#v}
tar xzf bazel-genfiles/docs/html.tar.gz --strip-components=1 -C $DOCDIR/${version#v} >$LOG 2>&1
done
echo "Maintain proper 404 page"
curl -s https://docs.daml.com/not-found.html > $DOCDIR/not-found.html
echo "Pushing to GCS bucket..."
GCS_KEY=$(mktemp)
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY
gcloud auth activate-service-account --key-file=$GCS_KEY >$LOG 2>&1
BOTO_CONFIG=/dev/null gsutil rsync -d -r $DOCDIR gs://daml-docs >$LOG 2>&1
git checkout $CUR_SHA
echo "Pushing to S3 bucket..."
aws s3 sync $DOCDIR \
s3://docs-daml-com/ \
--delete \
--acl public-read \
--exclude '*.doctrees/*' \
--exclude '*.buildinfo'
echo "Refreshing CloudFront cache..."
aws cloudfront create-invalidation \
--distribution-id E1U753I56ERH55 \
--paths '/*'
echo "Done."
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
- task: PublishPipelineArtifact@0
condition: always()
inputs:
Expand Down
1 change: 1 addition & 0 deletions dev-env/bin/aws
37 changes: 0 additions & 37 deletions infra/docs_bucket.tf

This file was deleted.

1 change: 0 additions & 1 deletion infra/modules/gcp_cdn_bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ It also makes a few assumptions:
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| cache\_retention\_days | The number of days to keep the objects around | string | n/a | yes |
| default\_file | The name of the file (from the files folder) to show for unknown paths. Currently one of cache or docs. | string | `"cache"` | no |
| labels | Labels to apply on all the resources | map | `<map>` | no |
| name | Name prefix for all the resources | string | n/a | yes |
| project | GCP project name | string | n/a | yes |
Expand Down
42 changes: 0 additions & 42 deletions infra/modules/gcp_cdn_bucket/files/docs.html

This file was deleted.

13 changes: 1 addition & 12 deletions infra/modules/gcp_cdn_bucket/google_storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ resource "google_storage_bucket" "default" {

website {
main_page_suffix = "index.html"
not_found_page = "${var.default_file == "docs" ? "not-found.html" : ""}"
}

force_destroy = true
Expand All @@ -54,19 +53,9 @@ resource "google_storage_bucket_acl" "default" {
}

resource "google_storage_bucket_object" "default" {
count = "${var.default_file == "cache" ? 1 : 0}"
name = "index.html"
bucket = "${google_storage_bucket.default.name}"
content = "${file("${path.module}/files/${var.default_file}.html")}"
content_type = "text/html"
depends_on = ["google_storage_bucket_acl.default"]
}

resource "google_storage_bucket_object" "not_found" {
count = "${var.default_file == "docs" ? 1 : 0}"
name = "not-found.html"
bucket = "${google_storage_bucket.default.name}"
content = "${file("${path.module}/files/${var.default_file}.html")}"
content = "${file("${path.module}/files/index.html")}"
content_type = "text/html"
depends_on = ["google_storage_bucket_acl.default"]
}
5 changes: 0 additions & 5 deletions infra/modules/gcp_cdn_bucket/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ variable "ssl_certificate" {
variable "cache_retention_days" {
description = "The number of days to keep the objects around"
}

variable "default_file" {
description = "The name of the file (from the files folder) to show for unknown paths. Currently one of cache or docs."
default = "cache"
}
1 change: 1 addition & 0 deletions nix/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ in rec {
jfrog = pkgs.callPackage ./tools/jfrog-cli {};

# Cloud tools
aws = pkgs.awscli;
gcloud = pkgs.google-cloud-sdk;
bq = gcloud;
gsutil = gcloud;
Expand Down

0 comments on commit c762d49

Please sign in to comment.