From 9207225db0c66450830dffb235fbfcb053e88901 Mon Sep 17 00:00:00 2001 From: Mark Sliva Date: Thu, 1 Sep 2022 16:53:56 -0700 Subject: [PATCH] Move data bucket creation out of the data_ingestion TF (#1530) Summary: Pull Request resolved: https://github.com/facebookresearch/fbpcs/pull/1530 The data bucket creation was previously bundled into the data_ingestion terraform template. This prevents limiting the s3 access to only the necessary bucket for the PCE, which will be updated in a followup. Reviewed By: ankushksingh Differential Revision: D39197009 fbshipit-source-id: 0f21427da1c90e2b54807ec030fbe29244dbe981 --- .../infra/cloud_bridge/data_ingestion/main.tf | 40 +------------------ .../cloud_bridge/data_ingestion/output.tf | 10 ----- .../cloud_bridge/data_ingestion/variable.tf | 5 +++ fbpcs/infra/cloud_bridge/deploy.sh | 15 ++++--- fbpcs/infra/cloud_bridge/util.sh | 11 ----- 5 files changed, 15 insertions(+), 66 deletions(-) diff --git a/fbpcs/infra/cloud_bridge/data_ingestion/main.tf b/fbpcs/infra/cloud_bridge/data_ingestion/main.tf index e4c671e1b..44333850f 100644 --- a/fbpcs/infra/cloud_bridge/data_ingestion/main.tf +++ b/fbpcs/infra/cloud_bridge/data_ingestion/main.tf @@ -34,7 +34,7 @@ resource "aws_kinesis_firehose_delivery_stream" "extended_s3_stream" { extended_s3_configuration { role_arn = aws_iam_role.firehose_role.arn - bucket_arn = aws_s3_bucket.bucket.arn + bucket_arn = var.data_processing_output_bucket_arn buffer_size = 128 buffer_interval = 900 prefix = "${var.events_data}/year=!{partitionKeyFromLambda:year}/month=!{partitionKeyFromLambda:month}/day=!{partitionKeyFromLambda:day}/hour=!{partitionKeyFromLambda:hour}/" @@ -57,44 +57,6 @@ resource "aws_kinesis_firehose_delivery_stream" "extended_s3_stream" { } } -resource "aws_s3_bucket" "bucket" { - bucket = var.data_processing_output_bucket - versioning { - enabled = true - } - server_side_encryption_configuration { - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } - } - } - -} - -resource "aws_s3_bucket_policy" "bucket_policy" { - bucket = aws_s3_bucket.bucket.id - - policy = <&1 | grep -q "404" # bucekt doesn't exist - then - echo "The bucket $s3_bucket_data_pipeline doesn't exist. Continue..." - else # bucket exists, we want the data-storage bucket to be new - echo "The bucket $s3_bucket_data_pipeline already exists under Account $aws_account_id. Please choose another bucket name." - exit 1 - fi - fi echo "validate input: aws account id..." echo "Your AWS acount ID is $aws_account_id" account_A=$(aws sts get-caller-identity |grep -o 'Account":.*' | tr -d '"' | tr -d ' ' | tr -d ',' | cut -d':' -f2)