Ejemplo n.º 1
0
#!/usr/bin/env python3
import os

import aws_cdk as cdk

from sfn_athena_cdk_python.sfn_athena_cdk_python_stack import SfnAthenaCdkPythonStack


app = cdk.App()
SfnAthenaCdkPythonStack(app, "SfnAthenaCdkPythonStack",
    env=cdk.Environment(
    account=os.environ["CDK_DEFAULT_ACCOUNT"],
    region=os.environ["CDK_DEFAULT_REGION"])
    )

app.synth()
Ejemplo n.º 2
0
          }
        }, indent=2)
      },
      passthrough_behavior=aws_apigateway.PassthroughBehavior.WHEN_NO_TEMPLATES
    )

    get_integration = aws_apigateway.AwsIntegration(
      service='dynamodb',
      action='Query',
      integration_http_method='POST',
      options=ddb_query_item_options
    )

    one_resource.add_method('GET', get_integration,
      method_responses=method_responses,
      authorization_type=aws_apigateway.AuthorizationType.COGNITO,
      authorizer=auth
    )

    cdk.CfnOutput(self, 'DynamoDBTableName', value=ddb_table.table_name)
    cdk.CfnOutput(self, 'UserPoolId', value=user_pool.user_pool_id)
    cdk.CfnOutput(self, 'UserPoolClientId', value=user_pool_client.user_pool_client_id)


app = cdk.App()
CognitoProtectedDynamoDBApiStack(app, "CognitoProtectedDynamoDBApiStack", env=cdk.Environment(
  account=os.getenv('CDK_DEFAULT_ACCOUNT'),
  region=os.getenv('CDK_DEFAULT_REGION')))

app.synth()
Ejemplo n.º 3
0
            execution_role=sagemaker_emr_execution_role.role_arn,
            security_groups=[sg_sm_instance.security_group_id])

        sagemaker_studio_domain = aws_sagemaker.CfnDomain(
            self,
            'SageMakerStudioDomain',
            auth_mode='IAM',  # [SSO | IAM]
            default_user_settings=sm_studio_user_settings,
            domain_name='StudioDomain',
            subnet_ids=vpc.select_subnets(
                subnet_type=aws_ec2.SubnetType.PRIVATE_WITH_NAT).subnet_ids,
            vpc_id=vpc.vpc_id,
            app_network_access_type='VpcOnly'  # [PublicInternetOnly | VpcOnly]
        )

        aws_sagemaker.CfnUserProfile(
            self,
            'SageMakerStudioUserProfile',
            domain_id=sagemaker_studio_domain.attr_domain_id,
            user_profile_name='studio-user')


app = cdk.App()
SageMakerStudioStack(app,
                     "SageMakerStudioStack",
                     env=cdk.Environment(
                         account=os.getenv('CDK_DEFAULT_ACCOUNT'),
                         region=os.getenv('CDK_DEFAULT_REGION')))

app.synth()
Ejemplo n.º 4
0
        'instance_type': aws_ec2.InstanceType.of(aws_ec2.InstanceClass.BURSTABLE3, aws_ec2.InstanceSize.MEDIUM),
        'parameter_group': rds_db_param_group,
        'vpc_subnets': {
          'subnet_type': aws_ec2.SubnetType.PRIVATE_WITH_NAT
        },
        'vpc': vpc,
        'auto_minor_version_upgrade': False,
        'security_groups': [sg_mysql_server]
      },
      instances=2,
      parameter_group=rds_cluster_param_group,
      cloudwatch_logs_retention=aws_logs.RetentionDays.THREE_DAYS,
      cluster_identifier=db_cluster_name,
      subnet_group=rds_subnet_group,
      backup=aws_rds.BackupProps(
        retention=cdk.Duration.days(3),
        preferred_window="03:00-04:00"
      )
    )

    cdk.CfnOutput(self, 'DBClusterEndpoint', value=db_cluster.cluster_endpoint.socket_address, export_name='DBClusterEndpoint')
    cdk.CfnOutput(self, 'DBClusterReadEndpoint', value=db_cluster.cluster_read_endpoint.socket_address, export_name='DBClusterReadEndpoint')


app = cdk.App()
AuroraMysqlStack(app, "AuroraMySQLStack", env=cdk.Environment(
  account=os.environ["CDK_DEFAULT_ACCOUNT"],
  region=os.environ["CDK_DEFAULT_REGION"]))

app.synth()
Ejemplo n.º 5
0
#!/usr/bin/env python3
import os

