Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: RDK v1.0 refactor #426

Closed
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b1d65e3
feat(cdk): initial commit
Apr 5, 2023
20de650
feat(cdk-int): initial commit
Apr 5, 2023
b2f6074
feat(cdk-int): add cdk deploy steps
Apr 5, 2023
5318411
fix(cdk-int): fix paths
Apr 5, 2023
5bb3f42
feat(managed-rule): add managed rules
Apr 7, 2023
1231247
feat(test): add rdk test comand
Apr 11, 2023
40bced9
feat(remediation): Add support for remediation configuration
Apr 14, 2023
da1144a
feat(remedi): add remediation configuration
Apr 18, 2023
210d39a
feat(destroy): add support for destroy
Apr 20, 2023
2fa511e
feat(tests): add testing rules
Apr 20, 2023
ac4490f
feat(python): add support to custom python rules
Apr 21, 2023
ac47399
feat(rdklib): add support to rdklib
Apr 21, 2023
5256a70
reformat using black
bmorrissirromb Apr 28, 2023
fae2782
windows updates
bmorrissirromb May 9, 2023
55dba3b
gitignore update
bmorrissirromb May 9, 2023
89c3d62
Delete cdk.out directory
bmorrissirromb May 9, 2023
fc4f1be
update gitignore
bmorrissirromb May 9, 2023
7a30b3d
remove cdkout
bmorrissirromb May 9, 2023
7719d9e
Merge branch 'rdk-on-rdk-sirromb' of https://github.com/bmorrissirrom…
bmorrissirromb May 9, 2023
ef5f369
Merge branch 'master' into rdk-on-rdk-sirromb
mbeacom May 19, 2023
69a04cb
add developer changes notes
bmorrissirromb May 30, 2023
efc7ff9
big update to cdkrdk
bmorrissirromb Jun 21, 2023
a3d7b57
resolve merge conflicts
bmorrissirromb Jun 21, 2023
64d8bd1
Delete README.rst
bmorrissirromb Jun 21, 2023
6845ad5
Delete testing directory
bmorrissirromb Jun 21, 2023
70eab91
use new doc format
bmorrissirromb Jun 21, 2023
5d42db2
Update README.md with todo
bmorrissirromb Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(cdk-int): add cdk deploy steps
Ricky Chau committed Apr 5, 2023
commit b2f6074f3e5487d67fe35a1ac9c97636361a2f73
6 changes: 4 additions & 2 deletions rdk/core/rules_deploy.py
Original file line number Diff line number Diff line change
@@ -46,8 +46,10 @@ def run(self):
rules_dir = Path(self.rulenames[0])

cdk_runner = CdkRunner(
root_module=Path("./cdk"),
root_module=Path().absolute() ,
rules_dir=rules_dir
)

cdk_runner.synthesize()
cdk_runner.synthesize()
cdk_runner.bootstrap()
cdk_runner.deploy()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
# visibility_timeout=Duration.seconds(300),
# )
rule_name = "MyRuleCFNGuard"
rule_dir = "rdk_rules"
rule_dir = "../"
sample_policy_text = Path(f'{rule_dir}/{rule_name}/rule_code.guard').read_text()

# sample_policy_text = """
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 51 additions & 5 deletions rdk/runners/cdk.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import os
from dataclasses import dataclass, field
from pathlib import Path
import shutil
from typing import Any, Dict, List, Optional

import rdk as this_pkg
@@ -24,10 +25,16 @@ class CdkRunner(BaseRunner):

root_module: Path
rules_dir: Path
cdk_app_dir: Path = field(init=False)

def __post_init__(self):
super().__post_init__()

cdk_source_dir = Path(__file__).resolve().parent.parent /'frameworks' / 'cdk'
self.logger.info("Getting latest deployment framework from " + cdk_source_dir.as_posix())
self.logger.info("Deploying latest deployment framework in " + self.root_module.as_posix())
shutil.rmtree(self.root_module / "cdk")
shutil.copytree(Path(__file__).resolve().parent.parent /'frameworks' / 'cdk', self.root_module / 'cdk')
self.cdk_app_dir = self.root_module / "cdk"

def synthesize(self):
"""
@@ -41,13 +48,52 @@ def synthesize(self):
]


self.logger.info("Synthsizing CloudFormation template(s)...")
self.logger.info(self.root_module.as_posix())
self.logger.info(self.rules_dir)
self.logger.info("Synthesizing CloudFormation template(s)...")

self.run_cmd(
cmd=cmd,
cwd=self.cdk_app_dir.as_posix(),
allowed_return_codes=[0, 2],
)

def bootstrap(self):
"""
Executes `cdk bootstrap`.

Parameters:
"""
cmd = [
"cdk",
"bootstrap"
]


self.logger.info("CDK Envrionment Bootstrapping ...")

self.run_cmd(
cmd=cmd,
cwd=self.root_module.as_posix(),
cwd=self.cdk_app_dir.as_posix(),
allowed_return_codes=[0, 2],
)

def deploy(self):
"""
Executes `cdk deploy`.

Parameters:
"""
cmd = [
"cdk",
"deploy",
"--require-approval",
"never"
]


self.logger.info("Deploying AWS Config Rules ...")

self.run_cmd(
cmd=cmd,
cwd=self.cdk_app_dir.as_posix(),
allowed_return_codes=[0, 2],
)