Skip to content

Commit 523d263

Browse files
wenhaizhumetafacebook-github-bot
authored andcommitted
fix the bugs in minimum permission policy (#676)
Summary: Pull Request resolved: #676 In computation UI, we need the user to provide the aws_access_key_id and aws_secret_access_key. Usually it's the admin credentials, but for the computation UI project, we have identified the policy with minimum permissions to run the calculation. This diff is to fix a few permissions. 1. We're using the wrong database name. It should be "mpc-events-db-<TAG>" instead of "fb_pc_data_<TAG>". 2. The "fb_pc_data_<TAG>" should be the table name. 3. Missed one resource for the GLUE permission. Reviewed By: marksliva Differential Revision: D34773691 fbshipit-source-id: 43c340b79e13b3ba78d37f634816faf62ba73be8
1 parent 14be23c commit 523d263

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-2
lines changed

fbpcs/infra/cloud_bridge/cli.py

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def aws_create_iam_policy_parser_arguments(aws_parser: argparse):
119119
"--database_name", type=str, required=False, help="Database name"
120120
)
121121

122+
iam_policy_command_group.add_argument(
123+
"--table_name", type=str, required=False, help="Table name"
124+
)
125+
122126
iam_policy_command_group.add_argument(
123127
"--cluster_name", type=str, required=False, help="ECS cluster name"
124128
)

fbpcs/infra/cloud_bridge/deploy.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ deploy_aws_resources() {
362362
--data_bucket_name "$s3_bucket_data_pipeline" \
363363
--config_bucket_name "$s3_bucket_for_storage" \
364364
--database_name "$database_name" \
365+
--table_name "$table_name" \
365366
--cluster_name "$aws_ecs_cluster_name" \
366367
--ecs_task_execution_role_name "$ecs_task_execution_role_name"
367368
echo "######################## Finished deploy resources policy ########################"
@@ -387,7 +388,6 @@ else
387388
# s3_bucket_for_storage is set, but add tags to it
388389
s3_bucket_for_storage="$s3_bucket_for_storage$tag_postfix"
389390
fi
390-
database_name=${s3_bucket_for_storage//-/_}
391391

392392
if [ -z ${s3_bucket_data_pipeline+x} ]
393393
then
@@ -399,6 +399,8 @@ else
399399
fi
400400

401401
policy_name="fb-pc-policy${tag_postfix}"
402+
database_name="mpc-events-db${tag_postfix}"
403+
table_name=${s3_bucket_data_pipeline//-/_}
402404
data_upload_key_path="semi-automated-data-ingestion"
403405
events_data_upload_s3_key="events-data-validation"
404406
query_results_key_path="query-results"

fbpcs/infra/cloud_bridge/deployment_helper/aws/aws_deployment_helper.py

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ def read_json_file(
290290
"ECS_TASK_EXECUTION_ROLE_NAME": policy_params.ecs_task_execution_role_name,
291291
"FIREHOSE_STREAM_NAME": policy_params.firehose_stream_name,
292292
"DATEBASE_NAME": policy_params.database_name,
293+
"TABLE_NAME": policy_params.table_name,
293294
}
294295

295296
file_path = os.path.join(os.path.dirname(__file__), file_name)

fbpcs/infra/cloud_bridge/deployment_helper/aws/aws_deployment_helper_tool.py

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def create(self):
4141
data_bucket_name=self.cli_args.data_bucket_name,
4242
config_bucket_name=self.cli_args.config_bucket_name,
4343
database_name=self.cli_args.database_name,
44+
table_name=self.cli_args.table_name,
4445
cluster_name=self.cli_args.cluster_name,
4546
ecs_task_execution_role_name=self.cli_args.ecs_task_execution_role_name,
4647
)

fbpcs/infra/cloud_bridge/deployment_helper/aws/iam_policies/fb_pc_iam_policy.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"arn:aws:glue:${REGION}:${ACCOUNT_ID}:catalog",
4040
"arn:aws:glue:${REGION}:${ACCOUNT_ID}:database/default",
4141
"arn:aws:glue:${REGION}:${ACCOUNT_ID}:database/${DATEBASE_NAME}",
42-
"arn:aws:glue:${REGION}:${ACCOUNT_ID}:table/${DATEBASE_NAME}/*"
42+
"arn:aws:glue:${REGION}:${ACCOUNT_ID}:table/${DATEBASE_NAME}/*",
43+
"arn:aws:glue:${REGION}:${ACCOUNT_ID}:table/default/${TABLE_NAME}"
4344
]
4445
},
4546
{

fbpcs/infra/cloud_bridge/deployment_helper/aws/policy_params.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ class PolicyParams:
1212
data_bucket_name: str
1313
config_bucket_name: str
1414
database_name: str
15+
table_name: str
1516
cluster_name: str
1617
ecs_task_execution_role_name: str

0 commit comments

Comments
 (0)