updated deploy files (#1387)
parent
226ec726e7
commit
689b6b571f
|
@ -5,7 +5,7 @@ jobs:
|
||||||
- image: circleci/node:erbium
|
- image: circleci/node:erbium
|
||||||
environment:
|
environment:
|
||||||
HUGO_VERSION: "0.59.1"
|
HUGO_VERSION: "0.59.1"
|
||||||
S3DEPLOY_VERSION: "2.3.2"
|
S3DEPLOY_VERSION: "2.3.5"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
|
|
|
@ -7,10 +7,10 @@ aws cloudformation deploy \
|
||||||
--template-file deploy/docs-website.yml \
|
--template-file deploy/docs-website.yml \
|
||||||
--stack-name="${STACK_NAME}" \
|
--stack-name="${STACK_NAME}" \
|
||||||
--capabilities CAPABILITY_IAM \
|
--capabilities CAPABILITY_IAM \
|
||||||
--no-execute-changeset \
|
|
||||||
--parameter-overrides \
|
--parameter-overrides \
|
||||||
AcmCertificateArn="${ACM_ARN}" \
|
AcmCertificateArn="${ACM_ARN}" \
|
||||||
DomainName="${DOMAIN_NAME}"
|
DomainName="${DOMAIN_NAME}"
|
||||||
```
|
```
|
||||||
|
|
||||||
The `--no-execute-changeset` option will display the actions that will be taken. Remove the `--no-execute-changeset` option to actually deploy a change.
|
To only display actions that will be taken, in the `--no-execute-changeset` option.
|
||||||
|
Without this option, the command executes and deploys the changeset.
|
||||||
|
|
|
@ -126,152 +126,13 @@ Resources:
|
||||||
ZipFile: |
|
ZipFile: |
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
// This is a a placeholder lambda function. Use the AWS Lambda console
|
||||||
|
// to add/update the contents of deploy/edge.js to the actual Lambda
|
||||||
|
// function and deploy it to Lambda@Edge
|
||||||
|
|
||||||
const latestVersions = {
|
const { request } = event.Records[0].cf;
|
||||||
'influxdb': 'v1.8',
|
|
||||||
'influxdbv2': 'v2.0',
|
|
||||||
'telegraf': 'v1.15',
|
|
||||||
'chronograf': 'v1.8',
|
|
||||||
'kapacitor': 'v1.5',
|
|
||||||
'enterprise': 'v1.8',
|
|
||||||
};
|
|
||||||
|
|
||||||
const archiveDomain = 'http://archive.docs.influxdata.com';
|
|
||||||
|
|
||||||
exports.handler = (event, context, callback) => {
|
exports.handler = (event, context, callback) => {
|
||||||
|
|
||||||
function temporaryRedirect(condition, newUri) {
|
|
||||||
if (condition) {
|
|
||||||
return callback(null, {
|
|
||||||
status: '302',
|
|
||||||
statusDescription: 'Found',
|
|
||||||
headers: {
|
|
||||||
location: [{
|
|
||||||
key: 'Location',
|
|
||||||
value: newUri,
|
|
||||||
}],
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function permanantRedirect(condition, newUri) {
|
|
||||||
if (condition) {
|
|
||||||
return callback(null, {
|
|
||||||
status: '301',
|
|
||||||
statusDescription: 'Moved Permanently',
|
|
||||||
headers: {
|
|
||||||
'location': [{
|
|
||||||
key: 'Location',
|
|
||||||
value: newUri,
|
|
||||||
}],
|
|
||||||
'cache-control': [{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: "max-age=3600"
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { request } = event.Records[0].cf;
|
|
||||||
const parsedPath = path.parse(request.uri);
|
|
||||||
const indexPath = 'index.html';
|
|
||||||
const validExtensions = {
|
|
||||||
'.html': true,
|
|
||||||
'.css': true,
|
|
||||||
'.js': true,
|
|
||||||
'.xml': true,
|
|
||||||
'.png': true,
|
|
||||||
'.gif': true,
|
|
||||||
'.jpg': true,
|
|
||||||
'.ico': true,
|
|
||||||
'.svg': true,
|
|
||||||
'.csv': true,
|
|
||||||
'.txt': true,
|
|
||||||
'.lp': true,
|
|
||||||
'.json': true,
|
|
||||||
'.rb': true,
|
|
||||||
'.eot': true,
|
|
||||||
'.ttf': true,
|
|
||||||
'.woff': true,
|
|
||||||
'.otf': true,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove index.html from path
|
|
||||||
permanantRedirect(request.uri.endsWith('index.html'), request.uri.substr(0, request.uri.length - indexPath.length));
|
|
||||||
|
|
||||||
// If file has a valid extension, return the request unchanged
|
|
||||||
if (validExtensions[parsedPath.ext]) {
|
|
||||||
callback(null, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////// START PRODUCT-SPECIFIC REDIRECTS //////////////////////
|
|
||||||
|
|
||||||
//////////////////////////// v2 subdomain redirect ///////////////////////////
|
|
||||||
permanantRedirect(request.headers.host[0].value === 'v2.docs.influxdata.com', `https://docs.influxdata.com${request.uri}`);
|
|
||||||
|
|
||||||
////////////////////////// Latest version redirects //////////////////////////
|
|
||||||
temporaryRedirect(/\/influxdb\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['influxdb']}`));
|
|
||||||
temporaryRedirect(/\/telegraf\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['telegraf']}`));
|
|
||||||
temporaryRedirect(/\/chronograf\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['chronograf']}`));
|
|
||||||
temporaryRedirect(/\/kapacitor\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['kapacitor']}`));
|
|
||||||
temporaryRedirect(/\/enterprise_influxdb\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['enterprise']}`));
|
|
||||||
|
|
||||||
////////////////////////// Versionless URL redirects /////////////////////////
|
|
||||||
temporaryRedirect(request.uri === '/influxdb/', `/influxdb/${latestVersions['influxdb']}/`);
|
|
||||||
temporaryRedirect(request.uri === '/telegraf/', `/telegraf/${latestVersions['telegraf']}/`);
|
|
||||||
temporaryRedirect(request.uri === '/chronograf/', `/chronograf/${latestVersions['chronograf']}/`);
|
|
||||||
temporaryRedirect(request.uri === '/kapacitor/', `/kapacitor/${latestVersions['kapacitor']}/`);
|
|
||||||
temporaryRedirect(request.uri === '/enterprise_influxdb/', `/enterprise_influxdb/${latestVersions['enterprise']}/`);
|
|
||||||
|
|
||||||
/////////////////////////////// Flux redirects ///////////////////////////////
|
|
||||||
// Redirect flux guides and introduction based on latest InfluxDB version
|
|
||||||
if (/v2/.test(latestVersions['influxdb'])) {
|
|
||||||
temporaryRedirect(/\/flux\/v0\.[0-9]{1,2}\/guides\//.test(request.uri), request.uri.replace(/\/flux\/v0\.[0-9]{1,2}\/guides\//, `/influxdb/${latestVersions['influxdb']}/query-data/flux/`));
|
|
||||||
temporaryRedirect(/\/flux\/v0\.[0-9]{1,2}\/guides\//.test(request.uri), request.uri.replace(/\/flux\/v0\.[0-9]{1,2}\/introduction\//, `/influxdb/${latestVersions['influxdb']}/query-data/get-started/`));
|
|
||||||
} else {
|
|
||||||
temporaryRedirect(/\/flux\/v0\.[0-9]{1,2}\/guides\//.test(request.uri), request.uri.replace(/\/flux\/v0\.[0-9]{1,2}\/guides\//, `/influxdb/${latestVersions['influxdb']}/flux/guides/`));
|
|
||||||
temporaryRedirect(/\/flux\/v0\.[0-9]{1,2}\/guides\//.test(request.uri), request.uri.replace(/\/flux\/v0\.[0-9]{1,2}\/introduction\//, `/influxdb/${latestVersions['influxdb']}/flux/introduction/`));
|
|
||||||
}
|
|
||||||
// Redirect Flux stdlib and language sections to v2 Flux docs
|
|
||||||
temporaryRedirect(/\/flux\/v0\.[0-9]{1,2}\/(?:functions|stdlib|language)\//.test(request.uri), request.uri.replace(/\/flux\/v0\.[0-9]{1,2}\//, `/influxdb/${latestVersions['influxdbv2']}/reference/flux/`));
|
|
||||||
|
|
||||||
// Redirect versionless and base version to v2 Flux docs
|
|
||||||
temporaryRedirect(/^\/flux\/(?:v0\.[0-9]{1,2}\/|)$/.test(request.uri), `/influxdb/${latestVersions['influxdbv2']}/reference/flux/`);
|
|
||||||
|
|
||||||
////////////////////////////// v2 path redirect //////////////////////////////
|
|
||||||
permanantRedirect(/^\/v2\.0\//.test(request.uri), request.uri.replace(/^\/v2\.0\//, `/influxdb/v2.0/`));
|
|
||||||
|
|
||||||
////////////////////////// Archive version redirects /////////////////////////
|
|
||||||
permanantRedirect(/\/influxdb\/(?:v0\.[0-9]{1,2}|v1\.[0-2])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
||||||
permanantRedirect(/\/telegraf\/(?:v0\.[0-9]{1,2}|v1\.[0-8])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
||||||
permanantRedirect(/\/chronograf\/(?:v0\.[0-9]{1,2}|v1\.[0-5])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
||||||
permanantRedirect(/\/kapacitor\/(?:v0\.[0-9]{1,2}|v1\.[0-3])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
||||||
permanantRedirect(/\/enterprise_influxdb\/v1\.[0-3]\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
||||||
permanantRedirect(/\/enterprise_kapacitor\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
||||||
|
|
||||||
/////////////////////// END PRODUCT-SPECIFIC REDIRECTS ///////////////////////
|
|
||||||
|
|
||||||
// Redirect to the a trailing slash
|
|
||||||
permanantRedirect(!request.uri.endsWith('/'), request.uri + '/');
|
|
||||||
|
|
||||||
// Use index.html if the path doesn't have an extension
|
|
||||||
// or if the version number is parsed as an extension.
|
|
||||||
let newUri;
|
|
||||||
|
|
||||||
if (parsedPath.ext === '' || /\.\d*/.test(parsedPath.ext)) {
|
|
||||||
newUri = path.join(parsedPath.dir, parsedPath.base, indexPath);
|
|
||||||
} else {
|
|
||||||
newUri = request.uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace the received URI with the URI that includes the index page
|
|
||||||
request.uri = newUri;
|
|
||||||
|
|
||||||
// Return to CloudFront
|
|
||||||
// request.uri = request.uri + indexPath;
|
|
||||||
callback(null, request);
|
callback(null, request);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
###############################################################################
|
|
||||||
### AWS Cloudformation Template
|
|
||||||
### InfluxData Documentation Website Hosting and Deployment
|
|
||||||
###############################################################################
|
|
||||||
AWSTemplateFormatVersion: 2010-09-09
|
|
||||||
###############################################################################
|
|
||||||
Resources:
|
|
||||||
###############################################################################
|
|
||||||
DocsOriginRequestRewriteLambdaRole:
|
|
||||||
Type: AWS::IAM::Role
|
|
||||||
Properties:
|
|
||||||
RoleName: test1-DocsOriginRequestRewriteLambdaRole-10RT8O6PQO2ZE
|
|
||||||
AssumeRolePolicyDocument:
|
|
||||||
Version: 2012-10-17
|
|
||||||
Statement:
|
|
||||||
- Effect: Allow
|
|
||||||
Action: sts:AssumeRole
|
|
||||||
Principal:
|
|
||||||
Service:
|
|
||||||
- edgelambda.amazonaws.com
|
|
||||||
- lambda.amazonaws.com
|
|
||||||
ManagedPolicyArns:
|
|
||||||
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
Loading…
Reference in New Issue