-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add redshiftserverless.py module (#2101)
- Add redshiftserverless.py module to support the deployment of Serverless Redshift Workgroups and Namespaces. - Update CONTRIBUTING.md
- Loading branch information
Showing
4 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
from troposphere import Template | ||
from troposphere.redshiftserverless import ConfigParameter, Namespace, Workgroup | ||
|
||
# Redshift serverless cluster variables | ||
admin_username = "{{{{resolve:ssm:/redshift_admin_username}}}}" | ||
admin_password = "{{{{resolve:ssm:/redshift_admin_password}}}}" | ||
default_iam_role_arn = "arn:aws:iam::123456789123:role/service-role/AmazonRedshift-CommandsAccessRole-123451234512345" | ||
default_db_name = "dev" | ||
iam_roles = [] | ||
serverless_namespace_name = "serverless" | ||
tcp_port = 5439 | ||
vpc_id = "vpc-12345678123456789" | ||
subnet_ids = ["subnet-12345678912345678", "subnet-98765432198765432"] | ||
security_group_ids = ["sg-12345123451234567"] | ||
|
||
# Prepare Template | ||
t = Template() | ||
t.set_description("RedshiftServerless: Template and module example") | ||
|
||
RedshiftServerlessNamespace = t.add_resource( | ||
Namespace( | ||
"RedshiftServerlessNamespace", | ||
AdminUsername=admin_username, | ||
AdminUserPassword=admin_password, | ||
DbName=default_db_name, | ||
DefaultIamRoleArn=default_iam_role_arn, | ||
IamRoles=iam_roles, | ||
NamespaceName=serverless_namespace_name, | ||
) | ||
) | ||
|
||
RedshiftServerlessWorkgroup = t.add_resource( | ||
Workgroup( | ||
"RedshiftServerlessWorkgroup", | ||
ConfigParameters=[ | ||
ConfigParameter( | ||
ParameterKey="enable_user_activity_logging", ParameterValue="true" | ||
) | ||
], | ||
EnhancedVpcRouting=True, | ||
NamespaceName=serverless_namespace_name, | ||
PubliclyAccessible=False, | ||
SecurityGroupIds=security_group_ids, | ||
SubnetIds=subnet_ids, | ||
WorkgroupName="RedshiftServerlessWorkgroup", | ||
) | ||
) | ||
|
||
# Output all necessary files with the template and stack_details | ||
print(t.to_json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"Description": "RedshiftServerless: Template and module example", | ||
"Resources": { | ||
"RedshiftServerlessNamespace": { | ||
"Properties": { | ||
"AdminUserPassword": "{{{{resolve:ssm:/redshift_admin_password}}}}", | ||
"AdminUsername": "{{{{resolve:ssm:/redshift_admin_username}}}}", | ||
"DbName": "dev", | ||
"DefaultIamRoleArn": "arn:aws:iam::123456789123:role/service-role/AmazonRedshift-CommandsAccessRole-123451234512345", | ||
"IamRoles": [], | ||
"NamespaceName": "serverless" | ||
}, | ||
"Type": "AWS::RedshiftServerless::Namespace" | ||
}, | ||
"RedshiftServerlessWorkgroup": { | ||
"Properties": { | ||
"ConfigParameters": [ | ||
{ | ||
"ParameterKey": "enable_user_activity_logging", | ||
"ParameterValue": "true" | ||
} | ||
], | ||
"EnhancedVpcRouting": true, | ||
"NamespaceName": "serverless", | ||
"PubliclyAccessible": false, | ||
"SecurityGroupIds": [ | ||
"sg-12345123451234567" | ||
], | ||
"SubnetIds": [ | ||
"subnet-12345678912345678", | ||
"subnet-98765432198765432" | ||
], | ||
"WorkgroupName": "RedshiftServerlessWorkgroup" | ||
}, | ||
"Type": "AWS::RedshiftServerless::Workgroup" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright (c) 2012-2022, Mark Peek <mark@peek.org> | ||
# All rights reserved. | ||
# | ||
# See LICENSE file for full license. | ||
# | ||
# *** Do not modify - this file is autogenerated *** | ||
|
||
|
||
from . import AWSObject, AWSProperty, PropsDictType, Tags | ||
from .validators import boolean, integer | ||
|
||
|
||
class Namespace(AWSObject): | ||
""" | ||
`Namespace <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshiftserverless-namespace.html>`__ | ||
""" | ||
|
||
resource_type = "AWS::RedshiftServerless::Namespace" | ||
|
||
props: PropsDictType = { | ||
"AdminUserPassword": (str, False), | ||
"AdminUsername": (str, False), | ||
"DbName": (str, False), | ||
"DefaultIamRoleArn": (str, False), | ||
"FinalSnapshotName": (str, False), | ||
"FinalSnapshotRetentionPeriod": (integer, False), | ||
"IamRoles": ([str], False), | ||
"KmsKeyId": (str, False), | ||
"LogExports": ([str], False), | ||
"NamespaceName": (str, True), | ||
"Tags": (Tags, False), | ||
} | ||
|
||
|
||
class ConfigParameter(AWSProperty): | ||
""" | ||
`ConfigParameter <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-redshiftserverless-workgroup-configparameter.html>`__ | ||
""" | ||
|
||
props: PropsDictType = { | ||
"ParameterKey": (str, False), | ||
"ParameterValue": (str, False), | ||
} | ||
|
||
|
||
class Workgroup(AWSObject): | ||
""" | ||
`Workgroup <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshiftserverless-workgroup.html>`__ | ||
""" | ||
|
||
resource_type = "AWS::RedshiftServerless::Workgroup" | ||
|
||
props: PropsDictType = { | ||
"BaseCapacity": (integer, False), | ||
"ConfigParameters": ([ConfigParameter], False), | ||
"EnhancedVpcRouting": (boolean, False), | ||
"NamespaceName": (str, False), | ||
"PubliclyAccessible": (boolean, False), | ||
"SecurityGroupIds": ([str], False), | ||
"SubnetIds": ([str], False), | ||
"Tags": (Tags, False), | ||
"WorkgroupName": (str, True), | ||
} |