├── module ├── .DS_Store ├── cloudfront │ ├── variables.tf │ ├── outputs.tf │ └── main.tf ├── s3 │ ├── HNG-first │ │ ├── IMG20210204072904.jpg │ │ ├── script.js │ │ ├── index.html │ │ └── styles.css │ ├── outputs.tf │ ├── variables.tf │ └── main.tf ├── route53 │ ├── output.tf │ ├── variables.tf │ └── main.tf └── acm │ ├── output.tf │ ├── variables.tf │ └── main.tf ├── variables.tf └── main.tf /module/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/conrad-assignment/HEAD/module/.DS_Store -------------------------------------------------------------------------------- /module/cloudfront/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "The name of the S3 bucket." 3 | type = string 4 | } 5 | -------------------------------------------------------------------------------- /module/s3/HNG-first/IMG20210204072904.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonnero234/conrad-assignment/HEAD/module/s3/HNG-first/IMG20210204072904.jpg -------------------------------------------------------------------------------- /module/s3/HNG-first/script.js: -------------------------------------------------------------------------------- 1 | document.addEventListener('DOMContentLoaded', function() { 2 | console.log('Welcome to Noah Anthony Imanche\'s portfolio!'); 3 | 4 | }); 5 | -------------------------------------------------------------------------------- /module/route53/output.tf: -------------------------------------------------------------------------------- 1 | output "main_domain_zone_id" { 2 | description = "The Zone ID of the main domain in Route 53." 3 | value = aws_route53_zone.main_domain.zone_id 4 | } 5 | 6 | -------------------------------------------------------------------------------- /module/s3/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "The name of the S3 bucket." 3 | value = aws_s3_bucket.this.bucket 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "The ARN of the S3 bucket." 8 | value = aws_s3_bucket.this.arn 9 | } 10 | -------------------------------------------------------------------------------- /module/s3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "The name of the S3 bucket." 3 | type = string 4 | } 5 | 6 | variable "origin_access_identity_id" { 7 | description = "The ID of the CloudFront origin access identity." 8 | type = string 9 | } 10 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "aws_region" { 2 | description = "The AWS region to deploy the resources." 3 | type = string 4 | default = "us-west-2" 5 | } 6 | 7 | variable "bucket_name" { 8 | description = "The name of the S3 bucket." 9 | type = string 10 | default = "tony-altschool" 11 | } 12 | -------------------------------------------------------------------------------- /module/acm/output.tf: -------------------------------------------------------------------------------- 1 | output "certificate_arn" { 2 | description = "The ARN of the ACM certificate." 3 | value = aws_acm_certificate.this.arn 4 | } 5 | 6 | output "certificate_domain_name" { 7 | description = "The domain name associated with the ACM certificate." 8 | value = aws_acm_certificate.this.domain_name 9 | } 10 | -------------------------------------------------------------------------------- /module/route53/variables.tf: -------------------------------------------------------------------------------- 1 | variable "aws_region" { 2 | description = "us-east-1" 3 | type = string 4 | } 5 | 6 | variable "main_domain" { 7 | description = "tonynoah.me" 8 | type = string 9 | } 10 | 11 | 12 | 13 | variable "alias_target_domain_name" { 14 | description = "d26xp1i2yvoxpw.cloudfront.net" 15 | type = string 16 | } 17 | 18 | variable "alias_target_zone_id" { 19 | description = "Z0273290C20QSK62JJJ2" 20 | type = string 21 | } 22 | -------------------------------------------------------------------------------- /module/acm/variables.tf: -------------------------------------------------------------------------------- 1 | variable "domain_name" { 2 | description = "tonynoah.me" 3 | type = string 4 | } 5 | 6 | variable "validation_method" { 7 | description = "The method to use for validation. DNS or EMAIL." 8 | type = string 9 | default = "DNS" 10 | } 11 | 12 | variable "environment" { 13 | description = "The environment name for tagging purposes." 14 | type = string 15 | } 16 | 17 | variable "aws_region" { 18 | description = "us-east-1" 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /module/acm/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_acm_certificate" "this" { 2 | domain_name = var.domain_name 3 | validation_method = var.validation_method 4 | 5 | lifecycle { 6 | create_before_destroy = true 7 | } 8 | 9 | tags = { 10 | Environment = var.environment 11 | } 12 | } 13 | 14 | resource "aws_acm_certificate_validation" "this" { 15 | certificate_arn = aws_acm_certificate.this.arn 16 | validation_record_fqdns = [for option in aws_acm_certificate.this.domain_validation_options : option.resource_record_name] 17 | } 18 | -------------------------------------------------------------------------------- /module/route53/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_route53_zone" "main_domain" { 2 | name = var.main_domain 3 | } 4 | 5 | resource "aws_route53_record" "main_domain_record" { 6 | zone_id = "Z0273290C20QSK62JJJ2" # Replace with the correct hosted zone ID 7 | name = var.main_domain 8 | type = "A" 9 | 10 | alias { 11 | name = "d26xp1i2yvoxpw.cloudfront.net" 12 | zone_id = "Z0273290C20QSK62JJJ2" # Replace with the correct hosted zone ID 13 | evaluate_target_health = false 14 | } 15 | } -------------------------------------------------------------------------------- /module/cloudfront/outputs.tf: -------------------------------------------------------------------------------- 1 | output "distribution_id" { 2 | description = "The ID of the CloudFront distribution." 3 | value = aws_cloudfront_distribution.this.id 4 | } 5 | 6 | output "distribution_domain_name" { 7 | description = "The domain name of the CloudFront distribution." 8 | value = aws_cloudfront_distribution.this.domain_name 9 | } 10 | 11 | output "origin_access_identity_id" { 12 | description = "The ID of the CloudFront origin access identity." 13 | value = aws_cloudfront_origin_access_identity.this.id 14 | } 15 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.aws_region 3 | } 4 | 5 | module "s3_bucket" { 6 | source = "./module/s3" 7 | bucket_name = var.bucket_name 8 | origin_access_identity_id = module.cloudfront_distribution.origin_access_identity_id 9 | } 10 | 11 | module "cloudfront_distribution" { 12 | source = "./module/cloudfront" 13 | 14 | bucket_name = var.bucket_name 15 | } 16 | 17 | module "aws_route53" { 18 | source = "./module/route53" 19 | aws_region = "us-east-1" 20 | main_domain = "tonynoah.me" 21 | alias_target_domain_name = module.cloudfront_distribution.distribution_domain_name 22 | alias_target_zone_id = module.cloudfront_distribution.distribution_id 23 | 24 | } 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /module/s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "this" { 2 | bucket = var.bucket_name 3 | 4 | 5 | 6 | tags = { 7 | Name = var.bucket_name 8 | Environment = "Production" 9 | } 10 | } 11 | 12 | resource "aws_s3_bucket_policy" "this" { 13 | bucket = aws_s3_bucket.this.id 14 | 15 | policy = jsonencode({ 16 | Version = "2012-10-17" 17 | Statement = [ 18 | { 19 | Effect = "Allow" 20 | Principal = { 21 | AWS = "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${var.origin_access_identity_id}" 22 | } 23 | Action = "s3:GetObject" 24 | Resource = "arn:aws:s3:::${aws_s3_bucket.this.id}/*" 25 | } 26 | ] 27 | }) 28 | } 29 | 30 | resource "aws_s3_bucket_public_access_block" "this" { 31 | bucket = aws_s3_bucket.this.id 32 | 33 | block_public_acls = true 34 | block_public_policy = true 35 | ignore_public_acls = true 36 | restrict_public_buckets = true 37 | } 38 | 39 | 40 | resource "aws_s3_object" "files_upload" { 41 | for_each = fileset("module/s3/HNG-first/", "**/*.*") 42 | bucket = var.bucket_name 43 | key = each.value 44 | source = "module/s3/HNG-first/${each.value}" 45 | content_type = "text/html" 46 | } 47 | 48 | -------------------------------------------------------------------------------- /module/cloudfront/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_cloudfront_origin_access_identity" "this" { 2 | comment = "Access to S3 bucket ${var.bucket_name}" 3 | } 4 | 5 | resource "aws_cloudfront_distribution" "this" { 6 | origin { 7 | domain_name = "${var.bucket_name}.s3.amazonaws.com" 8 | origin_id = "S3-${var.bucket_name}" 9 | 10 | s3_origin_config { 11 | origin_access_identity = aws_cloudfront_origin_access_identity.this.cloudfront_access_identity_path 12 | } 13 | } 14 | 15 | enabled = true 16 | is_ipv6_enabled = true 17 | comment = "CloudFront distribution for ${var.bucket_name}" 18 | default_root_object = "index.html" 19 | 20 | default_cache_behavior { 21 | allowed_methods = ["GET", "HEAD"] 22 | cached_methods = ["GET", "HEAD"] 23 | target_origin_id = "S3-${var.bucket_name}" 24 | 25 | forwarded_values { 26 | query_string = false 27 | cookies { 28 | forward = "none" 29 | } 30 | } 31 | 32 | viewer_protocol_policy = "redirect-to-https" 33 | 34 | min_ttl = 0 35 | default_ttl = 3600 36 | max_ttl = 86400 37 | } 38 | 39 | restrictions { 40 | geo_restriction { 41 | restriction_type = "none" 42 | } 43 | } 44 | 45 | viewer_certificate { 46 | cloudfront_default_certificate = true 47 | } 48 | 49 | tags = { 50 | Name = "cloudfront-${var.bucket_name}" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /module/s3/HNG-first/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Noah Anthony Imanche - Cloud Engineering Trainee 7 | 8 | 9 | 10 |
11 |

Noah Anthony Imanche

12 |

Cloud Engineering Trainee at HNG

13 |
14 | 15 |
16 |

About Me

17 | Noah Anthony Imanche 18 |

Hello! my name is Noah Anthony Imanche, I am passionate about cloud engineering and constantly upskilling my tech skills. I am currently an intern with HNG

19 |
20 | 21 |
22 |

Skills

23 | 32 |
33 | 34 | 35 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /module/s3/HNG-first/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | margin: 0; 4 | padding: 0; 5 | background-color: #f4f4f4; 6 | } 7 | 8 | header { 9 | background-color: #006400; /* Dark green */ 10 | color: white; 11 | padding: 1em 0; 12 | text-align: center; 13 | } 14 | 15 | header h1 { 16 | margin: 0; 17 | font-size: 2.5em; 18 | } 19 | 20 | header p { 21 | margin: 0; 22 | font-size: 1.2em; 23 | } 24 | 25 | section { 26 | margin: 2em 1em; 27 | padding: 1em; 28 | background-color: white; 29 | border-left: 5px solid #008000; /* Green border */ 30 | border-radius: 5px; 31 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 32 | } 33 | 34 | h2 { 35 | border-bottom: 2px solid #006400; /* Dark green */ 36 | padding-bottom: 0.5em; 37 | } 38 | 39 | ul { 40 | list-style-type: none; 41 | padding: 0; 42 | } 43 | 44 | ul li { 45 | background-color: #e2e2e2; 46 | margin: 0.5em 0; 47 | padding: 0.5em; 48 | border-radius: 5px; 49 | } 50 | 51 | 52 | 53 | footer { 54 | text-align: center; 55 | padding: 1em 0; 56 | background-color: #006400; /* Dark green */ 57 | color: white; 58 | position: fixed; 59 | width: 100%; 60 | bottom: 0; 61 | } 62 | 63 | footer ul { 64 | list-style-type: none; 65 | padding: 0; 66 | margin: 0; 67 | display: flex; 68 | justify-content: center; 69 | } 70 | 71 | footer ul li { 72 | margin: 0 10px; 73 | } 74 | 75 | footer ul li a { 76 | color: white; 77 | text-decoration: none; 78 | font-weight: bold; 79 | } 80 | 81 | footer ul li a:hover { 82 | text-decoration: underline; 83 | } 84 | 85 | .profile-pic { 86 | display: block; 87 | margin: 0 auto 20px; 88 | width: 150px; 89 | height: 150px; 90 | border-radius: 50%; 91 | object-fit: cover; 92 | border: 3px solid #008000; /* Green border */ 93 | } 94 | 95 | 96 | #portfolio-button { 97 | display: block; 98 | margin: 20px auto; 99 | padding: 10px 20px; 100 | background-color: #006400; /* Dark green */ 101 | color: white; 102 | border: none; 103 | border-radius: 5px; 104 | font-size: 1em; 105 | cursor: pointer; 106 | transition: background-color 0.3s; 107 | } 108 | 109 | #portfolio-button:hover { 110 | background-color: #008000; /* Green */ 111 | } --------------------------------------------------------------------------------