def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: super().__init__(scope, id, **kwargs) project_name = 'inference' # ================================================== # =================== LAMBDAS ====================== # ================================================== lambda_rf_stack = LambdaStack(scope=self, id='lambda_rf', name=f'{project_name}-random-forest', directory='lambda_images/random_forest', bucket='<ADD YOUR S3 BUCKET NAME HERE>', key='<ADD THE MODEL S3 KEY HERE>') lambda_svr_stack = LambdaStack( scope=self, id='lambda_svr', name=f'{project_name}-support-vector', directory='lambda_images/support_vector', bucket='<ADD YOUR S3 BUCKET NAME HERE>', key='<ADD THE MODEL S3 KEY HERE>') lambda_lr_stack = LambdaStack( scope=self, id='lambda_lr', name=f'{project_name}-linear-regressor', directory='lambda_images/linear_regressor', bucket='<ADD YOUR S3 BUCKET NAME HERE>', key='<ADD THE MODEL S3 KEY HERE>') # ================================================== # ================= STATE MACHINE ================== # ================================================== state_machine_stack = StateMachineStack( scope=self, id='state_machine', name=f'{project_name}-state-machine', lambdas={ 'lambda_rf': lambda_rf_stack.lambda_function, 'lambda_svr': lambda_svr_stack.lambda_function, 'lambda_lr': lambda_lr_stack.lambda_function }) # ================================================== # ================== API GATEWAY =================== # ================================================== api_stack = ApiStack(scope=self, id='api', name=f'{project_name}-api', state_machine_arn=state_machine_stack. state_machine.state_machine_arn)
#!/usr/bin/env python3 from aws_cdk import core from stacks.lambda_stack import LambdaStack env_northvirginia = core.Environment( account="1111111111111111", region="us-east-1") app = core.App() LambdaStack(app, "aws-lambda", env=env_northvirginia) app.synth()
'bastion-stack', vpc=vpc_stack.vpc, sg=security_stack.bastion_sg, env={'region': 'eu-west-1'}) kms_stack = KMSStack(app, 'kms-stack', env={'region': 'eu-west-1'}) s3_stack = S3Stack(app, 's3buckets', env={'region': 'eu-west-1'}) rds_stack = RDSStack(app, 'rds-stack', vpc=vpc_stack.vpc, bastionsg=security_stack.bastion_sg, lambdasg=security_stack.lambda_sg, kmskey=kms_stack.kms_rds, env={'region': 'eu-west-1'}) cognito_stack = CognitoStack(app, 'cognito-stack', env={'region': 'eu-west-1'}) apigw_stack = APIStack(app, 'apigw-stack', env={'region': 'eu-west-1'}) lambda_stack = LambdaStack(app, 'lambda-stack') cp_backend = CodePipelineBackendStack( app, 'cp-backend', artifactbucket=core.Fn.import_value('build-artifacts-bucket'), env={'region': 'eu-west-1'}) notifications_stack = NotifiacationStack(app, 'notifications-stack', env={'region': 'eu-west-1'}) cdn_stack = CDNStack(app, 'cdn-stack', s3bucket=core.Fn.import_value('frontend-bucket')) cp_frontend = CodePipelineFrontendStack( app, 'cp-frontend', frontendBucket=core.Fn.import_value('frontend-bucket'),
from stacks.cdn_stack import CDNStack from stacks.codepipeline_frontend import CodePipelineFrontendStack from stacks.waf_stack import WafStack from stacks.route53_stack import DnsStack from stacks.acm_stack import ACMStack from stacks.cloudtrail_stack import CloudTrailStack from stacks.kibana_stack import KibanaStack app = core.App() vpc_stack = VPCStack(app, 'vpc') security_stack = SecurityStack(app, 'security-stack', vpc=vpc_stack.vpc) bastion_stack = BastionStack(app, 'bastion', vpc=vpc_stack.vpc, sg=security_stack.bastion_sg) kms_stack = KMSStack(app,'kms') s3_stack = S3Stack(app,'s3buckets') rds_stack = RDSStack(app,'rds', vpc=vpc_stack.vpc, lambdasg=security_stack.lambda_sg, bastionsg=security_stack.bastion_sg, kmskey=kms_stack.kms_rds) redis_stack = RedisStack(app,'redis', vpc=vpc_stack.vpc, redissg=core.Fn.import_value('redis-sg-export')) cognito_stack = CognitoStack(app,'cognito') apigw_stack = APIStack(app,'apigw') lambda_stack = LambdaStack(app,'lambda') cp_backend = CodePipelineBackendStack(app,'cp-backend', artifactbucket=core.Fn.import_value('build-artifacts-bucket') ) notification = NotificationStack(app,'notification') cp_frontend = CodePipelineFrontendStack(app,'cp-frontend', webhostingbucket=core.Fn.import_value('frontend-bucket')) waf_stack = WafStack(app,'waf') acm_stack = ACMStack(app, 'acm') cdn_stack = CDNStack(app,'cdn',s3bucket=core.Fn.import_value('frontend-bucket'),acmcert=acm_stack.cert_manager) route53 = DnsStack(app, 'route53',cdnid=cdn_stack.cdn_id) cloudtrail = CloudTrailStack(app,'cloudtrail', s3bucket=s3_stack.cloudtrail_bucket) kibana = KibanaStack(app,'kibana', vpc=vpc_stack.vpc, kibanasg=security_stack.kibana_sg) app.synth()
#!/usr/bin/env python3 from aws_cdk import core import boto3 import sys client = boto3.client('sts') region = client.meta.region_name #if region != 'us-east-1': # print("This app may only be run from us-east-1") # sys.exit() account_id = client.get_caller_identity()["Account"] my_env = {'region': region, 'account': account_id} from stacks.lambda_stack import LambdaStack proj_name = "proj-name-" app = core.App() lambda_stack = LambdaStack(app, proj_name + "lambda", env=my_env) app.synth()
print("* !!!!!!!! ERROR !!!!!!!!") print("* This app may only be run from us-east-1") print("* IAM is specific to us-east-1") print("*********************************************") raise Exception('Error: You are using:', region, 'relaunch from us-east-1') sys.exit() account_id = client.get_caller_identity()["Account"] my_env = {'region': 'us-east-1', 'account': account_id} from stacks.iam_stack import IAMStack from stacks.lambda_stack import LambdaStack from stacks.config_stack import ConfigStack proj_name = "config-badpol" app = core.App() iam_stack = IAMStack(app, proj_name + "-iam", env=my_env) lambda_stack = LambdaStack( app, proj_name + "-lambda", config_badpol_lambda_role=iam_stack.config_badpol_lambda_role) config_stack = ConfigStack( app, proj_name + "-config", config_badpol_lambda_function=lambda_stack.config_badpol_lambda_function) app.synth()
region = client.meta.region_name #if region != 'us-east-1': # print("This app may only be run from us-east-1") # sys.exit() account_id = client.get_caller_identity()["Account"] my_env = {'region': region, 'account': account_id} from stacks.iam_stack import IAMStack from stacks.lambda_stack import LambdaStack from stacks.config_stack import ConfigStack proj_name = "toprisk-6" app = core.App() iam_stack = IAMStack(app, proj_name + "-iam", proj=proj_name, env=my_env) lambda_stack = LambdaStack( app, proj_name + "-lambda", config_sg_open_lambda_role=iam_stack.config_sg_open_lambda_role) config_stack = ConfigStack( app, proj_name + "-config", config_sg_checker_function=lambda_stack.sg_checker_func) app.synth()