diff --git a/.gitignore b/.gitignore
index 521b971..3e1ab97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ blog/node_modules
# static
blog/static
+!blog/static/images/*
test/
.DS_Store
diff --git a/blog/config.toml b/blog/config.toml
index 382010d..3f5a784 100644
--- a/blog/config.toml
+++ b/blog/config.toml
@@ -1,4 +1,5 @@
-baseURL = "http://127.0.0.1:6060"
+baseURL = "https://panaetius.io/"
+# relativeURLs = true
title = "panaetius.io"
# theme = "panaetius-chunky-theme"
theme = ["hugo-notice-admonition", "panaetius-theme"]
@@ -83,5 +84,6 @@ page = ["HTML", "RSS"]
[markup]
[markup.highlight]
-style = "monokailight"
+# style = "monokailight"
+style = "paraiso-dark"
lineNos = true
diff --git a/blog/content/post/second_post copy 2/index.md b/blog/content/post/second_post copy 2/index.md
index 78a8bae..74fabab 100644
--- a/blog/content/post/second_post copy 2/index.md
+++ b/blog/content/post/second_post copy 2/index.md
@@ -1,5 +1,5 @@
---
-title: "Really long title Second Post Copy for layout scaling with flexbox using css 2."
+title: "Really long title Second Post Copy for layout scaling with flexbox using css 2"
date: "2020-05-05T02:14:50+01:00"
images: ["images/banner.svg"]
draft: true
diff --git a/blog/content/post/second_post copy/index.md b/blog/content/post/second_post copy/index.md
index 846ff1c..698de72 100644
--- a/blog/content/post/second_post copy/index.md
+++ b/blog/content/post/second_post copy/index.md
@@ -1,5 +1,5 @@
---
-title: "Really long title Second Post Copy for layout scaling with flexbox using css."
+title: "Really long title Second Post Copy for layout scaling with flexbox using css"
date: "2020-05-06T02:14:51+01:00"
images:
- "images/banner.svg"
diff --git a/blog/content/post/second_post/index.md b/blog/content/post/second_post/index.md
index a8bd260..28207d4 100644
--- a/blog/content/post/second_post/index.md
+++ b/blog/content/post/second_post/index.md
@@ -6,7 +6,6 @@ images:
draft: true
authors:
- "Daniel Tomlinson"
- - "New Authors"
tags:
- "Introduction"
- "test"
diff --git a/blog/package.json b/blog/package.json
index a77ea87..21f0f87 100644
--- a/blog/package.json
+++ b/blog/package.json
@@ -14,14 +14,7 @@
"webpack": "^4.43.0"
},
"scripts": {
- "buildSearch": "gulp buildSearch",
- "buildHugo": "gulp buildHugo",
"buildBlog": "gulp buildBlog",
- "buildTheme": "gulp buildTheme",
- "buildLunr": "gulp buildLunr",
- "cleanJS": "gulp cleanJS",
- "insertJS": "gulp insertJS",
- "minifyJS": "gulp minifyJS",
- "minifyImages": "gulp minifyImages"
+ "buildLunr": "gulp buildLunr"
}
}
diff --git a/blog/static/images/front-images/world.svg b/blog/static/images/front-images/world.svg
new file mode 100644
index 0000000..822f455
--- /dev/null
+++ b/blog/static/images/front-images/world.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blog/static/images/icons/Extraterrestrials.svg b/blog/static/images/icons/Extraterrestrials.svg
new file mode 100644
index 0000000..ec1fbe9
--- /dev/null
+++ b/blog/static/images/icons/Extraterrestrials.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blog/static/images/icons/Gods.png b/blog/static/images/icons/Gods.png
new file mode 100644
index 0000000..be95c69
--- /dev/null
+++ b/blog/static/images/icons/Gods.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a9133885cabc71992e566fba8a0c29a3be3671e3866d29a25d41a2265ab6321c
+size 5955
diff --git a/blog/static/images/icons/Kraken.png b/blog/static/images/icons/Kraken.png
new file mode 100644
index 0000000..c3ce784
--- /dev/null
+++ b/blog/static/images/icons/Kraken.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:eb2ebede545f670d24f42093c7e279677d787fe0da6f4d0f92447cd96eb13f5f
+size 11800
diff --git a/blog/static/images/icons/Wizard.png b/blog/static/images/icons/Wizard.png
new file mode 100644
index 0000000..6961f1a
--- /dev/null
+++ b/blog/static/images/icons/Wizard.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d3cb3693db4ae5860bbb858d87130dd3c6437d75513e47fd4687dea3f44fd039
+size 9941
diff --git a/blog/static/images/icons/info-icon-notice.png b/blog/static/images/icons/info-icon-notice.png
new file mode 100644
index 0000000..aaa08bf
--- /dev/null
+++ b/blog/static/images/icons/info-icon-notice.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ddad3778f8056e86cc8f2943d4901213479d1466813bd35cfdc67f1863015b24
+size 5289
diff --git a/blog/static/images/icons/note-icon-notice.png b/blog/static/images/icons/note-icon-notice.png
new file mode 100644
index 0000000..0758900
--- /dev/null
+++ b/blog/static/images/icons/note-icon-notice.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:dce0d1b29b2d5af6b969f95bef14d47c9c8ad4e18a0b4f9b3dc2319c68dce9d6
+size 3290
diff --git a/blog/static/images/icons/pillar.png b/blog/static/images/icons/pillar.png
new file mode 100644
index 0000000..cda196d
--- /dev/null
+++ b/blog/static/images/icons/pillar.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:976ca07a255e4daf537eade91362a54a917356338647ed923354d9fefa4e37b8
+size 383
diff --git a/blog/static/images/icons/series-icon-notice-old.png b/blog/static/images/icons/series-icon-notice-old.png
new file mode 100644
index 0000000..0e2f6cd
--- /dev/null
+++ b/blog/static/images/icons/series-icon-notice-old.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2bf5ed5d1e9b56c4aad183350caeed421a4b6abc27940d198fdf89781f9c72bf
+size 14397
diff --git a/blog/static/images/icons/series-icon-notice.png b/blog/static/images/icons/series-icon-notice.png
new file mode 100644
index 0000000..b0a7305
--- /dev/null
+++ b/blog/static/images/icons/series-icon-notice.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0d25a4bc69642278bcc2f716dff6397f339e3c8cd62956d66760f49439d1172d
+size 8081
diff --git a/blog/static/images/icons/series-scarecrow.png b/blog/static/images/icons/series-scarecrow.png
new file mode 100644
index 0000000..161329f
--- /dev/null
+++ b/blog/static/images/icons/series-scarecrow.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:46b1dcc910219b41d0ca64058b62e00587851db5f88d7e577be7521ec699e4b1
+size 5581
diff --git a/blog/static/images/icons/tip-icon-notice.png b/blog/static/images/icons/tip-icon-notice.png
new file mode 100644
index 0000000..3642180
--- /dev/null
+++ b/blog/static/images/icons/tip-icon-notice.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1b166ebc9322129c0d10a7555a7014a7e7124604c32e69dbd6eb2d5d07a5de99
+size 3463
diff --git a/blog/static/images/icons/warning-icon-notice.png b/blog/static/images/icons/warning-icon-notice.png
new file mode 100644
index 0000000..a6f1ce2
--- /dev/null
+++ b/blog/static/images/icons/warning-icon-notice.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:83d2a04cec7f942033cb7d08e88ae7b06d9b79891397956d717b93c45cb04429
+size 5793
diff --git a/blog/themes/hugo-notice-admonition b/blog/themes/hugo-notice-admonition
index f08dd40..1e35d5c 160000
--- a/blog/themes/hugo-notice-admonition
+++ b/blog/themes/hugo-notice-admonition
@@ -1 +1 @@
-Subproject commit f08dd406cc63f912032bdf914e893acc751324ed
+Subproject commit 1e35d5ca2da42b56de2c6112bfd84d3845c24e52
diff --git a/blog/themes/panaetius-theme b/blog/themes/panaetius-theme
index 412ab93..524a2be 160000
--- a/blog/themes/panaetius-theme
+++ b/blog/themes/panaetius-theme
@@ -1 +1 @@
-Subproject commit 412ab931c34399a3902f3c3cb7861f31988db368
+Subproject commit 524a2be0120e9fdd828c5827e3ac5f4aa7c50792
diff --git a/blog/webpack-filestructure.md b/blog/webpack-filestructure.md
index 8f01033..4b73340 100644
--- a/blog/webpack-filestructure.md
+++ b/blog/webpack-filestructure.md
@@ -1,6 +1,6 @@
# Webpack
-TODO: This note should also go under a note for structuring a website.s
+TODO: This note should also go under a note for structuring a website.
Great tutorial for the basics: .
diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js
new file mode 100644
index 0000000..6c9f2bf
--- /dev/null
+++ b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js
@@ -0,0 +1,29 @@
+"use strict";
+
+exports.handler = (event, context, callback) => {
+ // Extract the request from the Cloudfront event that is sent to Lambda@Edge
+ var request = event.Records[0].cf.request;
+
+ // Extract the URI from the request
+ var oldURI = request.uri;
+
+ // Match any '/' that occurs at the end of a URI. Replace it with a default index
+ function replace_uri(uri) {
+ uri = uri.replace(/\/$/, "/index.html");
+ // uri = uri.replace(/\.io\/search\?q\=(.*)/, ".io/search/index.html?q=$1");
+ // console.log(uri)
+ return uri;
+ }
+ // var newURI = oldURI.replace(/\/$/, "/index.html");
+ var newURI = replace_uri(oldURI);
+
+ // Log the URI as received by Cloudfront and the new URI to be used to fetch from the origin
+ console.log(`Old URI: ${oldURI}`);
+ console.log(`New URI: ${newURI}`);
+
+ // Replace the received URI with the URI that includes the index page
+ request.uri = newURI;
+
+ // Return to Cloudfront
+ return callback(null, request);
+};
diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip
new file mode 100644
index 0000000..bfff512
Binary files /dev/null and b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip differ
diff --git a/infrastructure/main.tf b/infrastructure/main.tf
index c22396d..8ccdb20 100644
--- a/infrastructure/main.tf
+++ b/infrastructure/main.tf
@@ -1,9 +1,17 @@
+# aws config
provider "aws" {
region = var.region
profile = var.profile
version = "~> 2.66"
}
+provider "aws" {
+ alias = "us_east_1"
+ profile = var.profile
+ region = "us-east-1"
+}
+
+# tags
locals {
tags = {
"Project" = "panaetius-blog"
@@ -11,21 +19,31 @@ locals {
}
}
+# cloudfront
module "cloudfront_s3_cdn" {
- source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn.git?ref=tags/0.23.1"
- stage = var.stage
- name = var.name
- parent_zone_id = var.parent_zone_id
- acm_certificate_arn = var.acm_certificate_arn
- # log_expiration_days = var.log_expiration_days
- # log_standard_transition_days = var.log_standard_transition_days
+ source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn.git?ref=tags/0.23.1"
+ stage = var.stage
+ name = var.name
+ parent_zone_id = var.parent_zone_id
+ acm_certificate_arn = var.acm_certificate_arn
use_regional_s3_endpoint = true
origin_force_destroy = true
+ compress = true
cors_allowed_headers = ["*"]
cors_allowed_methods = ["GET", "HEAD", "PUT", "POST"]
cors_allowed_origins = var.allowed_origins
tags = local.tags
aliases = var.aliases
+ index_document = "index.html"
+ lambda_function_association = [
+ {
+ event_type : "origin-request",
+ lambda_arn : aws_lambda_function.directory_indexes.qualified_arn,
+ include_body : false
+ }
+ ]
+
+ # this policy sets the bucket to be public for all newly created files
additional_bucket_policy = <<-EOT
{
"Version": "2012-10-17",
@@ -33,20 +51,101 @@ module "cloudfront_s3_cdn" {
{
"Sid":"PublicRead",
"Effect":"Allow",
- "Principal": "*",
+ "Principal":"*",
"Action":["s3:GetObject"],
- "Resource": "arn:aws:s3:::${var.bucket_name}/*"
+ "Resource":"arn:aws:s3:::${module.cloudfront_s3_cdn.s3_bucket}/*"
}
]
}
EOT
}
-resource "aws_s3_bucket_object" "index" {
- bucket = module.cloudfront_s3_cdn.s3_bucket
- key = "index.html"
- acl = "public-read"
- source = "${path.module}/test/index.html"
- content_type = "text/html"
- etag = md5(file("${path.module}/test/index.html"))
+# # cloudfront lambda@edge
+
+# resource "aws_s3_bucket" "lambda_s3" {
+# provider = aws.us_east_1
+# region = var.s3_region
+# bucket = "${var.stage}-${var.name}-lambda-function"
+# acl = var.acl
+# tags = local.tags
+# }
+
+data "archive_file" "lambda_main" {
+ type = "zip"
+ source_file = var.source_file
+ output_path = "${var.source_file}.zip"
+}
+
+# resource "aws_s3_bucket_object" "main" {
+# provider = aws.us_east_1
+# bucket = aws_s3_bucket.lambda_s3.id
+# key = var.lambda_key
+# acl = var.acl
+# source = var.source_file
+# }
+
+resource "aws_lambda_function" "directory_indexes" {
+ provider = aws.us_east_1
+ function_name = "${var.stage}-${var.name}-directory_indexes"
+ filename = "${var.source_file}.zip"
+ source_code_hash = data.archive_file.lambda_main.output_base64sha256
+ # s3_bucket = aws_s3_bucket.lambda_s3.id
+ # s3_key = var.lambda_key
+ handler = var.handler
+ runtime = var.runtime
+ role = aws_iam_role.lambda_role.arn
+ publish = true
+ tags = local.tags
+
+ depends_on = [aws_iam_role_policy_attachment.lambda_logging]
+}
+
+## Lambda iam role & policies
+
+resource "aws_iam_role" "lambda_role" {
+ name = "${var.stage}-${var.name}-lambda"
+ tags = local.tags
+
+ assume_role_policy = <<-EOT
+ {
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Principal": {
+ "Service": [
+ "lambda.amazonaws.com",
+ "edgelambda.amazonaws.com"
+ ]
+ },
+ "Action": "sts:AssumeRole"
+ }
+ ]
+ }
+ EOT
+}
+
+resource "aws_iam_policy" "lambda_logging" {
+ name = "${var.stage}-${var.name}-lambda_logging"
+ policy = <<-EOT
+ {
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Action": [
+ "logs:CreateLogGroup",
+ "logs:CreateLogStream",
+ "logs:PutLogEvents"
+ ],
+ "Resource": "arn:aws:logs:*:*:*",
+ "Effect": "Allow"
+ }
+ ]
+ }
+ EOT
+}
+
+resource "aws_iam_role_policy_attachment" "lambda_logging" {
+ role = aws_iam_role.lambda_role.name
+ policy_arn = aws_iam_policy.lambda_logging.arn
}
diff --git a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate
index 312ecd7..4e242b5 100644
--- a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate
+++ b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate
@@ -1,7 +1,7 @@
{
"version": 4,
"terraform_version": "0.12.26",
- "serial": 90,
+ "serial": 281,
"lineage": "cda52006-90fc-4aec-a630-42e69057b365",
"outputs": {
"cf_arn": {
@@ -13,7 +13,7 @@
"type": "string"
},
"cf_etag": {
- "value": "E2SEL7AYXF1CKS",
+ "value": "E2UYU85RHS3J18",
"type": "string"
},
"cf_hosted_zone_id": {
@@ -38,6 +38,32 @@
}
},
"resources": [
+ {
+ "mode": "data",
+ "type": "archive_file",
+ "name": "lambda_main",
+ "provider": "provider.archive",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "excludes": null,
+ "id": "320d4868dd37d1674e98bd790b8a54b006838d04",
+ "output_base64sha256": "5EVmwQDkgGfYMpMXNaWHUz3cmb/dSssoWl8mM8o3aMs=",
+ "output_md5": "611fc9e8b494e4b399217f632b8e35ed",
+ "output_path": "./lambda/prod-panaetius-blog-lambda/main.js.zip",
+ "output_sha": "320d4868dd37d1674e98bd790b8a54b006838d04",
+ "output_size": 601,
+ "source": [],
+ "source_content": null,
+ "source_content_filename": null,
+ "source_dir": null,
+ "source_file": "./lambda/prod-panaetius-blog-lambda/main.js",
+ "type": "zip"
+ }
+ }
+ ]
+ },
{
"module": "module.cloudfront_s3_cdn",
"mode": "data",
@@ -50,7 +76,7 @@
"attributes": {
"id": "3493490045",
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}",
- "override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\": \"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n }\n ]\n}\n",
+ "override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\":\"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n }\n ]\n}\n",
"policy_id": null,
"source_json": null,
"statement": [
@@ -116,7 +142,7 @@
"attributes": {
"id": "736817168",
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"*\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}",
- "override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\": \"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n }\n ]\n}\n",
+ "override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\":\"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n }\n ]\n}\n",
"policy_id": null,
"source_json": null,
"statement": [
@@ -283,7 +309,7 @@
"GET",
"HEAD"
],
- "compress": false,
+ "compress": true,
"default_ttl": 60,
"field_level_encryption_id": "",
"forwarded_values": [
@@ -303,7 +329,13 @@
"query_string_cache_keys": []
}
],
- "lambda_function_association": [],
+ "lambda_function_association": [
+ {
+ "event_type": "origin-request",
+ "include_body": false,
+ "lambda_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:7"
+ }
+ ],
"max_ttl": 31536000,
"min_ttl": 0,
"smooth_streaming": false,
@@ -315,13 +347,13 @@
"default_root_object": "index.html",
"domain_name": "d244ranky0ff54.cloudfront.net",
"enabled": true,
- "etag": "E2SEL7AYXF1CKS",
+ "etag": "E2UYU85RHS3J18",
"hosted_zone_id": "Z2FDTNDATAQYW2",
"http_version": "http2",
"id": "E2IHXIMPI3MZ2X",
"in_progress_validation_batches": 0,
"is_ipv6_enabled": true,
- "last_modified_time": "2020-07-15 00:18:34.684 +0000 UTC",
+ "last_modified_time": "2020-07-21 21:34:03.839 +0000 UTC",
"logging_config": [
{
"bucket": "prod-panaetius-blog-logs.s3.amazonaws.com",
@@ -378,6 +410,9 @@
},
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
"dependencies": [
+ "aws_iam_role.lambda_role",
+ "aws_iam_role_policy_attachment.lambda_logging",
+ "aws_lambda_function.directory_indexes",
"module.cloudfront_s3_cdn.aws_cloudfront_origin_access_identity.default",
"module.cloudfront_s3_cdn.aws_s3_bucket.origin",
"module.cloudfront_s3_cdn.module.logs.aws_s3_bucket.default"
@@ -398,7 +433,7 @@
"caller_reference": "terraform-20200713232645930800000001",
"cloudfront_access_identity_path": "origin-access-identity/cloudfront/E21A7YWJ1RT3K5",
"comment": "prod-panaetius-blog",
- "etag": "EESE0U5KF261",
+ "etag": "E38E5DTUJGROV",
"iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5",
"id": "E21A7YWJ1RT3K5",
"s3_canonical_user_id": "2d7779400635ec843efe9b677769fc4f82b0d384408cf22382bf3a90540502e09e75d1346e7105b4da159515b229f39b"
@@ -407,6 +442,133 @@
}
]
},
+ {
+ "mode": "managed",
+ "type": "aws_iam_policy",
+ "name": "lambda_logging",
+ "provider": "provider.aws",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "arn": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging",
+ "description": "",
+ "id": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging",
+ "name": "prod-panaetius-blog-lambda_logging",
+ "name_prefix": null,
+ "path": "/",
+ "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\",\n \"Effect\": \"Allow\"\n }\n ]\n}\n"
+ },
+ "private": "bnVsbA=="
+ }
+ ]
+ },
+ {
+ "mode": "managed",
+ "type": "aws_iam_role",
+ "name": "lambda_role",
+ "provider": "provider.aws",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "arn": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda",
+ "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"lambda.amazonaws.com\",\"edgelambda.amazonaws.com\"]},\"Action\":\"sts:AssumeRole\"}]}",
+ "create_date": "2020-07-21T20:01:43Z",
+ "description": "",
+ "force_detach_policies": false,
+ "id": "prod-panaetius-blog-lambda",
+ "max_session_duration": 3600,
+ "name": "prod-panaetius-blog-lambda",
+ "name_prefix": null,
+ "path": "/",
+ "permissions_boundary": null,
+ "tags": {
+ "Description": "terraform resources to host the blog",
+ "Project": "panaetius-blog"
+ },
+ "unique_id": "AROA23D4RF6O2VEGAGEXM"
+ },
+ "private": "bnVsbA=="
+ }
+ ]
+ },
+ {
+ "mode": "managed",
+ "type": "aws_iam_role_policy_attachment",
+ "name": "lambda_logging",
+ "provider": "provider.aws",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "id": "prod-panaetius-blog-lambda-20200721200145100500000001",
+ "policy_arn": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging",
+ "role": "prod-panaetius-blog-lambda"
+ },
+ "private": "bnVsbA==",
+ "dependencies": [
+ "aws_iam_policy.lambda_logging",
+ "aws_iam_role.lambda_role"
+ ]
+ }
+ ]
+ },
+ {
+ "mode": "managed",
+ "type": "aws_lambda_function",
+ "name": "directory_indexes",
+ "provider": "provider.aws.us_east_1",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes",
+ "dead_letter_config": [],
+ "description": "",
+ "environment": [],
+ "file_system_config": [],
+ "filename": "./lambda/prod-panaetius-blog-lambda/main.js.zip",
+ "function_name": "prod-panaetius-blog-directory_indexes",
+ "handler": "main.handler",
+ "id": "prod-panaetius-blog-directory_indexes",
+ "invoke_arn": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes/invocations",
+ "kms_key_arn": "",
+ "last_modified": "2020-07-21T21:34:00.971+0000",
+ "layers": [],
+ "memory_size": 128,
+ "publish": true,
+ "qualified_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:7",
+ "reserved_concurrent_executions": -1,
+ "role": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda",
+ "runtime": "nodejs12.x",
+ "s3_bucket": null,
+ "s3_key": null,
+ "s3_object_version": null,
+ "source_code_hash": "5EVmwQDkgGfYMpMXNaWHUz3cmb/dSssoWl8mM8o3aMs=",
+ "source_code_size": 601,
+ "tags": {
+ "Description": "terraform resources to host the blog",
+ "Project": "panaetius-blog"
+ },
+ "timeout": 3,
+ "timeouts": null,
+ "tracing_config": [
+ {
+ "mode": "PassThrough"
+ }
+ ],
+ "version": "7",
+ "vpc_config": []
+ },
+ "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==",
+ "dependencies": [
+ "aws_iam_role.lambda_role",
+ "aws_iam_role_policy_attachment.lambda_logging"
+ ]
+ }
+ ]
+ },
{
"module": "module.cloudfront_s3_cdn.module.dns",
"mode": "managed",
@@ -674,47 +836,6 @@
}
]
},
- {
- "mode": "managed",
- "type": "aws_s3_bucket_object",
- "name": "index",
- "provider": "provider.aws",
- "instances": [
- {
- "schema_version": 0,
- "attributes": {
- "acl": "public-read",
- "bucket": "prod-panaetius-blog-origin",
- "cache_control": "",
- "content": null,
- "content_base64": null,
- "content_disposition": "",
- "content_encoding": "",
- "content_language": "",
- "content_type": "text/html",
- "etag": "83350948ee374f30e5513497c69c0fe5",
- "force_destroy": false,
- "id": "index.html",
- "key": "index.html",
- "kms_key_id": null,
- "metadata": {},
- "object_lock_legal_hold_status": "",
- "object_lock_mode": "",
- "object_lock_retain_until_date": "",
- "server_side_encryption": "",
- "source": "./test/index.html",
- "storage_class": "STANDARD",
- "tags": {},
- "version_id": "",
- "website_redirect": ""
- },
- "private": "bnVsbA==",
- "dependencies": [
- "module.cloudfront_s3_cdn.aws_s3_bucket.origin"
- ]
- }
- ]
- },
{
"module": "module.cloudfront_s3_cdn",
"mode": "managed",
@@ -729,7 +850,7 @@
"attributes": {
"bucket": "prod-panaetius-blog-origin",
"id": "prod-panaetius-blog-origin",
- "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}"
+ "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"S3GetObjectForCloudFront\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"},\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"},{\"Sid\":\"S3ListBucketForCloudFront\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"},\"Action\":\"s3:ListBucket\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin\"},{\"Sid\":\"PublicRead\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"}]}"
},
"private": "bnVsbA==",
"dependencies": [
diff --git a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup
index f4171dd..5453742 100644
--- a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup
+++ b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup
@@ -1,7 +1,7 @@
{
"version": 4,
"terraform_version": "0.12.26",
- "serial": 88,
+ "serial": 278,
"lineage": "cda52006-90fc-4aec-a630-42e69057b365",
"outputs": {
"cf_arn": {
@@ -13,7 +13,7 @@
"type": "string"
},
"cf_etag": {
- "value": "E2SEL7AYXF1CKS",
+ "value": "E1CTWNZ643PUQZ",
"type": "string"
},
"cf_hosted_zone_id": {
@@ -38,6 +38,32 @@
}
},
"resources": [
+ {
+ "mode": "data",
+ "type": "archive_file",
+ "name": "lambda_main",
+ "provider": "provider.archive",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "excludes": null,
+ "id": "502af9bcd8bac1822a4052c962a3bd322746084b",
+ "output_base64sha256": "W5HchTpXhL2+aBI5O1Qzo25q4hxfbf+uhEln7zcrZpM=",
+ "output_md5": "e7f26d9ad3488ef6867a7f6bc2a7356a",
+ "output_path": "./lambda/prod-panaetius-blog-lambda/main.js.zip",
+ "output_sha": "502af9bcd8bac1822a4052c962a3bd322746084b",
+ "output_size": 597,
+ "source": [],
+ "source_content": null,
+ "source_content_filename": null,
+ "source_dir": null,
+ "source_file": "./lambda/prod-panaetius-blog-lambda/main.js",
+ "type": "zip"
+ }
+ }
+ ]
+ },
{
"module": "module.cloudfront_s3_cdn",
"mode": "data",
@@ -48,9 +74,9 @@
{
"schema_version": 0,
"attributes": {
- "id": "1149999058",
- "json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n }\n ]\n}",
- "override_json": "{\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\": \"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n}\n",
+ "id": "3493490045",
+ "json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}",
+ "override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\":\"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n }\n ]\n}\n",
"policy_id": null,
"source_json": null,
"statement": [
@@ -114,9 +140,9 @@
{
"schema_version": 0,
"attributes": {
- "id": "239689126",
- "json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"*\"\n }\n }\n ]\n}",
- "override_json": "{\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\": \"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n}\n",
+ "id": "736817168",
+ "json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"*\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}",
+ "override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\":\"PublicRead\",\n \"Effect\":\"Allow\",\n \"Principal\":\"*\",\n \"Action\":[\"s3:GetObject\"],\n \"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"\n }\n ]\n}\n",
"policy_id": null,
"source_json": null,
"statement": [
@@ -234,9 +260,9 @@
"schema_version": 0,
"attributes": {
"filename": null,
- "id": "bf2245baaea68e5cc89448356e64936cbd79d0706457d884cdd7badc903719e8",
- "rendered": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"\n }\n }\n ]\n}",
- "template": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n }\n ]\n}",
+ "id": "ef8d6cdd8c782d412e41e1e574ea39e8674f2d80726946a8f8dbe8ea50c1ac8b",
+ "rendered": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}",
+ "template": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"S3GetObjectForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}${origin_path}*\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"S3ListBucketForCloudFront\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::${bucket_name}\",\n \"Principal\": {\n \"AWS\": \"${cloudfront_origin_access_identity_iam_arn}\"\n }\n },\n {\n \"Sid\": \"PublicRead\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": \"arn:aws:s3:::prod-panaetius-blog-origin/*\",\n \"Principal\": \"*\"\n }\n ]\n}",
"vars": {
"bucket_name": "prod-panaetius-blog-origin",
"cloudfront_origin_access_identity_iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5",
@@ -283,7 +309,7 @@
"GET",
"HEAD"
],
- "compress": false,
+ "compress": true,
"default_ttl": 60,
"field_level_encryption_id": "",
"forwarded_values": [
@@ -303,7 +329,13 @@
"query_string_cache_keys": []
}
],
- "lambda_function_association": [],
+ "lambda_function_association": [
+ {
+ "event_type": "origin-request",
+ "include_body": false,
+ "lambda_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:6"
+ }
+ ],
"max_ttl": 31536000,
"min_ttl": 0,
"smooth_streaming": false,
@@ -315,13 +347,13 @@
"default_root_object": "index.html",
"domain_name": "d244ranky0ff54.cloudfront.net",
"enabled": true,
- "etag": "E2SEL7AYXF1CKS",
+ "etag": "E1CTWNZ643PUQZ",
"hosted_zone_id": "Z2FDTNDATAQYW2",
"http_version": "http2",
"id": "E2IHXIMPI3MZ2X",
"in_progress_validation_batches": 0,
"is_ipv6_enabled": true,
- "last_modified_time": "2020-07-15 00:18:34.684 +0000 UTC",
+ "last_modified_time": "2020-07-21 21:18:38.945 +0000 UTC",
"logging_config": [
{
"bucket": "prod-panaetius-blog-logs.s3.amazonaws.com",
@@ -378,6 +410,9 @@
},
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
"dependencies": [
+ "aws_iam_role.lambda_role",
+ "aws_iam_role_policy_attachment.lambda_logging",
+ "aws_lambda_function.directory_indexes",
"module.cloudfront_s3_cdn.aws_cloudfront_origin_access_identity.default",
"module.cloudfront_s3_cdn.aws_s3_bucket.origin",
"module.cloudfront_s3_cdn.module.logs.aws_s3_bucket.default"
@@ -398,7 +433,7 @@
"caller_reference": "terraform-20200713232645930800000001",
"cloudfront_access_identity_path": "origin-access-identity/cloudfront/E21A7YWJ1RT3K5",
"comment": "prod-panaetius-blog",
- "etag": "EESE0U5KF261",
+ "etag": "E38E5DTUJGROV",
"iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5",
"id": "E21A7YWJ1RT3K5",
"s3_canonical_user_id": "2d7779400635ec843efe9b677769fc4f82b0d384408cf22382bf3a90540502e09e75d1346e7105b4da159515b229f39b"
@@ -407,6 +442,133 @@
}
]
},
+ {
+ "mode": "managed",
+ "type": "aws_iam_policy",
+ "name": "lambda_logging",
+ "provider": "provider.aws",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "arn": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging",
+ "description": "",
+ "id": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging",
+ "name": "prod-panaetius-blog-lambda_logging",
+ "name_prefix": null,
+ "path": "/",
+ "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\",\n \"Effect\": \"Allow\"\n }\n ]\n}\n"
+ },
+ "private": "bnVsbA=="
+ }
+ ]
+ },
+ {
+ "mode": "managed",
+ "type": "aws_iam_role",
+ "name": "lambda_role",
+ "provider": "provider.aws",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "arn": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda",
+ "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"lambda.amazonaws.com\",\"edgelambda.amazonaws.com\"]},\"Action\":\"sts:AssumeRole\"}]}",
+ "create_date": "2020-07-21T20:01:43Z",
+ "description": "",
+ "force_detach_policies": false,
+ "id": "prod-panaetius-blog-lambda",
+ "max_session_duration": 3600,
+ "name": "prod-panaetius-blog-lambda",
+ "name_prefix": null,
+ "path": "/",
+ "permissions_boundary": null,
+ "tags": {
+ "Description": "terraform resources to host the blog",
+ "Project": "panaetius-blog"
+ },
+ "unique_id": "AROA23D4RF6O2VEGAGEXM"
+ },
+ "private": "bnVsbA=="
+ }
+ ]
+ },
+ {
+ "mode": "managed",
+ "type": "aws_iam_role_policy_attachment",
+ "name": "lambda_logging",
+ "provider": "provider.aws",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "id": "prod-panaetius-blog-lambda-20200721200145100500000001",
+ "policy_arn": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging",
+ "role": "prod-panaetius-blog-lambda"
+ },
+ "private": "bnVsbA==",
+ "dependencies": [
+ "aws_iam_policy.lambda_logging",
+ "aws_iam_role.lambda_role"
+ ]
+ }
+ ]
+ },
+ {
+ "mode": "managed",
+ "type": "aws_lambda_function",
+ "name": "directory_indexes",
+ "provider": "provider.aws.us_east_1",
+ "instances": [
+ {
+ "schema_version": 0,
+ "attributes": {
+ "arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes",
+ "dead_letter_config": [],
+ "description": "",
+ "environment": [],
+ "file_system_config": [],
+ "filename": "./lambda/prod-panaetius-blog-lambda/main.js.zip",
+ "function_name": "prod-panaetius-blog-directory_indexes",
+ "handler": "main.handler",
+ "id": "prod-panaetius-blog-directory_indexes",
+ "invoke_arn": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes/invocations",
+ "kms_key_arn": "",
+ "last_modified": "2020-07-21T21:18:36.437+0000",
+ "layers": [],
+ "memory_size": 128,
+ "publish": true,
+ "qualified_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:6",
+ "reserved_concurrent_executions": -1,
+ "role": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda",
+ "runtime": "nodejs12.x",
+ "s3_bucket": null,
+ "s3_key": null,
+ "s3_object_version": null,
+ "source_code_hash": "W5HchTpXhL2+aBI5O1Qzo25q4hxfbf+uhEln7zcrZpM=",
+ "source_code_size": 597,
+ "tags": {
+ "Description": "terraform resources to host the blog",
+ "Project": "panaetius-blog"
+ },
+ "timeout": 3,
+ "timeouts": null,
+ "tracing_config": [
+ {
+ "mode": "PassThrough"
+ }
+ ],
+ "version": "6",
+ "vpc_config": []
+ },
+ "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==",
+ "dependencies": [
+ "aws_iam_role.lambda_role",
+ "aws_iam_role_policy_attachment.lambda_logging"
+ ]
+ }
+ ]
+ },
{
"module": "module.cloudfront_s3_cdn.module.dns",
"mode": "managed",
@@ -674,47 +836,6 @@
}
]
},
- {
- "mode": "managed",
- "type": "aws_s3_bucket_object",
- "name": "index",
- "provider": "provider.aws",
- "instances": [
- {
- "schema_version": 0,
- "attributes": {
- "acl": "public-read",
- "bucket": "prod-panaetius-blog-origin",
- "cache_control": "",
- "content": null,
- "content_base64": null,
- "content_disposition": "",
- "content_encoding": "",
- "content_language": "",
- "content_type": "text/html",
- "etag": "83350948ee374f30e5513497c69c0fe5",
- "force_destroy": false,
- "id": "index.html",
- "key": "index.html",
- "kms_key_id": null,
- "metadata": {},
- "object_lock_legal_hold_status": "",
- "object_lock_mode": "",
- "object_lock_retain_until_date": "",
- "server_side_encryption": "",
- "source": "./test/index.html",
- "storage_class": "STANDARD",
- "tags": {},
- "version_id": "",
- "website_redirect": ""
- },
- "private": "bnVsbA==",
- "dependencies": [
- "module.cloudfront_s3_cdn.aws_s3_bucket.origin"
- ]
- }
- ]
- },
{
"module": "module.cloudfront_s3_cdn",
"mode": "managed",
@@ -729,11 +850,10 @@
"attributes": {
"bucket": "prod-panaetius-blog-origin",
"id": "prod-panaetius-blog-origin",
- "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"S3GetObjectForCloudFront\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"},\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"},{\"Sid\":\"S3ListBucketForCloudFront\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"},\"Action\":\"s3:ListBucket\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin\"}]}"
+ "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"S3GetObjectForCloudFront\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"},\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"},{\"Sid\":\"S3ListBucketForCloudFront\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E21A7YWJ1RT3K5\"},\"Action\":\"s3:ListBucket\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin\"},{\"Sid\":\"PublicRead\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::prod-panaetius-blog-origin/*\"}]}"
},
"private": "bnVsbA==",
"dependencies": [
- "module.cloudfront_s3_cdn.aws_cloudfront_origin_access_identity.default",
"module.cloudfront_s3_cdn.aws_s3_bucket.origin"
]
}
diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf
index 837bbd3..55a7186 100644
--- a/infrastructure/variables.tf
+++ b/infrastructure/variables.tf
@@ -14,10 +14,6 @@ variable "profile" {
}
-variable "bucket_name" {
-
-}
-
variable "acm_certificate_arn" {
}
@@ -34,11 +30,26 @@ variable "allowed_origins" {
}
+variable "acl" {
-# variable "log_expiration_days" {
+}
-# }
+variable "lambda_key" {
-# variable "log_standard_transition_days" {
+}
-# }
+variable "source_file" {
+
+}
+
+variable "handler" {
+
+}
+
+variable "runtime" {
+
+}
+
+variable "s3_region" {
+
+}
diff --git a/infrastructure/variables/prod-eu-west-1.tfvars b/infrastructure/variables/prod-eu-west-1.tfvars
index f74486a..a330cef 100644
--- a/infrastructure/variables/prod-eu-west-1.tfvars
+++ b/infrastructure/variables/prod-eu-west-1.tfvars
@@ -1,11 +1,19 @@
-name = "panaetius-blog"
-region = "eu-west-1"
-stage = "prod"
-profile = "admin"
-bucket_name = "prod-panaetius-blog-origin"
+# module
+name = "panaetius-blog"
+region = "eu-west-1"
+stage = "prod"
+profile = "admin"
+
+# cloudfront
acm_certificate_arn = "arn:aws:acm:us-east-1:745437999005:certificate/60af49f0-07bb-4680-8f5b-3c9a33f756e5"
parent_zone_id = "Z05316671VABVSMAAF1RC"
aliases = ["panaetius.io"]
allowed_origins = ["*.panaetius.io"]
-# log_expiration_days = 60
-# log_standard_transition_days = 60
+
+# s3 & lambda
+acl = "private"
+lambda_key = "main.zip"
+source_file = "./lambda/prod-panaetius-blog-lambda/main.js"
+handler = "main.handler"
+runtime = "nodejs12.x"
+s3_region = "us-east-1"