-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
34 lines (28 loc) · 1.19 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
from aws_cdk import App, Environment, Aspects
from sso_automation_app.sso_stack import AWSSSOStack
import logging
import cdk_nag
logger = logging.getLogger(__name__)
loghandler = logging.StreamHandler()
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
loghandler.setFormatter(formatter)
logger.addHandler(loghandler)
logger.setLevel(logging.DEBUG)
app = App()
profile = app.node.try_get_context("profile")
account_id = app.node.try_get_context("accountID")
region_name = app.node.try_get_context("region")
stage = app.node.try_get_context("stage")
stage_bucket = app.node.try_get_context("stagebucket")
organization_id = app.node.try_get_context("orgid")
sso_permission_sets = app.node.try_get_context("permsets")
sso_assignments = app.node.try_get_context("assignments")
env_info = Environment(account=account_id, region=region_name)
if profile and env_info:
if sso_permission_sets and sso_assignments:
AWSSSOStack(app, "awssso-stack", sso_permission_sets, sso_assignments, profile, env=env_info)
Aspects.of(app).add(cdk_nag.AwsSolutionsChecks())
else:
logger.debug("Failed to specify a profile and environment")
app.synth()