Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Imtiah01 committed Jan 17, 2025
1 parent ba147f9 commit 9ec1fd9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

app = cdk.App()
LambdaRolePolicyStack(app, "LambdaRolePolicyStack")
# RedshiftRolePolicyStack(app, "RedshiftRolePolicyStack")
RedshiftRolePolicyStack(app, "RedshiftRolePolicyStack")

# If you don't specify 'env', this stack will be environment-agnostic.
# Account/Region-dependent features and context lookups will not work,
Expand Down
62 changes: 29 additions & 33 deletions cdp_cdk_python/redshift_role_policy_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
aws_s3 as s3,
aws_iam as iam,
aws_lambda as _lambda,
# aws_redshiftserverless as redshiftserverless,

aws_redshiftserverless as redshiftserverless
)
import aws_cdk as core
from constructs import Construct

import os
import json
from aws_cdk.cloudformation_include import CfnInclude

from aws_cdk.aws_redshift import
class RedshiftRolePolicyStack(Stack):

def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
Expand Down Expand Up @@ -80,37 +79,37 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
)
)

# # Create Redshift Serverless Namespace
# namespace = redshiftserverless.CfnNamespace(
# self, "RedshiftNamespace",
# namespace_name="my-redshift-namespace",
# admin_username="admin",
# admin_user_password="YourSecurePassword123!", # Use Secrets Manager for production
# iam_roles=[redshift_role.role_arn]
# )
# Create Redshift Serverless Namespace
namespace = redshiftserverless.CfnNamespace(
self, "RedshiftNamespace",
namespace_name="my-redshift-namespace",
admin_username="admin",
admin_user_password="YourSecurePassword123!", # Use Secrets Manager for production
iam_roles=[redshift_role.role_arn]
)

# # Create Redshift Serverless Workgroup
# workgroup = redshiftserverless.CfnWorkgroup(
# self, "RedshiftWorkgroup",
# workgroup_name="my-redshift-workgroup",
# namespace_name=namespace.namespace_name,
# base_capacity=32, # Base capacity in Redshift Processing Units (RPUs)
# publicly_accessible=True,
# subnet_ids=["subnet-xxxxxxx", "subnet-yyyyyyy"], # Replace with actual subnet IDs
# security_group_ids=["sg-zzzzzzzz"] # Replace with actual security group IDs
# )
# Create Redshift Serverless Workgroup
workgroup = redshiftserverless.CfnWorkgroup(
self, "RedshiftWorkgroup",
workgroup_name="my-redshift-workgroup",
namespace_name=namespace.namespace_name,
base_capacity=32, # Base capacity in Redshift Processing Units (RPUs)
publicly_accessible=True,
subnet_ids=["subnet-xxxxxxx", "subnet-yyyyyyy"], # Replace with actual subnet IDs
security_group_ids=["sg-zzzzzzzz"] # Replace with actual security group IDs
)

print('lambda path: %s' % os.path.join(dirname, "./mle-non-pii-redshift-role-template.json"))
print('lambda path: %s' % os.path.join(dirname, "lambda_function.py.zip"))
print('cwd: %s' % cwd)




# core.CfnOutput(
# self,
# "WorkgroupEndpoint",
# value=workgroup.attr_endpoint_address)
core.CfnOutput(
self,
"WorkgroupEndpoint",
value=namespace.namespace_name)
core.CfnOutput(
self,
"WorkgroupEndpoint",
value=workgroup.attr_endpoint_address)
core.CfnOutput(
self,
"RoleArn1",
Expand All @@ -119,7 +118,4 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
self,
"RoleArn2",
value=redshift_role.role_arn)
core.CfnOutput(
self,
"FunctionArn",
value=fn.function_arn)

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
attrs
aws-cdk-lib==2.18.0
aws-cdk.cloud-assembly-schema==2.23.0
aws-cdk-lib==2.176.0
# aws-cdk.cloud-assembly-schema==2.23.0
boto3==1.23.10
botocore==1.26.10

Expand Down

0 comments on commit 9ec1fd9

Please sign in to comment.