summaryrefslogtreecommitdiff
path: root/bliki.tf
blob: b4d7bd5dd32865e51a22908f0d549271a7e7b2bd (plain)
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
terraform {
  backend "s3" {
    bucket = "terraform.grimoire"
    key    = "bliki.tfstate"
    region = "ca-central-1"
  }
}

provider "aws" {
  region = "ca-central-1"
}

# CloudFront needs certificates in us-east-1.
provider "aws" {
  alias  = "cloudfront"
  region = "us-east-1"
}

resource "aws_s3_bucket" "bliki" {
  bucket = "grimoire.ca"

  tags = {
    Project = "bliki"
  }
}

resource "aws_s3_bucket_website_configuration" "bliki" {
  bucket = aws_s3_bucket.bliki.id

  index_document {
    suffix = "index.html"
  }
}

resource "aws_s3_bucket_policy" "bliki" {
  bucket = aws_s3_bucket.bliki.id
  policy = <<POLICY
{
  "Version":"2012-10-17",
  "Statement":[
    {
      "Effect":"Allow",
      "Principal": "*",
      "Action": ["s3:GetObject"],
      "Resource": ["${aws_s3_bucket.bliki.arn}/*"]
    }
  ]
}
POLICY

}

data "aws_route53_zone" "grimoire_ca" {
  name = "grimoire.ca"
}