Added Lambda Skeleton
This commit is contained in:
19
.terraform.lock.hcl
generated
19
.terraform.lock.hcl
generated
@@ -1,6 +1,25 @@
|
|||||||
# This file is maintained automatically by "terraform init".
|
# This file is maintained automatically by "terraform init".
|
||||||
# Manual edits may be lost in future updates.
|
# Manual edits may be lost in future updates.
|
||||||
|
|
||||||
|
provider "registry.terraform.io/hashicorp/archive" {
|
||||||
|
version = "2.4.2"
|
||||||
|
hashes = [
|
||||||
|
"h1:G4v6F6Lhqlo3EKGBKEK/kJRhNcQiRrhEdUiVpBHKHOA=",
|
||||||
|
"zh:08faed7c9f42d82bc3d406d0d9d4971e2d1c2d34eae268ad211b8aca57b7f758",
|
||||||
|
"zh:3564112ed2d097d7e0672378044a69b06642c326f6f1584d81c7cdd32ebf3a08",
|
||||||
|
"zh:53cd9afd223c15828c1916e68cb728d2be1cbccb9545568d6c2b122d0bac5102",
|
||||||
|
"zh:5ae4e41e3a1ce9d40b6458218a85bbde44f21723943982bca4a3b8bb7c103670",
|
||||||
|
"zh:5b65499218b315b96e95c5d3463ea6d7c66245b59461217c99eaa1611891cd2c",
|
||||||
|
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
||||||
|
"zh:7f45b35a8330bebd184c2545a41782ff58240ed6ba947274d9881dd5da44b02e",
|
||||||
|
"zh:87e67891033214e55cfead1391d68e6a3bf37993b7607753237e82aa3250bb71",
|
||||||
|
"zh:de3590d14037ad81fc5cedf7cfa44614a92452d7b39676289b704a962050bc5e",
|
||||||
|
"zh:e7e6f2ea567f2dbb3baa81c6203be69f9cd6aeeb01204fd93e3cf181e099b610",
|
||||||
|
"zh:fd24d03c89a7702628c2e5a3c732c0dede56fa75a08da4a1efe17b5f881c88e2",
|
||||||
|
"zh:febf4b7b5f3ff2adff0573ef6361f09b6638105111644bdebc0e4f575373935f",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
provider "registry.terraform.io/hashicorp/aws" {
|
provider "registry.terraform.io/hashicorp/aws" {
|
||||||
version = "5.45.0"
|
version = "5.45.0"
|
||||||
constraints = "~> 5.0"
|
constraints = "~> 5.0"
|
||||||
|
|||||||
13
lambda_redirect/lambda_redirect.py
Normal file
13
lambda_redirect/lambda_redirect.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
def lambda_handler(event, context):
|
||||||
|
|
||||||
|
return {
|
||||||
|
"statusCode": 301,
|
||||||
|
"headers": {
|
||||||
|
"Cache-Control": "no-cache",
|
||||||
|
#"Location": "https://standout-data.s3.eu-west-1.amazonaws.com/funnel-rotation-circles.jpg"
|
||||||
|
#"Location": "https://www.instagram.com/cosebrutteimpaginatebelle/?e=ec081328-9f83-4745-b6b7-aed1e87963df&g=5"
|
||||||
|
#"Location": "https://standout-data.s3.eu-west-1.amazonaws.com/Meter-Seneca.pdf"
|
||||||
|
#"Location": "https://standout-data.s3.eu-west-1.amazonaws.com/Lisa+Varano.vcf"
|
||||||
|
}
|
||||||
|
}
|
||||||
51
master.tf
51
master.tf
@@ -33,10 +33,10 @@ resource "aws_s3_bucket_ownership_controls" "s3_standout_ownership" {
|
|||||||
resource "aws_s3_bucket_public_access_block" "s3_standout_public_access" {
|
resource "aws_s3_bucket_public_access_block" "s3_standout_public_access" {
|
||||||
bucket = aws_s3_bucket.s3_standout.id
|
bucket = aws_s3_bucket.s3_standout.id
|
||||||
|
|
||||||
block_public_acls = false
|
block_public_acls = true
|
||||||
block_public_policy = false
|
block_public_policy = true
|
||||||
ignore_public_acls = false
|
ignore_public_acls = true
|
||||||
restrict_public_buckets = false
|
restrict_public_buckets = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket_acl" "s3_standout_public_acl" {
|
resource "aws_s3_bucket_acl" "s3_standout_public_acl" {
|
||||||
@@ -75,5 +75,48 @@ data "aws_iam_policy_document" "s3_standout_allow_lambda" {
|
|||||||
|
|
||||||
# create a redirect lambda function
|
# create a redirect lambda function
|
||||||
|
|
||||||
|
data "aws_iam_policy_document" "lambda_role" {
|
||||||
|
statement {
|
||||||
|
effect = "Allow"
|
||||||
|
|
||||||
|
principals {
|
||||||
|
type = "Service"
|
||||||
|
identifiers = ["lambda.amazonaws.com"]
|
||||||
|
}
|
||||||
|
|
||||||
|
actions = ["sts:AssumeRole"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_iam_role" "iam_for_lambda" {
|
||||||
|
name = "iam_for_lambda"
|
||||||
|
assume_role_policy = data.aws_iam_policy_document.lambda_role.json
|
||||||
|
}
|
||||||
|
|
||||||
|
data "archive_file" "lambda_standout_code" {
|
||||||
|
type = "zip"
|
||||||
|
source_file = "./lambda_redirect/lambda_redirect.py"
|
||||||
|
output_path = "standout_lambda_function.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_lambda_function" "lambda_standout_redirect" {
|
||||||
|
# If the file is not in the current working directory you will need to include a
|
||||||
|
# path.module in the filename.
|
||||||
|
filename = "standout_lambda_function.zip"
|
||||||
|
function_name = "standout-redirect"
|
||||||
|
role = aws_iam_role.iam_for_lambda.arn
|
||||||
|
handler = "lambda_handler"
|
||||||
|
|
||||||
|
source_code_hash = data.archive_file.lambda_standout_code.output_base64sha256
|
||||||
|
|
||||||
|
runtime = "python3.10"
|
||||||
|
|
||||||
|
#environment {
|
||||||
|
# variables = {
|
||||||
|
# foo = "bar"
|
||||||
|
# }
|
||||||
|
#}
|
||||||
|
}
|
||||||
|
|
||||||
# create a route 53 configuration
|
# create a route 53 configuration
|
||||||
|
|
||||||
|
|||||||
BIN
standout_lambda_function.zip
Normal file
BIN
standout_lambda_function.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user