<jupyter_start><jupyter_text>Credentials to access AWS (__aws_access_key_id__ and __aws_secret_access_key__) are stored in ~/.aws/credentials under [datalord] profile<jupyter_code>session = boto3.Session(profile_name='datalord', region_name='us-east-1')
client = session.client('redshift')<jupyter_output><empty_output><jupyter_text>Update the variables in the cell below. Adjust for your needs.<jupyter_code>cluster_identifier = 'datalord-rs-cluster'
cluster_roles = [
    'arn:aws:iam::...AccountNumber...:role/DataLord-RH-role', # replace ...AccountNumber... with your real one
]
cluster_subnet_group_name = 'datalord-sub-gr'
cluster_subnet_group_descr = 'Datalord Redshift Subnet Group'
cluster_subnet_ids = [
    'subnet-...SubId...', # replace ...SubId... with your real one
]
user_name = 'datalord'
user_password = '<PASSWORD>' # just a sample. Change it!!!<jupyter_output><empty_output><jupyter_text>Create Cluster Subnet GroupDocumentation for [create_cluster_subnet_group](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift.htmlRedshift.Client.create_cluster_subnet_group)<jupyter_code>response = client.create_cluster_subnet_group(
    ClusterSubnetGroupName=cluster_subnet_group_name,
    Description=cluster_subnet_group_descr,
    SubnetIds=cluster_subnet_ids,
)
response['ClusterSubnetGroup']<jupyter_output><empty_output><jupyter_text>Create Redshift clusterDocumentation for [create_cluster](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift.htmlRedshift.Client.create_cluster)<jupyter_code>response = client.create_cluster(
    ClusterIdentifier=cluster_identifier,
    ClusterType='single-node',
    NodeType='dc2.large',
    MasterUsername=user_name,
    MasterUserPassword=<PASSWORD>,
    ClusterSubnetGroupName=cluster_subnet_group_name,
    PubliclyAccessible=True,
    IamRoles=cluster_roles,
)
response['Cluster']<jupyter_output><empty_output><jupyter_text>Run the cell if you want to wait until the cluster is provision and available<jupyter_code>start_time = time.time()
cluster_available_waiter = client.get_waiter('cluster_available')
cluster_available_waiter.wait(ClusterIdentifier=cluster_identifier, 
                                            WaiterConfig={'Delay': 10, 'MaxAttempts': 999}
                             )
print(f'Processing time: {time.time() - start_time} s')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10968009970918155, 'fraction_numerical': 0.004985459077690071, 'mean_word_length': 6.06158357771261, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '185602', 'license': 'MIT', 'n_tokens_mistral': 773, 'n_tokens_neox': 757, 'n_words': 112, 'path': 'AWS/Redshift/create-cluster.ipynb', 'repo_name': 'ttotev/cloudy-with-python', 'size': '2411'}