diff --git a/template.yaml b/template.yaml index 0e1a7a55..ec46d244 100644 --- a/template.yaml +++ b/template.yaml @@ -999,71 +999,71 @@ Resources: Type: AWS::Serverless::HttpApi Properties: StageName: latest - # rootRedirect: - # Type: AWS::Serverless::Function - # Properties: - # CodeUri: ./redirect - # Handler: index.handler - # Timeout: 1 - # Description: Redirects to latest version of docs - # Environment: - # Variables: - # REDIRECT_TO: /docs/v2/index.html - # Events: - # RedirectApiGet: - # Type: HttpApi - # Properties: - # ApiId: !Ref rootApi - # Path: / - # Method: GET - # RedirectApiHead: - # Type: HttpApi - # Properties: - # ApiId: !Ref rootApi - # Path: / - # Method: HEAD + rootRedirect: + Type: AWS::Serverless::Function + Properties: + CodeUri: ./redirect + Handler: index.handler + Timeout: 1 + Description: Redirects to latest version of docs + Environment: + Variables: + REDIRECT_TO: /docs/v2/index.html + Events: + RedirectApiGet: + Type: HttpApi + Properties: + ApiId: !Ref rootApi + Path: / + Method: GET + RedirectApiHead: + Type: HttpApi + Properties: + ApiId: !Ref rootApi + Path: / + Method: HEAD # Documentation - # docsMapping: - # Type: AWS::ApiGatewayV2::ApiMapping - # Properties: - # DomainName: !Sub "${CustomDomainHost}.${CustomDomainZone}" - # ApiId: !Ref rootApi - # Stage: !Ref rootApilatestStage - # DependsOn: dcApi - # docsBucket: - # Type: AWS::S3::Bucket - # Properties: - # BucketName: !Sub "${CustomDomainHost}-docs.${CustomDomainZone}" - # AccessControl: PublicRead - # WebsiteConfiguration: - # IndexDocument: index.html - # ErrorDocument: index.html - # docsBucketPolicy: - # Type: AWS::S3::BucketPolicy - # Properties: - # PolicyDocument: - # Id: MyPolicy - # Version: 2012-10-17 - # Statement: - # - Sid: PublicReadForGetBucketObjects - # Effect: Allow - # Principal: "*" - # Action: "s3:GetObject" - # Resource: !Sub "arn:aws:s3:::${docsBucket}/*" - # Bucket: !Ref docsBucket - # docsIntegration: - # Type: AWS::ApiGatewayV2::Integration - # Properties: - # ApiId: !Ref rootApi - # IntegrationMethod: GET - # IntegrationType: HTTP_PROXY - # IntegrationUri: !Sub "http://${docsBucket}.s3-website-us-east-1.amazonaws.com/{proxy}" - # PayloadFormatVersion: "1.0" - # docsRoute: - # Type: AWS::ApiGatewayV2::Route - # Properties: - # ApiId: !Ref rootApi - # AuthorizationType: NONE - # RouteKey: GET /docs/v2/{proxy+} - # Target: !Sub "integrations/${docsIntegration}" + docsMapping: + Type: AWS::ApiGatewayV2::ApiMapping + Properties: + DomainName: !Sub "${CustomDomainHost}.${CustomDomainZone}" + ApiId: !Ref rootApi + Stage: !Ref rootApilatestStage + DependsOn: dcApi + docsBucket: + Type: AWS::S3::Bucket + Properties: + BucketName: !Sub "${CustomDomainHost}-docs.${CustomDomainZone}" + AccessControl: PublicRead + WebsiteConfiguration: + IndexDocument: index.html + ErrorDocument: index.html + docsBucketPolicy: + Type: AWS::S3::BucketPolicy + Properties: + PolicyDocument: + Id: MyPolicy + Version: 2012-10-17 + Statement: + - Sid: PublicReadForGetBucketObjects + Effect: Allow + Principal: "*" + Action: "s3:GetObject" + Resource: !Sub "arn:aws:s3:::${docsBucket}/*" + Bucket: !Ref docsBucket + docsIntegration: + Type: AWS::ApiGatewayV2::Integration + Properties: + ApiId: !Ref rootApi + IntegrationMethod: GET + IntegrationType: HTTP_PROXY + IntegrationUri: !Sub "http://${docsBucket}.s3-website-us-east-1.amazonaws.com/{proxy}" + PayloadFormatVersion: "1.0" + docsRoute: + Type: AWS::ApiGatewayV2::Route + Properties: + ApiId: !Ref rootApi + AuthorizationType: NONE + RouteKey: GET /docs/v2/{proxy+} + Target: !Sub "integrations/${docsIntegration}"