From a837bcaebcdb73c550be6d647b5d323fac80f180 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 26 Aug 2020 23:19:33 -0600 Subject: [PATCH] Deploy refactor (#1370) * Change lambda function to recognize clean URLs * More bug fixes to CF template and function * Add redirect for root to /v2.0 * Fix lambda rewrite logic * Switch to using multiple cache behaviors * Experiment with deleting lambda@edge functions * Change lambda function to recognize clean URLs * More bug fixes to CF template and function * Add redirect for root to /v2.0 * Fix lambda rewrite logic * Switch to using multiple cache behaviors * Experiment with deleting lambda@edge functions * Update nodejs version in redirect lambda * Use edge lambda function and remove path redirects. * updated edge.js and cloudformation template * revamped lambda edge function, made other template adjustments Co-authored-by: Gunnar Aasen --- assets/js/content-interactions.js | 7 - config.toml | 2 +- .../introduction/installation_guidelines.md | 1 - .../introduction/installation_guidelines.md | 1 - .../introduction/installation_requirements.md | 1 - .../introduction/installation_requirements.md | 1 - deploy/README.md | 2 +- deploy/docs-website.yml | 248 +++++++++++------- deploy/edge.js | 150 +++++++++++ deploy/remove-lambda.yml | 23 ++ layouts/partials/topnav/product-selector.html | 2 +- layouts/partials/topnav/version-selector.html | 2 +- static/img/coming-soon.svg | 66 ----- 13 files changed, 328 insertions(+), 178 deletions(-) create mode 100644 deploy/edge.js create mode 100644 deploy/remove-lambda.yml delete mode 100644 static/img/coming-soon.svg diff --git a/assets/js/content-interactions.js b/assets/js/content-interactions.js index 0c2b6cd49..58211c9be 100644 --- a/assets/js/content-interactions.js +++ b/assets/js/content-interactions.js @@ -94,13 +94,6 @@ $('.expand-label').click(function() { $(this).next('.expand-content').slideToggle(200) }) -//////////////////// Replace Missing Images with Placeholder /////////////////// - -$(".article--content img").on("error", function() { - $(this).attr("src", "/img/coming-soon.svg"); - $(this).attr("style", "max-width:500px;"); -}); - ////////////////////////// Inject tooltips on load ////////////////////////////// $('.tooltip').each( function(){ diff --git a/config.toml b/config.toml index ab58ca106..01dc6f9e9 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,4 @@ -baseURL = "https://v2.docs.influxdata.com/" +baseURL = "https://docs.influxdata.com/" languageCode = "en-us" title = "InfluxDB Documentation" diff --git a/content/enterprise_influxdb/v1.5/introduction/installation_guidelines.md b/content/enterprise_influxdb/v1.5/introduction/installation_guidelines.md index d1410eca8..d90eb5d02 100644 --- a/content/enterprise_influxdb/v1.5/introduction/installation_guidelines.md +++ b/content/enterprise_influxdb/v1.5/introduction/installation_guidelines.md @@ -3,7 +3,6 @@ title: Installation options (⏰ Please Read!) aliases: - /enterprise_influxdb/v1.5/introduction/meta_node_installation/ - /enterprise_influxdb/v1.5/introduction/data_node_installation/ - - /{{< latest "chronograf" >}}/introduction/installation - /enterprise/v1.5/introduction/installation_guidelines/ menu: enterprise_influxdb_1_5: diff --git a/content/enterprise_influxdb/v1.6/introduction/installation_guidelines.md b/content/enterprise_influxdb/v1.6/introduction/installation_guidelines.md index e6f7cc09f..50b038bd7 100644 --- a/content/enterprise_influxdb/v1.6/introduction/installation_guidelines.md +++ b/content/enterprise_influxdb/v1.6/introduction/installation_guidelines.md @@ -3,7 +3,6 @@ title: Installation options (⏰ Please Read!) aliases: - /enterprise_influxdb/v1.6/introduction/meta_node_installation/ - /enterprise_influxdb/v1.6/introduction/data_node_installation/ - - /{{< latest "chronograf" >}}/introduction/installation - /enterprise/v1.6/introduction/installation_guidelines/ menu: enterprise_influxdb_1_6: diff --git a/content/enterprise_influxdb/v1.7/introduction/installation_requirements.md b/content/enterprise_influxdb/v1.7/introduction/installation_requirements.md index dd85678b6..e3842e77c 100644 --- a/content/enterprise_influxdb/v1.7/introduction/installation_requirements.md +++ b/content/enterprise_influxdb/v1.7/introduction/installation_requirements.md @@ -3,7 +3,6 @@ title: Installation requirements aliases: - /enterprise_influxdb/v1.7/introduction/meta_node_installation/ - /enterprise_influxdb/v1.7/introduction/data_node_installation/ - - /{{< latest "chronograf" >}}/introduction/installation - /enterprise/v1.7/introduction/installation_guidelines/ menu: enterprise_influxdb_1_7: diff --git a/content/enterprise_influxdb/v1.8/introduction/installation_requirements.md b/content/enterprise_influxdb/v1.8/introduction/installation_requirements.md index 8ad14c81b..8dc2b6287 100644 --- a/content/enterprise_influxdb/v1.8/introduction/installation_requirements.md +++ b/content/enterprise_influxdb/v1.8/introduction/installation_requirements.md @@ -3,7 +3,6 @@ title: Installation requirements aliases: - /enterprise_influxdb/v1.8/introduction/meta_node_installation/ - /enterprise_influxdb/v1.8/introduction/data_node_installation/ - - /{{< latest "chronograf" >}}/introduction/installation - /enterprise/v1.8/introduction/installation_guidelines/ menu: enterprise_influxdb_1_8: diff --git a/deploy/README.md b/deploy/README.md index da584ee5a..66b32c8ca 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -4,7 +4,7 @@ Use the following command to deploy a CloudFormation stack using the template in ```sh aws cloudformation deploy \ - --template-file docs-website.yml \ + --template-file deploy/docs-website.yml \ --stack-name="${STACK_NAME}" \ --capabilities CAPABILITY_IAM \ --no-execute-changeset \ diff --git a/deploy/docs-website.yml b/deploy/docs-website.yml index 5a1c1b64b..88674da15 100644 --- a/deploy/docs-website.yml +++ b/deploy/docs-website.yml @@ -33,7 +33,7 @@ Outputs: DocsProdBucketArn: Description: The ARN of the S3 bucket hosting the static content. - Value: !GetAtt DocsV2Bucket.Arn + Value: !GetAtt DocsBucket.Arn DocsCircleCIDeployAccessKeyId: Description: The access key ID for CircleCI deployment to S3. @@ -49,21 +49,21 @@ Resources: DocsCloudFrontDistribution: Type: AWS::CloudFront::Distribution - Description: The CDN for both V1 and V2 docs. Properties: DistributionConfig: Aliases: - !Ref DomainName DefaultCacheBehavior: + TargetOriginId: !Ref DocsBucket + ViewerProtocolPolicy: redirect-to-https + DefaultTTL: 2592000 Compress: true ForwardedValues: QueryString: false - TargetOriginId: !Ref DocsV2Bucket - ViewerProtocolPolicy: redirect-to-https LambdaFunctionAssociations: - EventType: origin-request LambdaFunctionARN: !Ref DocsOriginRequestRewriteLambdaVersion - DefaultRootObject: index.html + DefaultRootObject: '/' CustomErrorResponses: - ErrorCachingMinTTL: 300 ErrorCode: 403 @@ -72,15 +72,8 @@ Resources: Enabled: true HttpVersion: http2 Origins: - - DomainName: - !Sub "${DocsV2Bucket}.s3.amazonaws.com" - Id: !Ref DocsV2Bucket - S3OriginConfig: - OriginAccessIdentity: - !Sub "origin-access-identity/cloudfront/${DocsCloudFrontOriginAccessIdentity}" - - DomainName: - !Sub "${DocsV1Bucket}.s3.amazonaws.com" - Id: !Ref DocsV1Bucket + - Id: !Ref DocsBucket + DomainName: !Join [ "", [ !Ref DocsBucket, ".s3.amazonaws.com" ] ] S3OriginConfig: OriginAccessIdentity: !Sub "origin-access-identity/cloudfront/${DocsCloudFrontOriginAccessIdentity}" @@ -99,7 +92,7 @@ Resources: CloudFrontOriginAccessIdentityConfig: Comment: !Sub 'CloudFront Origin Access Identity for ${DomainName}' - DocsV2Bucket: + DocsBucket: Type: AWS::S3::Bucket Properties: BucketEncryption: @@ -111,42 +104,17 @@ Resources: - Key: Domain Value: !Ref DomainName - DocsV2BucketPolicy: + DocsBucketPolicy: Type: AWS::S3::BucketPolicy Properties: - Bucket: !Ref DocsV2Bucket + Bucket: !Ref DocsBucket PolicyDocument: Statement: - Effect: Allow Action: - s3:GetObject - Resource: !Sub "arn:aws:s3:::${DocsV2Bucket}/*" - Principal: - CanonicalUser: !GetAtt DocsCloudFrontOriginAccessIdentity.S3CanonicalUserId - - DocsV1Bucket: - Type: AWS::S3::Bucket - Properties: - BucketEncryption: - ServerSideEncryptionConfiguration: - - - ServerSideEncryptionByDefault: - SSEAlgorithm: AES256 - Tags: - - Key: Domain - Value: !Ref DomainName - - DocsV1BucketPolicy: - Type: AWS::S3::BucketPolicy - Properties: - Bucket: !Ref DocsV1Bucket - PolicyDocument: - Statement: - - Effect: Allow - Action: - - s3:GetObject - Resource: !Sub "arn:aws:s3:::${DocsV1Bucket}/*" + Resource: !Sub "arn:aws:s3:::${DocsBucket}/*" Principal: CanonicalUser: !GetAtt DocsCloudFrontOriginAccessIdentity.S3CanonicalUserId @@ -158,71 +126,159 @@ Resources: ZipFile: | 'use strict'; + const path = require('path'); + + const latestVersions = { + '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) => { + + 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 { uri, headers, origin } = request; - const extension = uri.substr(uri.lastIndexOf('.') + 1); - - const validExtensions = ['.html', '.css', '.js', '.xml', '.png', '.jpg', '.svg', '.json', '.csv', '.rb', '.otf', '.eot', '.ttf', '.woff']; + const parsedPath = path.parse(request.uri); const indexPath = 'index.html'; - const defaultPath = '/v2.0/' + 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, + }; - // If path ends with '/', then append 'index.html', otherwise redirect to a - // path with '/' or ignore if the path ends with a valid file extension. - if ((uri == '/') || (uri.length < defaultPath.length)) { - callback(null, { - status: '302', - statusDescription: 'Found', - headers: { - location: [{ - key: 'Location', - value: defaultPath, - }], - } - }); - } else if (uri.endsWith('/')) { - request.uri = uri + indexPath; - } else if (uri.endsWith('/index.html')) { - callback(null, { - status: '302', - statusDescription: 'Found', - headers: { - location: [{ - key: 'Location', - value: uri.substr(0, uri.length - indexPath.length), - }], - } - }); - } else if (validExtensions.filter((ext) => uri.endsWith(ext)) == 0) { - callback(null, { - status: '302', - statusDescription: 'Found', - headers: { - location: [{ - key: 'Location', - value: uri + '/', - }], - } - }); + // Remove index.html from path + temporaryRedirect(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); } - const pathsV1 = ['/influxdb', '/telegraf', '/chronograf', '/kapacitor', '/enterprise_influxdb', '/enterprise_kapacitor']; - const originV1 = process.env.ORIGIN_V1; + ////////////////////// START PRODUCT-SPECIFIC REDIRECTS ////////////////////// - // Send to v1 origin if start of path matches - if (pathsV1.filter((path) => uri.startsWith(path)) > 0) { - headers['host'] = [{key: 'host', value: originV1}]; - origin.s3.domainName = originV1; + //////////////////////////// v2 subdomain redirect /////////////////////////// + temporaryRedirect(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 ////////////////////////////// + temporaryRedirect(/^\/v2\.0\//.test(request.uri), request.uri.replace(/^\/v2\.0\//, `/influxdb/${latestVersions['influxdbv2']}/`)); + + ////////////////////////// Archive version redirects ///////////////////////// + temporaryRedirect(/\/influxdb\/(?:v0\.[0-9]{1,2}|v1\.[0-2])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/telegraf\/(?:v0\.[0-9]{1,2}|v1\.[0-8])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/chronograf\/(?:v0\.[0-9]{1,2}|v1\.[0-5])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/kapacitor\/(?:v0\.[0-9]{1,2}|v1\.[0-3])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/enterprise_influxdb\/v1\.[0-3]\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/enterprise_kapacitor\//.test(request.uri), `${archiveDomain}${request.uri}`); + + /////////////////////// END PRODUCT-SPECIFIC REDIRECTS /////////////////////// + + // Redirect to the a trailing slash + temporaryRedirect(!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; } - // If nothing matches, return request unchanged + // 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); }; Handler: index.handler MemorySize: 128 Role: !Sub ${DocsOriginRequestRewriteLambdaRole.Arn} - Runtime: nodejs8.10 + Runtime: nodejs12.x Tags: - Key: Domain Value: !Ref DomainName @@ -261,16 +317,14 @@ Resources: - s3:ListBucket - s3:GetBucketLocation Resource: - - !Sub "arn:aws:s3:::${DocsV2Bucket}" - - !Sub "arn:aws:s3:::${DocsV1Bucket}" + - !Sub "arn:aws:s3:::${DocsBucket}" - Effect: Allow Action: - s3:PutObject - s3:PutObjectAcl - s3:DeleteObject Resource: - - !Sub "arn:aws:s3:::${DocsV2Bucket}/*" - - !Sub "arn:aws:s3:::${DocsV1Bucket}/*" + - !Sub "arn:aws:s3:::${DocsBucket}/*" - Effect: Allow Action: - cloudfront:GetDistribution diff --git a/deploy/edge.js b/deploy/edge.js new file mode 100644 index 000000000..5a1ed6c10 --- /dev/null +++ b/deploy/edge.js @@ -0,0 +1,150 @@ +'use strict'; + +const path = require('path'); + +const latestVersions = { + '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) => { + + 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 + temporaryRedirect(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 /////////////////////////// + temporaryRedirect(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 ////////////////////////////// + temporaryRedirect(/^\/v2\.0\//.test(request.uri), request.uri.replace(/^\/v2\.0\//, `/influxdb/${latestVersions['influxdbv2']}/`)); + + ////////////////////////// Archive version redirects ///////////////////////// + temporaryRedirect(/\/influxdb\/(?:v0\.[0-9]{1,2}|v1\.[0-2])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/telegraf\/(?:v0\.[0-9]{1,2}|v1\.[0-8])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/chronograf\/(?:v0\.[0-9]{1,2}|v1\.[0-5])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/kapacitor\/(?:v0\.[0-9]{1,2}|v1\.[0-3])\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/enterprise_influxdb\/v1\.[0-3]\//.test(request.uri), `${archiveDomain}${request.uri}`); + temporaryRedirect(/\/enterprise_kapacitor\//.test(request.uri), `${archiveDomain}${request.uri}`); + + /////////////////////// END PRODUCT-SPECIFIC REDIRECTS /////////////////////// + + // Redirect to the a trailing slash + temporaryRedirect(!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); +}; \ No newline at end of file diff --git a/deploy/remove-lambda.yml b/deploy/remove-lambda.yml new file mode 100644 index 000000000..7e0be9c5b --- /dev/null +++ b/deploy/remove-lambda.yml @@ -0,0 +1,23 @@ +############################################################################### +### 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 diff --git a/layouts/partials/topnav/product-selector.html b/layouts/partials/topnav/product-selector.html index c7031b9e0..3903a2d1e 100644 --- a/layouts/partials/topnav/product-selector.html +++ b/layouts/partials/topnav/product-selector.html @@ -13,7 +13,7 @@ diff --git a/layouts/partials/topnav/version-selector.html b/layouts/partials/topnav/version-selector.html index c25ca6205..4078c9999 100644 --- a/layouts/partials/topnav/version-selector.html +++ b/layouts/partials/topnav/version-selector.html @@ -10,7 +10,7 @@
  • older
  • {{ range (index .Site.Data.products $product).versions }}
  • - {{ . }} + {{ . }}
  • {{ end }} diff --git a/static/img/coming-soon.svg b/static/img/coming-soon.svg deleted file mode 100644 index 4e1678045..000000000 --- a/static/img/coming-soon.svg +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -