Skip to content

Commit

Permalink
wip 403 at olap
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneider-vertical-relevance committed May 10, 2022
1 parent afcb645 commit b049625
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions stacks/handlers_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
aws_events,
aws_events_targets,
aws_apigatewayv2,
aws_s3objectlambda,
# experimental
aws_apigatewayv2_alpha,
aws_apigatewayv2_authorizers_alpha,
Expand Down Expand Up @@ -135,6 +136,7 @@ def pac_frameworks(self):
),
)


aws_s3_deployment.BucketDeployment(
self,
"PaCPoliciesDeployment",
Expand All @@ -155,15 +157,18 @@ def pac_frameworks(self):
block_public_access=aws_s3.BlockPublicAccess(
block_public_acls=True,
ignore_public_acls=True,
block_public_policy=True,
restrict_public_buckets=True,
# block_public_policy=True,
# restrict_public_buckets=True,
block_public_policy=False,
restrict_public_buckets=False,
),
event_bridge_enabled=True
)

self.bucket_raw_pac_results.add_to_resource_policy(
aws_iam.PolicyStatement(
principals=[
# aws_iam.AnyPrincipal()
aws_iam.AnyPrincipal().with_conditions(
{
"ForAnyValue:StringLike": {
Expand All @@ -174,16 +179,19 @@ def pac_frameworks(self):
],
actions=[
"s3:GetObject",
"s3:Get*",
"s3:List*",
],
resources=[
self.bucket_raw_pac_results.bucket_arn,
self.bucket_raw_pac_results.arn_for_objects("*"),
],
)
)
)

def output_handler(self):


self.event_bus_infractions = aws_events.EventBus(
self,
"Infractions"
Expand Down Expand Up @@ -232,6 +240,7 @@ def output_handler(self):
},
)


self.lambda_output_handler.role.add_to_policy(
aws_iam.PolicyStatement(
actions=[
Expand Down Expand Up @@ -272,6 +281,7 @@ def output_handler(self):
# # prefix="home/myusername/*"
# )


self.access_point = aws_s3objectlambda_alpha.AccessPoint(
self,
"OuputHandlerCloudFormationOPA",
Expand All @@ -283,6 +293,36 @@ def output_handler(self):
# }
)

# policy_document_access_point = aws_iam.PolicyStatement(
# principals=[
# aws_iam.AnyPrincipal().with_conditions(
# {
# "ForAnyValue:StringLike": {
# "aws:PrincipalOrgPaths": [
# # self.secrets.allowed_org_path,
# "o-9txpghbplo/*"
# ]
# }
# }
# )
# ],
# actions=[
# "s3:GetObject",
# ],
# resources=["*"
# # self.bucket_raw_pac_results.bucket_arn,
# # self.bucket_raw_pac_results.arn_for_objects("*"),
# ],
# )

# cfn_access_point_policy = aws_s3objectlambda.CfnAccessPointPolicy(
# self,
# "OuputHandlerSameOrgPolicy",
# object_lambda_access_point=self.access_point.access_point_name,
# policy_document=policy_document_access_point.to_json()
# # policy_document={}
# )

CfnOutput(self, "OuputHandlerCloudFormationOPAAccessPointArn", value=self.access_point.access_point_arn)

def authorizer_lambda(self):
Expand Down

0 comments on commit b049625

Please sign in to comment.