Skip to content

telia-oss/terraform-aws-cloudfront-subdomains

Repository files navigation

Terraform Module for Cloudfront Subdomains

latest release build status

Terraform module which creates a Cloudfront resource in AWS, which dynamically maps subdomains to static files in subfolders of a S3 bucket.

Usage

See the example.

Example request flow

sequenceDiagram
    participant AD
    participant User
    participant ViewerRequest
    participant CloudFront
    participant OriginResponse
    participant S3
    User->>ViewerRequest: red-color.branch.<hostname>/auth:ad
    Note over ViewerRequest: Rewrite path (subfolder)
    ViewerRequest->>CloudFront: red-color.branch.<hostname>/red-color/auth:ad
    CloudFront->>S3: telia-no-oneportal-frontend-dev-branch.s3.eu-west-1.amazonaws.com/red-color/auth:ad
    S3->>OriginResponse: File Not Found
    Note over OriginResponse: Rewrite to redirect
    OriginResponse->>User: Redirect red-color.branch.<hostname>/auth:ad?cloudfrontindex=true
    User->>ViewerRequest: red-color.branch.<hostname>/auth:ad?cloudfrontindex=true
    Note over ViewerRequest: Rewrite path (subfolder and file)
    ViewerRequest->>CloudFront: red-color.branch.<hostname>/red-color/shell/index.html
    CloudFront->>S3: telia-no-oneportal-frontend-dev-branch.s3.eu-west-1.amazonaws.com/red-color/shell/index.html
    S3->>OriginResponse: File red-color/shell/index.html
    OriginResponse->>User: File red-color/shell/index.html
    Note over User: Fetches and runs JavaScript files linked in index.html
    User->>AD: /login?state=red-color
    AD->>User: Redirect branch.<hostname>/_callback/internal#35;state=ey...|red-color
    User->>ViewerRequest: branch.<hostname>/_callback/internal#35;state=ey...|red-color
    ViewerRequest->>User: AD redirect script
    Note over User: Rewrite host and redirect
    User->>ViewerRequest: red-color.branch.<hostname>/_callback/internal
    Note over ViewerRequest: Rewrite subfolder
    ViewerRequest->>CloudFront: red-color.branch.<hostname>/red-color/_callback/internal
    CloudFront->>S3: telia-no-oneportal-frontend-dev-branch.s3.eu-west-1.amazonaws.com/red-color/_callback/internal
    S3->>OriginResponse: File Not Found
    Note over OriginResponse: Rewrite to redirect
    OriginResponse->>User: Redirect red-color.branch.<hostname>/_callback/internal?cloudfrontindex=true
    Note over ViewerRequest: Rewrite subfolder and path
    ViewerRequest->>CloudFront: red-color.branch.<hostname>/red-color/shell/index.html
    CloudFront->>S3: telia-no-oneportal-frontend-dev-branch.s3.eu-west-1.amazonaws.com/red-color/shell/index.html
    S3->>OriginResponse: File red-color/shell/index.html
    OriginResponse->>User: File red-color/shell/index.html
Loading

Authors

Currently maintained by these contributors.

License

MIT License. See LICENSE for full details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published