import aws_cdk as cdk

from vpc_v2.vpc_v2_stack import VpcV2Stack

ACCOUNT_ID = os.environ.get('ACCOUNT_ID')
REGION = os.environ.get('REGION')
if not ACCOUNT_ID:
    raise Exception('[error] ACCOUNT_ID')
if not REGION:
    raise Exception('[error] REGION')
env = {
    'region': REGION,
    'account': ACCOUNT_ID,
}
env = cdk.Environment(account=ACCOUNT_ID, region=REGION)

app = cdk.App()
VpcV2Stack(app, "VpcV2Stack", env=env)

app.synth()
Ejemplo n.º 6
0
#!/usr/bin/env python3
import os

import aws_cdk as cdk

from cdk_sfn.cdk_sfn_stack import CdkSfnStack

app = cdk.App()
CdkSfnStack(
    app,
    "CdkSfnStack",
    # If you don't specify 'env', this stack will be environment-agnostic.
    # Account/Region-dependent features and context lookups will not work,
    # but a single synthesized template can be deployed anywhere.

    # Uncomment the next line to specialize this stack for the AWS Account
    # and Region that are implied by the current CLI configuration.

    #env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')),

    # Uncomment the next line if you know exactly what Account and Region you
    # want to deploy the stack to. */
    env=cdk.Environment(account='872436821098', region='ap-south-1'),

    # For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
)

app.synth()
Ejemplo n.º 7
0
    distribution = cloudfront.Distribution(self, "myDist",
      default_behavior=cloudfront.BehaviorOptions(
        origin=cf_origins.S3Origin(bucket=site_bucket, origin_access_identity=cloudfrontOAI)
      ),
      error_responses=[
        #XXX: If you have accessed root page of cloudfront url (i.e. https://your-domain.cloudfront.net/),
        #XXX: 403:Forbidden error might occur. In order to prevent this error,
        #XXX: configure 403:Forbidden error response page to be 'index.html'
        cloudfront.ErrorResponse(http_status=403, response_http_status=200,
          response_page_path='/index.html', ttl=cdk.Duration.seconds(10)),
        #XXX: Configure 404:NotFound error response page to be 'error.html'
        cloudfront.ErrorResponse(http_status=404, response_http_status=404,
          response_page_path='/error.html', ttl=cdk.Duration.seconds(10))
      ]
    )

    cdk.CfnOutput(self, 'StackName', value=self.stack_name, export_name='StackName')
    cdk.CfnOutput(self, 'SiteBucket', value=site_bucket.bucket_name, export_name='SiteBucket')
    cdk.CfnOutput(self, 'DistributionId', value=distribution.distribution_id, export_name='DistributionId')
    cdk.CfnOutput(self, 'DistributionDomainName', value=distribution.distribution_domain_name, export_name='DistributionDomainName')
    cdk.CfnOutput(self, 'CloudFrontOriginAccessId', value=cloudfrontOAI.cloud_front_origin_access_identity_s3_canonical_user_id, export_name='CloudFrontOAI')


app = cdk.App()
MyStaticSiteStack(app, "MyStaticSiteStack", env=cdk.Environment(
  account=os.getenv('CDK_DEFAULT_ACCOUNT'),
  region=os.getenv('CDK_DEFAULT_REGION')))

app.synth()
Ejemplo n.º 8
0
# from aws_cdk import core as cdf
import aws_cdk
from aws_cdk import App

from cdk_ml_cicd_pipeline.cdk_ml_cicd_pipeline_stack import \
    CdkMlCicdPipelineStack

app = App()

resource_prefix = app.node.try_get_context("prefix")
stack_name = resource_prefix + "-MLOps"
account = app.node.try_get_context("account")
region = app.node.try_get_context("region")

env_us_east_1 = aws_cdk.Environment(account=account, region=region)
CdkMlCicdPipelineStack(app, stack_name, env=env_us_east_1)

app.synth()
Ejemplo n.º 9
0
#!/usr/bin/env python3

import aws_cdk as cdk
import os

from sqs_fargate_cdk_python.sqs_fargate_cdk_python_stack import SqsFargateCdkPythonStack

app = cdk.App()
SqsFargateCdkPythonStack(app, "sqs-fargate-cdk-python", env=cdk.Environment(account=os.environ["CDK_DEFAULT_ACCOUNT"],
                                                                            region=os.environ["CDK_DEFAULT_REGION"]))

app.synth()
Ejemplo n.º 10
0
    vpc = aws_ec2.Vpc(self, 'VpcStack',
      max_azs=6
    )

    sg_ssh_access = aws_ec2.SecurityGroup(self, "BastionHostSG",
      vpc=vpc,
      allow_all_outbound=True,
      description='security group for bastion host',
      security_group_name='bastion-host-sg'
    )
    cdk.Tags.of(sg_ssh_access).add('Name', 'bastion-host-sg')
    sg_ssh_access.add_ingress_rule(peer=aws_ec2.Peer.any_ipv4(), connection=aws_ec2.Port.tcp(22), description='ssh access')

    bastion_host = aws_ec2.BastionHostLinux(self, "BastionHost",
      vpc=vpc,
      instance_type=aws_ec2.InstanceType('t3.nano'),
      security_group=sg_ssh_access,
      subnet_selection=aws_ec2.SubnetSelection(subnet_type=aws_ec2.SubnetType.PUBLIC)
    )

    cdk.CfnOutput(self, 'BastionHostId', value=bastion_host.instance_id, export_name='BastionHostId')
    cdk.CfnOutput(self, 'BastionHostPublicDNSName', value=bastion_host.instance_public_dns_name, export_name='BastionHostPublicDNSName')


app = cdk.App()
VpcStack(app, "vpc", env=cdk.Environment(
  account=os.environ["CDK_DEFAULT_ACCOUNT"],
  region=os.environ["CDK_DEFAULT_REGION"]))

app.synth()
Ejemplo n.º 11
0
    docdb_workbench = aws_sagemaker.CfnNotebookInstance(self, 'DocDBWorkbench',
      instance_type='ml.t3.xlarge',
      role_arn=sagemaker_notebook_role.role_arn,
      lifecycle_config_name=docdb_wb_lifecycle_config.notebook_instance_lifecycle_config_name,
      notebook_instance_name='DocDBWorkbench',
      root_access='Disabled',
      security_group_ids=[sg_use_docdb.security_group_id],
      subnet_id=vpc.select_subnets(subnet_type=aws_ec2.SubnetType.PRIVATE_WITH_NAT).subnet_ids[0]
    )

    cdk.CfnOutput(self, 'StackName', value=self.stack_name, export_name='StackName')
    cdk.CfnOutput(self, 'VpcId', value=vpc.vpc_id, export_name='VpcId')

    cdk.CfnOutput(self, 'DocumentDBClusterName', value=docdb_cluster.cluster_identifier, export_name='DocumentDBClusterName')
    cdk.CfnOutput(self, 'DocumentDBCluster', value=docdb_cluster.cluster_endpoint.socket_address, export_name='DocumentDBCluster')
    #XXX: https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_secretsmanager/README.html
    # secret_arn="arn:aws:secretsmanager:<region>:<account-id-number>:secret:<secret-name>-<random-6-characters>",
    cdk.CfnOutput(self, 'DocDBSecret', value=docdb_cluster.secret.secret_name, export_name='DocDBSecret')

    cdk.CfnOutput(self, 'SageMakerRole', value=sagemaker_notebook_role.role_name, export_name='SageMakerRole')
    cdk.CfnOutput(self, 'SageMakerNotebookInstance', value=docdb_workbench.notebook_instance_name, export_name='SageMakerNotebookInstance')
    cdk.CfnOutput(self, 'SageMakerNotebookInstanceLifecycleConfig', value=docdb_workbench.lifecycle_config_name, export_name='SageMakerNotebookInstanceLifecycleConfig')

app = cdk.App()
DocumentdbStack(app, 'AmazonDocDBWithNotebook', env=cdk.Environment(
  account=os.environ['CDK_DEFAULT_ACCOUNT'],
  region=os.environ['CDK_DEFAULT_REGION']))

app.synth()
Ejemplo n.º 12
0
#!/usr/bin/env python3
import aws_cdk as cdk

from infra import Context
from infra.infra_stack import InfraStack
from infra.static_site import create_static_site
from infra.r53_hosted_zone import create_hosted_zone

app = cdk.App()

context = Context(app=app)

stack = InfraStack(
    app,
    f"{context.env_name}-{context.service_name}",
    env=cdk.Environment(account=context.account_id, region=context.aws_region),
    context=context,
)

r53_zone_stack = InfraStack(
    app,
    f'{context.service_name}-hosted-zone-stack',
    env=cdk.Environment(account=context.account_id, region=context.aws_region),
    context=context,
)

zone = create_hosted_zone(r53_zone_stack)

create_static_site(stack, zone)

app.synth()