Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSDEV-899] Move React application to the S3 bucket #449

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

roninzp
Copy link
Contributor

@roninzp roninzp commented Dec 10, 2024

After moving the React application to an S3 bucket, we transfer the processing of part of the traffic to the CDN, which allows us to use the computing resources of the ECS cluster more efficiently.

@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp had a problem deploying to Quality Environment December 10, 2024 14:02 — with GitHub Actions Failure
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 10, 2024 14:02 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 13, 2024 14:22 — with GitHub Actions Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (2)
deployment/terraform/cdn.tf (2)

26-32: Consider enabling versioning for production environments

Versioning is currently suspended, which could make it difficult to recover from accidental deletions or modifications. For production environments, it's recommended to enable versioning.

Consider enabling versioning and adding lifecycle rules:

resource "aws_s3_bucket_versioning" "react" {
  bucket = aws_s3_bucket.react.id
  versioning_configuration {
    status = "Enabled"  # Enable for production
  }
}

resource "aws_s3_bucket_lifecycle_rule" "react" {
  bucket = aws_s3_bucket.react.id
  id      = "cleanup-old-versions"
  enabled = true

  noncurrent_version_expiration {
    days = 30  # Adjust retention period as needed
  }
}

Line range hint 42-467: Add security headers and origin failover

The CloudFront distribution is missing important security headers and origin failover configuration.

Consider adding:

  1. Security headers using Lambda@Edge or CloudFront Functions
  2. Origin failover for high availability

Example configuration for security headers using CloudFront Functions:

resource "aws_cloudfront_function" "security_headers" {
  name    = "security-headers"
  runtime = "cloudfront-js-1.0"
  code    = <<-EOT
function handler(event) {
    var response = event.response;
    var headers = response.headers;
    
    headers['strict-transport-security'] = { value: 'max-age=63072000; includeSubdomains; preload'};
    headers['x-content-type-options'] = { value: 'nosniff'};
    headers['x-frame-options'] = { value: 'DENY'};
    headers['x-xss-protection'] = { value: '1; mode=block'};
    headers['referrer-policy'] = { value: 'same-origin'};
    headers['content-security-policy'] = { value: "default-src 'self'"};
    
    return response;
}
EOT
}

For the CloudFront distribution, add:

  # In default_cache_behavior and ordered_cache_behavior blocks
  function_association {
    event_type   = "viewer-response"
    function_arn = aws_cloudfront_function.security_headers.arn
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c90d10 and 149d104.

📒 Files selected for processing (1)
  • deployment/terraform/cdn.tf (4 hunks)

deployment/terraform/cdn.tf Show resolved Hide resolved
deployment/terraform/cdn.tf Show resolved Hide resolved
deployment/terraform/cdn.tf Show resolved Hide resolved
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:20 — with GitHub Actions Inactive
Copy link

sonarqubecloud bot commented Dec 18, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:22 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:27 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:28 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:28 — with GitHub Actions Inactive
@roninzp roninzp temporarily deployed to Quality Environment December 18, 2024 13:37 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant