forked from speedshop/speedshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
58 lines (50 loc) · 1.11 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
backend "s3" {
bucket = "speedshop-terraform"
key = "#{local.infra_name}-prod.tfstate"
region = "us-east-1"
}
}
locals {
infra_name = "www.speedshop.co"
region = "us-east-1"
}
provider "aws" {
region = local.region
}
provider "cloudflare" {}
data "aws_iam_policy_document" "bucket_policy" {
statement {
actions = ["s3:GetObject"]
sid = "AllowPublicRead"
resources = ["arn:aws:s3:::${local.infra_name}/*"]
principals {
type = "AWS"
identifiers = ["*"]
}
}
}
resource "aws_s3_bucket" "website" {
bucket = local.infra_name
acl = "public-read"
policy = data.aws_iam_policy_document.bucket_policy.json
force_destroy = true
website {
index_document = "index.html"
error_document = "error.html"
}
}
# Someday I will do a complete cloudflare import
resource "cloudflare_zone" "cdn" {
zone = "speedshop.co"
}