{"id":22389675,"url":"https://github.com/rflcnunes/cdn_with_cloudfront_iac_template","last_synced_at":"2026-04-12T05:33:28.239Z","repository":{"id":248330067,"uuid":"828063705","full_name":"rflcnunes/cdn_with_cloudfront_iac_template","owner":"rflcnunes","description":"This Terraform project configures AWS resources for a CDN application and a Lambda function that checks the client's final IP, with an educational focus on Infrastructure as Code (IaC), including reusable modules and integration with CloudWatch.","archived":false,"fork":false,"pushed_at":"2024-07-14T01:55:30.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T11:07:28.541Z","etag":null,"topics":["api-gateway","aws","bucket","cdn","cdnjs","cloudfront","cloudfront-distribution","golang","iac","ip-verification","javascript","js","lambda","makefile","s3","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","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/rflcnunes.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":"2024-07-13T02:57:26.000Z","updated_at":"2024-07-14T04:45:17.000Z","dependencies_parsed_at":"2024-07-14T04:32:39.441Z","dependency_job_id":"15499368-e9b8-4107-a0e4-759a80dc3bac","html_url":"https://github.com/rflcnunes/cdn_with_cloudfront_iac_template","commit_stats":null,"previous_names":["rflcnunes/cdn_with_cloudfront_iac_template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rflcnunes/cdn_with_cloudfront_iac_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rflcnunes%2Fcdn_with_cloudfront_iac_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rflcnunes%2Fcdn_with_cloudfront_iac_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rflcnunes%2Fcdn_with_cloudfront_iac_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rflcnunes%2Fcdn_with_cloudfront_iac_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rflcnunes","download_url":"https://codeload.github.com/rflcnunes/cdn_with_cloudfront_iac_template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rflcnunes%2Fcdn_with_cloudfront_iac_template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31705574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T05:11:36.334Z","status":"ssl_error","status_checked_at":"2026-04-12T05:11:27.332Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api-gateway","aws","bucket","cdn","cdnjs","cloudfront","cloudfront-distribution","golang","iac","ip-verification","javascript","js","lambda","makefile","s3","terraform"],"created_at":"2024-12-05T03:12:38.372Z","updated_at":"2026-04-12T05:33:28.223Z","avatar_url":"https://github.com/rflcnunes.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform Project for AWS Infrastructure template\n\nThis project uses Terraform to configure various resources on AWS, creating a template for a CDN application and a\nLambda function that checks the client's final IP. The main goal of this project is educational. I developed this\ntemplate to study the technologies used in the project and also to create something practical: a template for CDN and\nLambda using Infrastructure as Code (IaC).\n\n## Covered Topics\n\n* Organization of the code into reusable modules for various infrastructure components.\n* Implementation of Hexagonal Architecture.\n* Definition of access policies.\n* Integration of CloudWatch Logs with the Lambda function.\n* Configuration of the API Gateway to expose the Lambda function as an HTTP endpoint.\n* Setup of a CloudFront distribution to distribute content from the S3 bucket.\n* Use of variables to make the configuration flexible and reusable.\n* Definition of outputs to facilitate the retrieval of important information from the created resources.\n* Use of depends_on to ensure the correct order of resource creation.\n* Automation of infrastructure build with a Makefile.\n* Creation of a Lambda function using API Gateway events to check the client's final IP with Golang.\n* Creation of an S3 Bucket to store static content and function as a CDN.\n* Implementation of a CloudFront distribution to distribute content from the S3 Bucket.\n\n### 1. Architecture resources\n\n- **Hexagonal Architecture**: Organization of the CDN code.\n\n### 2. AWS resources\n\n- **S3**: Implementation of an S3 bucket with restricted access policies.\n- **IAM**: Definition of IAM roles and policies to ensure the secure operation of AWS resources.\n- **Lambda**: Creation of a Lambda function, configured for logging in CloudWatch.\n- **API Gateway**: Establishment of an API Gateway to make the Lambda function available as an HTTP endpoint.\n- **CloudFront**: Configuration of a CloudFront distribution for the delivery of content from the S3 bucket, with\n  restrictions on direct access.\n\n### 3. Resources Used for Application Construction\n\n- **Golang**: Used to create the Lambda function that checks the client's final IP.\n- **JavaScript**: Used to create the CDN application.\n- **Webpack**: Used to bundle the CDN application.\n- **Terraform**: Used to configure the infrastructure on AWS.\n- **Makefile**: Used to automate the infrastructure build.\n\n## Project Structure\n\n```plaintext\n  terraform/\n  ├── main.tf                     # Main configuration of Terraform\n  ├── variables.tf                # Variable declaration, information used in the code\n  ├── outputs.tf                  # Outputs declaration, output information\n  ├── providers.tf                # AWS provider configuration, region, and version\n  ├── Makefile                    # File to automate the infrastructure build\n  ├── artifacts/                  # Source code files and build-generated binaries used in the infrastructure\n  │   ├── cdn/ \n  │   │   ├── dist/               # Built files of the CDN\n  │   │   │   ├── index.min.js    # Minified JavaScript file used by the S3 Bucket\n  │   ├── lambdas/                # Folder to centralize the zips of Lambda functions\n  │   │   ├── ip_finder.zip/      # ZIP file of the Go Lambda function to check the final IP of the client\n  ├── app/\n  │   ├── cdn/                    # CDN to serve static content\n  │   │   ├── src/                # Static content files, focused on Hexagonal Architecture\n  │   │   │   ├── adapters/\n  │   │   │   ├── application/\n  │   │   │   ├── domain/\n  │   │   │   ├── infrastructure/\n  │   │   ├── main.js             # Main file of the application\n  │   ├── IPFinder/               # Lambda function to check the final IP of the client\n  │   │   ├── main.go             # Code of the Lambda function in Go\n  ├── modules/                    # Reusable modules for different infrastructure components\n  │   ├── s3/\n  │   │   ├── main.tf             # S3 bucket configuration\n  │   │   ├── variables.tf\n  │   │   ├── outputs.tf\n  │   │   └── policy.tf           # Access policy to the bucket\n  │   ├── iam/\n  │   │   ├── main.tf             # Configuration of IAM roles and policies\n  │   │   ├── variables.tf\n  │   │   └── outputs.tf\n  │   ├── lambda/                 # Lambda function to check the final IP of the client\n  │   │   ├── main.tf\n  │   │   ├── variables.tf\n  │   │   ├── outputs.tf\n  │   │   └── cloudwatch.tf       # Configuration of log groups in CloudWatch\n  │   ├── api_gateway/            # API Gateway to expose the Lambda function as an HTTP endpoint\n  │   │   ├── main.tf\n  │   │   ├── variables.tf\n  │   │   ├── outputs.tf\n  │   ├── cloudfront/             # CloudFront distribution to serve content from the S3 bucket\n  │   │   ├── main.tf\n  │   │   ├── variables.tf\n  │   │   └── outputs.tf\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frflcnunes%2Fcdn_with_cloudfront_iac_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frflcnunes%2Fcdn_with_cloudfront_iac_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frflcnunes%2Fcdn_with_cloudfront_iac_template/lists"}