provider "aws" { region = "eu-west-1" } provider "aws" { alias = "eu-west-3" region = "eu-west-3" } provider "aws" { alias = "ap-northeast-1" region = "ap-northeast-1" } resource "aws_iam_role" "iam_for_lambda" { name = "iam_for_lambda" assume_role_policy = < resource "aws_s3_bucket" "bucket" { bucket = "bucket-martin-test-drift" } resource "aws_lambda_permission" "allow1_bucket" { statement_id = "Allow1ExecutionFromS3Bucket" action = "lambda:InvokeFunction" function_name = aws_lambda_function.func1.arn principal = "s3.amazonaws.com" source_arn = aws_s3_bucket.bucket.arn } resource "aws_lambda_permission" "allow2_bucket" { statement_id = "Allow2ExecutionFromS3Bucket" action = "lambda:InvokeFunction" function_name = aws_lambda_function.func2.arn principal = "s3.amazonaws.com" source_arn = aws_s3_bucket.bucket.arn } resource "aws_s3_bucket_notification" "bucket_notification" { bucket = aws_s3_bucket.bucket.id lambda_function { lambda_function_arn = aws_lambda_function.func1.arn events = ["s3:ObjectCreated:*"] filter_prefix = "AWSLogs/" filter_suffix = ".log" } lambda_function { lambda_function_arn = aws_lambda_function.func2.arn events = ["s3:ObjectCreated:*"] filter_prefix = "OtherLogs/" filter_suffix = ".log" } } resource "aws_s3_bucket_policy" "bucket_policy" { bucket = aws_s3_bucket.bucket.id policy = < // resource "aws_s3_bucket" "bucket2" { provider = aws.eu-west-3 bucket = "bucket-martin-test-drift2" } resource "aws_lambda_permission" "allow1_bucket2" { provider = aws.eu-west-3 statement_id = "Allow1ExecutionFromS3Bucket2" action = "lambda:InvokeFunction" function_name = aws_lambda_function.func1w3.arn principal = "s3.amazonaws.com" source_arn = aws_s3_bucket.bucket2.arn } resource "aws_lambda_permission" "allow2_bucket2" { provider = aws.eu-west-3 statement_id = "Allow2ExecutionFromS3Bucket2" action = "lambda:InvokeFunction" function_name = aws_lambda_function.func2w3.arn principal = "s3.amazonaws.com" source_arn = aws_s3_bucket.bucket2.arn } resource "aws_s3_bucket_notification" "bucket_notification2" { provider = aws.eu-west-3 bucket = aws_s3_bucket.bucket2.id lambda_function { lambda_function_arn = aws_lambda_function.func1w3.arn events = ["s3:ObjectCreated:*"] filter_prefix = "AWSLogs/" filter_suffix = ".log" } lambda_function { lambda_function_arn = aws_lambda_function.func2w3.arn events = ["s3:ObjectCreated:*"] filter_prefix = "OtherLogs/" filter_suffix = ".log" } } resource "aws_s3_bucket_policy" "bucket2_policy" { provider = aws.eu-west-3 bucket = aws_s3_bucket.bucket2.id policy = < // resource "aws_s3_bucket" "bucket3" { provider = aws.ap-northeast-1 bucket = "bucket-martin-test-drift3" } resource "aws_lambda_permission" "allow1_bucket3" { provider = aws.ap-northeast-1 statement_id = "Allow1ExecutionFromS3Bucket3" action = "lambda:InvokeFunction" function_name = aws_lambda_function.func1ap.arn principal = "s3.amazonaws.com" source_arn = aws_s3_bucket.bucket3.arn } resource "aws_lambda_permission" "allow2_bucket3" { provider = aws.ap-northeast-1 statement_id = "Allow2ExecutionFromS3Bucket3" action = "lambda:InvokeFunction" function_name = aws_lambda_function.func2ap.arn principal = "s3.amazonaws.com" source_arn = aws_s3_bucket.bucket3.arn } resource "aws_s3_bucket_notification" "bucket_notification3" { provider = aws.ap-northeast-1 bucket = aws_s3_bucket.bucket3.id lambda_function { lambda_function_arn = aws_lambda_function.func1ap.arn events = ["s3:ObjectCreated:*"] filter_prefix = "AWSLogs/" filter_suffix = ".log" } lambda_function { lambda_function_arn = aws_lambda_function.func2ap.arn events = ["s3:ObjectCreated:*"] filter_prefix = "OtherLogs/" filter_suffix = ".log" } } resource "aws_s3_bucket_policy" "bucket3_policy" { provider = aws.ap-northeast-1 bucket = aws_s3_bucket.bucket3.id policy = <