{"id":17982978,"url":"https://github.com/minghsu0107/sync-react-s3-cloudfront","last_synced_at":"2026-05-09T04:32:50.349Z","repository":{"id":144336036,"uuid":"375682893","full_name":"minghsu0107/sync-react-s3-cloudfront","owner":"minghsu0107","description":"This repository demonstrates how to build a CD pipeline that deploys a React application to Amazon S3 and syncing it with Amazon CloudFront.","archived":false,"fork":false,"pushed_at":"2021-06-25T03:36:24.000Z","size":197,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T02:11:14.894Z","etag":null,"topics":["aws","cdn","cloudfront","droneci","react","s3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minghsu0107.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-10T12:04:15.000Z","updated_at":"2025-02-21T23:26:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc4d3220-856d-4bb7-b367-4ece7d2641f6","html_url":"https://github.com/minghsu0107/sync-react-s3-cloudfront","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/minghsu0107/sync-react-s3-cloudfront","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minghsu0107%2Fsync-react-s3-cloudfront","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minghsu0107%2Fsync-react-s3-cloudfront/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minghsu0107%2Fsync-react-s3-cloudfront/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minghsu0107%2Fsync-react-s3-cloudfront/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minghsu0107","download_url":"https://codeload.github.com/minghsu0107/sync-react-s3-cloudfront/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minghsu0107%2Fsync-react-s3-cloudfront/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32807212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cdn","cloudfront","droneci","react","s3"],"created_at":"2024-10-29T18:15:44.881Z","updated_at":"2026-05-09T04:32:50.333Z","avatar_url":"https://github.com/minghsu0107.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React App Deployment with Amazon S3 and CloudFront\nThis repository demonstrates how to build a CD pipeline that deploys a React application to Amazon S3 and syncs it with Amazon CloudFront, a content delivery network (CDN) managed by AWS.\n## Why?\nIt is quite convenient to configure a S3 bucket for static website hosting. However, we can only access it via HTTP protocol. A great way to host our contents is to place it to Amazon CloudFront. This way, not only can we benefit from HTTPS protection but also the out-of-the-box caching mechanism CloudFront provides for us.\n## Prerequisite\n1. A S3 bucket with [static website hosting](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html) enabled. Be sure that the index document is set to `index.html`.\n2. A CloudFront distribution with its origin set to the S3 website endpoint. The endpoint looks like `BUCKET.s3-website.us-east-2.amazonaws.com` where `BUCKET` is a placeholder of your S3 bucket name.\n3. The IAM user must be attached with proper S3 access policies and the following CloudFront policies:\n```\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Action\": \"s3:ListAllMyBuckets\",\n            \"Effect\": \"Allow\",\n            \"Resource\": \"arn:aws:s3:::BUCKET\"\n        },\n        {\n            \"Action\": [\n                \"cloudfront:CreateInvalidation\",\n                \"cloudfront:GetDistribution\",\n                \"cloudfront:GetStreamingDistribution\",\n                \"cloudfront:GetDistributionConfig\",\n                \"cloudfront:GetInvalidation\",\n                \"cloudfront:ListInvalidations\",\n                \"cloudfront:ListStreamingDistributions\",\n                \"cloudfront:ListDistributions\"\n            ],\n            \"Effect\": \"Allow\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\nWhere BUCKET is a placeholder of your bucket name.\n## CD Pipeline\nWe are using [Drone CI](https://www.drone.io) as our automation tool. There are two main steps in the pipeline, which are building React applcation and deploying to AWS.\n\n1. **Building React application** - In this step, we install all dependencies and create a minified bundle to `build/` folder.\n\n```yaml\n- name: build-react-app\n  image: node:15.14\n  commands:\n  - npm install \u0026\u0026 npm run build\n```\n\n2. **Deploy to AWS** - In this step, we upload the minified bundle to S3 and invalidate the CloudFront cache in order to see the updated website instantly.\n\n```yaml\n- name: sync-react-app\n  image: amazon/aws-cli:2.1.29\n  environment:\n    AWS_ACCESS_KEY_ID: \n      from_secret: aws_access_key_id\n    AWS_SECRET_ACCESS_KEY:\n      from_secret: aws_secret_access_key\n    CLOUDFRONT_DISTRIBUTION_ID:\n      from_secret: cloudfront_distribution_id\n    BUCKET:\n      from_secret: bucket\n  commands:\n  - aws s3 sync ./build/ s3://$BUCKET/ --delete --acl public-read\n  - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths \"/*\" \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminghsu0107%2Fsync-react-s3-cloudfront","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminghsu0107%2Fsync-react-s3-cloudfront","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminghsu0107%2Fsync-react-s3-cloudfront/lists"}