Skip to content

Commit

Permalink
Issue #3 todo deny by default logic; local env var for org id
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneider-vertical-relevance committed Apr 29, 2022
1 parent ea7f268 commit a5c16da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
env=env,
application_team_cdk_app=application_team_cdk_app,
config_rule_enabled=app.node.try_get_context("control-broker/config-rule/enabled"),
organization_id_parameter=app.node.try_get_context("control-broker/organization-id-ssm-parameter"),
config_rule_scope=aws_config.RuleScope.from_resources(
resource_types=[aws_config.ResourceType.SQS_QUEUE]
),
Expand Down
6 changes: 5 additions & 1 deletion cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"github_repo_branch": "config-integration"
},
"control-broker/post-deployment-testing/enabled": true,
"control-broker/client/enabled": true
"control-broker/client/enabled": true,
"control-broker/organization-id-ssm-parameter":{
"Name":"/control-broker/aws-organization-id",
"Version":1
}
}
}
22 changes: 11 additions & 11 deletions stacks/control_broker_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
aws_iam,
aws_logs,
aws_events,
aws_ssm,
)
from constructs import Construct

Expand All @@ -28,6 +29,7 @@ def __init__(
scope: Construct,
construct_id: str,
application_team_cdk_app: dict,
organization_id_parameter: str,
config_rule_enabled: bool = False,
config_rule_scope: aws_config.RuleScope = None,
**kwargs,
Expand Down Expand Up @@ -59,6 +61,8 @@ def __init__(
super().__init__(scope, construct_id, **kwargs)

self.application_team_cdk_app = application_team_cdk_app

self.organization_id_parameter = organization_id_parameter

self.pipeline_ownership_metadata = {}
(
Expand Down Expand Up @@ -155,15 +159,20 @@ def deploy_utils(self):
self.bucket_eval_results_reports = aws_s3.Bucket(
self,
"EvalResultsReports",
block_public_access=aws_s3.BlockPublicAccess.BLOCK_ALL,
removal_policy=RemovalPolicy.DESTROY,
auto_delete_objects=True,
block_public_access=aws_s3.BlockPublicAccess(
block_public_acls = True,
ignore_public_acls = True,
block_public_policy = True,
restrict_public_buckets = True,
)
)

self.bucket_eval_results_reports.add_to_resource_policy(
aws_iam.PolicyStatement(
principals=[
aws_iam.AnyPrincipal()
aws_iam.OrganizationPrincipal(os.environ.get('AWS_ORG_ID'))
],
actions=[
"s3:GetObject",
Expand All @@ -174,15 +183,6 @@ def deploy_utils(self):
self.bucket_eval_results_reports.bucket_arn,
self.bucket_eval_results_reports.arn_for_objects("*"),
],
# conditions= [
# {
# "StringEquals": {
# "aws:PrincipalOrgID": [
# aws_iam.OrganizationPrincipal.organization_id
# ]
# }
# }
# ]
)
)

Expand Down

0 comments on commit a5c16da

Please sign in to comment.