Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

Deploy to AWS Terraform and Gitlab

variable "bucket_name" {
  default = "website.example.com" // change this
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_s3_bucket" "bucket" {
  bucket = "${var.bucket_name}"
  acl    = "private"
  policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
      {
          "Sid": "AddPerm",
          "Effect": "Allow",
          "Principal": "*",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::${var.bucket_name}/*"
      }
  ]
}
EOF

  website {
    index_document = "index.html"
    error_document = "index.html"
  }
}

locals {
  s3_origin_id = "S3-${var.bucket_name}"
}

resource "aws_cloudfront_distribution" "s3_distribution" {
  origin {
    domain_name = "${aws_s3_bucket.bucket.bucket_regional_domain_name}"
    origin_id = "${local.s3_origin_id}"
  }

  wait_for_deployment = false

  enabled = true
  is_ipv6_enabled = true
  default_root_object = "index.html"

  default_cache_behavior {
    allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
    cached_methods = ["GET", "HEAD"]
    target_origin_id = "${local.s3_origin_id}"

    forwarded_values {
      query_string = false

      cookies {
        forward = "none"
      }
    }

    viewer_protocol_policy = "redirect-to-https"
    min_ttl = 0
    default_ttl = 3600
    max_ttl = 86400
  }


  price_class = "PriceClass_100"

  restrictions {
    geo_restriction {
      restriction_type = "none"
    }
  }

  custom_error_response {
    error_code = 403
    error_caching_min_ttl = 0
    response_code = 200
    response_page_path = "/index.html"
  }

  viewer_certificate {
    cloudfront_default_certificate = true
  }
}
Comment

PREVIOUS NEXT
Code Example
Shell :: swagger editor locally 
Shell :: bash copy folder 
Shell :: git show whole file at commit 
Shell :: install moment.js 
Shell :: linux kali download 
Shell :: run tar.xz ubuntu 
Shell :: sed mac install 
Shell :: git issues 
Shell :: develop - FETCH_HEAD instead of origin develop 
Shell :: Pulling a branch 
Shell :: how to unrar multiple files at once linux 
Shell :: git merge conflict resolve 
Shell :: scp command ubuntu 
Shell :: remove .idea from git 
Shell :: df command linux concepts 
Shell :: git clone without project folder 
Shell :: vagrant 
Shell :: ssh bad owner permissions 
Shell :: removing package using snap 
Shell :: git submodule update --init --recursive 
Shell :: powershell and command 
Shell :: do command in a command linux 
Shell :: why upgrade ubuntu then frequently shows this message "It iwating for cache lock: Could not get lock /var/lib/dpkg/lock.frontend. 
Shell :: packet tracer 2.7.1 Full Config P2P-3 Router 
Shell :: /usr/local/psa/var/modules/composer//composer.phar 
Shell :: bash print separator null character 
Shell :: sed wrap each line in quotes 
Shell :: bash temp file extension 
Shell :: close app with terminal 
Shell :: thinderbird download linux mint 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =