This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "archive_file" "lambda_zip" { | |
type = "zip" | |
source_file = "${path.module}/src/conversion_lambda_python_file.py" | |
output_file_mode = "0666" | |
output_path = "${path.module}/bin/conversion_lambda_python_file.zip" | |
} | |
resource "aws_lambda_function" "conversion_lambda" { | |
runtime = "python3.9" | |
filename = data.archive_file.lambda_zip.output_path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_s3_bucket_notification" "incoming" { | |
bucket = aws_s3_bucket.incoming.id | |
lambda_function { | |
lambda_function_arn = aws_lambda_function.conversion_lambda.arn | |
events = ["s3:ObjectCreated:*"] | |
filter_prefix = "foldername" | |
filter_suffix = ".zip" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role_policy" "lambda" { | |
name = "s3_policy" | |
role = aws_iam_role.conversion_lambda_role.id | |
policy = jsonencode({ | |
Version = "2012-10-17" | |
Statement = [ | |
{ | |
Effect = "Allow" | |
Action = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import os | |
import urllib3 | |
import json | |
import boto3 | |
import base64 | |
from botocore.exceptions import ClientError | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "run_pipeline" { | |
bucket_name = module.s3_buckets.name | |
s3_prefix = "testfolder/" | |
s3_suffix = ".zip" | |
pipeline_name = "dbt-validation" | |
bitbucket_branch_name = "default" | |
bitbucket_repo_owner = "username" | |
bitbucket_repo_slug = "reponame" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "archive_file" "lambda_zip" { | |
type = "zip" | |
source_file = "${path.module}/src/run_pipeline.py" | |
output_file_mode = "0666" | |
output_path = "${path.module}/bin/run_pipeline.zip" | |
} | |
resource "aws_lambda_function" "processing_lambda" { | |
filename = data.archive_file.lambda_zip.output_path | |
function_name = local.processing_lambda_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_s3_bucket" "run_pipeline" { | |
bucket = local.bucket_name | |
} | |
resource "aws_s3_bucket_notification" "run_pipeline" { | |
bucket = data.aws_s3_bucket.run_pipeline.id | |
lambda_function { | |
lambda_function_arn = aws_lambda_function.processing_lambda.arn | |
events = ["s3:ObjectCreated:*", "s3:ObjectRemoved:*", "s3:ObjectRestore:*"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_secretsmanager_secret" "pipeline_password" { | |
name = "pipeline_pwd" | |
description = "pipeline pwd for triggering bitbucket pipeline" | |
tags = "-" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import os | |
import boto3 | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
def lambda_handler(event, context): | |
logger.info(f'Hello World!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "schedule_test_module" { | |
source = "../_modules/.." | |
config = module.config | |
schedule = "cron(0/10 * ? * MON-FRI *)" | |
} |