Skip to content

Instantly share code, notes, and snippets.

View davidvpe's full-sized avatar

David Velarde davidvpe

View GitHub Profile
resource "cloudflare_record" "records" {
zone_id = data.cloudflare_zone.zone.id
name = "example.com"
value = aws_cloudfront_distribution.s3_distribution.domain_name
type = "CNAME"
ttl = 1
allow_overwrite = true
}
locals {
s3_origin_id = "example.com_origin"
}
resource "aws_cloudfront_distribution" "s3_distribution" {
origin {
domain_name = aws_s3_bucket.website.bucket_regional_domain_name
origin_id = local.s3_origin_id
data "aws_iam_policy_document" "s3_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.website.arn}/*"]
principals {
type = "AWS"
identifiers = [aws_cloudfront_origin_access_identity.oai.iam_arn]
}
}
resource "aws_cloudfront_origin_access_identity" "oai" {
comment = "Cloudfront Origin Access Identity"
}
resource "aws_s3_bucket" "website" {
bucket = "example.com"
acl = "private"
force_destroy = true
lifecycle {
prevent_destroy = false
}
}
resource "aws_acm_certificate_validation" "validation" {
certificate_arn = aws_acm_certificate.certificate.arn
validation_record_fqdns = [for record in cloudflare_record.records : record.hostname]
}
@davidvpe
davidvpe / dns.tf
Last active February 5, 2022 17:42
AWS Medium 3
data "cloudflare_zone" "zone" {
name = "example.com"
}
resource "cloudflare_record" "records" {
for_each = {
for dvo in aws_acm_certificate.certificate.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
resource "aws_acm_certificate" "certificate" {
domain_name = "example.com"
validation_method = "DNS"
}
@davidvpe
davidvpe / main.tf
Last active February 5, 2022 17:34
Medium AWS 1
terraform {
backend "http" {
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.74.0"
}
cloudflare = {
@davidvpe
davidvpe / DutchProcessor.swift
Last active February 5, 2018 12:21
Dutch Language Processor that allows to separate syllables
//
// main.swift
// DutchGrammar
//
// Created by Velarde Robles, David on 05/02/2018.
// Copyright © 2018 Velarde Robles, David. All rights reserved.
//
import Foundation