@aws-cdk/aws-redshift-alpha 2.63.2-alpha.0 → 2.65.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +105 -39
- package/.jsii.tabl.json.gz +0 -0
- package/README.md +64 -5
- package/lib/cluster.d.ts +13 -1
- package/lib/cluster.js +19 -5
- package/lib/database-secret.js +1 -1
- package/lib/endpoint.js +1 -1
- package/lib/parameter-group.js +1 -1
- package/lib/private/database-query-provider/privileges.d.ts +1 -1
- package/lib/private/database-query-provider/privileges.js +1 -1
- package/lib/private/database-query-provider/table.js +9 -1
- package/lib/private/database-query-provider/user.d.ts +1 -1
- package/lib/private/database-query-provider/user.js +1 -1
- package/lib/private/database-query-provider/util.d.ts +1 -1
- package/lib/private/database-query-provider/util.js +1 -1
- package/lib/private/database-query.js +1 -1
- package/lib/private/handler-props.d.ts +1 -0
- package/lib/private/handler-props.js +1 -1
- package/lib/private/privileges.js +2 -2
- package/lib/subnet-group.js +1 -1
- package/lib/table.d.ts +6 -0
- package/lib/table.js +3 -2
- package/lib/user.js +1 -1
- package/package.json +8 -8
package/.jsii
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"url": "https://aws.amazon.com"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"aws-cdk-lib": "^2.
|
|
11
|
+
"aws-cdk-lib": "^2.65.0",
|
|
12
12
|
"constructs": "^10.0.0"
|
|
13
13
|
},
|
|
14
14
|
"dependencyClosure": {
|
|
@@ -2251,6 +2251,19 @@
|
|
|
2251
2251
|
}
|
|
2252
2252
|
}
|
|
2253
2253
|
},
|
|
2254
|
+
"aws-cdk-lib.aws_omics": {
|
|
2255
|
+
"targets": {
|
|
2256
|
+
"dotnet": {
|
|
2257
|
+
"namespace": "Amazon.CDK.AWS.Omics"
|
|
2258
|
+
},
|
|
2259
|
+
"java": {
|
|
2260
|
+
"package": "software.amazon.awscdk.services.omics"
|
|
2261
|
+
},
|
|
2262
|
+
"python": {
|
|
2263
|
+
"module": "aws_cdk.aws_omics"
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
},
|
|
2254
2267
|
"aws-cdk-lib.aws_opensearchserverless": {
|
|
2255
2268
|
"targets": {
|
|
2256
2269
|
"dotnet": {
|
|
@@ -2875,6 +2888,19 @@
|
|
|
2875
2888
|
}
|
|
2876
2889
|
}
|
|
2877
2890
|
},
|
|
2891
|
+
"aws-cdk-lib.aws_simspaceweaver": {
|
|
2892
|
+
"targets": {
|
|
2893
|
+
"dotnet": {
|
|
2894
|
+
"namespace": "Amazon.CDK.AWS.SimSpaceWeaver"
|
|
2895
|
+
},
|
|
2896
|
+
"java": {
|
|
2897
|
+
"package": "software.amazon.awscdk.services.simspaceweaver"
|
|
2898
|
+
},
|
|
2899
|
+
"python": {
|
|
2900
|
+
"module": "aws_cdk.aws_simspaceweaver"
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
},
|
|
2878
2904
|
"aws-cdk-lib.aws_sns": {
|
|
2879
2905
|
"targets": {
|
|
2880
2906
|
"dotnet": {
|
|
@@ -3344,7 +3370,7 @@
|
|
|
3344
3370
|
},
|
|
3345
3371
|
"name": "@aws-cdk/aws-redshift-alpha",
|
|
3346
3372
|
"readme": {
|
|
3347
|
-
"markdown": "# Amazon Redshift Construct Library\n<!--BEGIN STABILITY BANNER-->\n\n---\n\n\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n\n<!--END STABILITY BANNER-->\n\n## Starting a Redshift Cluster Database\n\nTo set up a Redshift cluster, define a `Cluster`. It will be launched in a VPC.\nYou can specify a VPC, otherwise one will be created. The nodes are always launched in private subnets and are encrypted by default.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\n\nconst vpc = new ec2.Vpc(this, 'Vpc');\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc\n});\n```\n\nBy default, the master password will be generated and stored in AWS Secrets Manager.\n\nA default database named `default_db` will be created in the cluster. To change the name of this database set the `defaultDatabaseName` attribute in the constructor properties.\n\nBy default, the cluster will not be publicly accessible.\nDepending on your use case, you can make the cluster publicly accessible with the `publiclyAccessible` property.\n\n## Adding a logging bucket for database audit logging to S3\n\nAmazon Redshift logs information about connections and user activities in your database. These logs help you to monitor the database for security and troubleshooting purposes, a process called database auditing. To send these logs to an S3 bucket, specify the `loggingProperties` when creating a new cluster.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as s3 from 'aws-cdk-lib/aws-s3';\n\nconst vpc = new ec2.Vpc(this, 'Vpc');\nconst bucket = s3.Bucket.fromBucketName(stack, 'bucket', 'logging-bucket');\n\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n loggingProperties: {\n loggingBucket = bucket,\n loggingKeyPrefix: 'prefix',\n }\n});\n```\n\n## Connecting\n\nTo control who can access the cluster, use the `.connections` attribute. Redshift Clusters have\na default port, so you don't need to specify the port:\n\n```ts fixture=cluster\ncluster.connections.allowDefaultPortFromAnyIpv4('Open to the world');\n```\n\nThe endpoint to access your database cluster will be available as the `.clusterEndpoint` attribute:\n\n```ts fixture=cluster\ncluster.clusterEndpoint.socketAddress; // \"HOSTNAME:PORT\"\n```\n\n## Database Resources\n\nThis module allows for the creation of non-CloudFormation database resources such as users\nand tables. This allows you to manage identities, permissions, and stateful resources\nwithin your Redshift cluster from your CDK application.\n\nBecause these resources are not available in CloudFormation, this library leverages\n[custom\nresources](https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html)\nto manage them. In addition to the IAM permissions required to make Redshift service\ncalls, the execution role for the custom resource handler requires database credentials to\ncreate resources within the cluster.\n\nThese database credentials can be supplied explicitly through the `adminUser` properties\nof the various database resource constructs. Alternatively, the credentials can be\nautomatically pulled from the Redshift cluster's default administrator\ncredentials. However, this option is only available if the password for the credentials\nwas generated by the CDK application (ie., no value vas provided for [the `masterPassword`\nproperty](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-redshift.Login.html#masterpasswordspan-classapi-icon-api-icon-experimental-titlethis-api-element-is-experimental-it-may-change-without-noticespan)\nof\n[`Cluster.masterUser`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-redshift.Cluster.html#masteruserspan-classapi-icon-api-icon-experimental-titlethis-api-element-is-experimental-it-may-change-without-noticespan)).\n\n### Creating Users\n\nCreate a user within a Redshift cluster database by instantiating a `User` construct. This\nwill generate a username and password, store the credentials in a [AWS Secrets Manager\n`Secret`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-secretsmanager.Secret.html),\nand make a query to the Redshift cluster to create a new database user with the\ncredentials.\n\n```ts fixture=cluster\nnew User(this, 'User', {\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nBy default, the user credentials are encrypted with your AWS account's default Secrets\nManager encryption key. You can specify the encryption key used for this purpose by\nsupplying a key in the `encryptionKey` property.\n\n```ts fixture=cluster\nimport * as kms from 'aws-cdk-lib/aws-kms';\n\nconst encryptionKey = new kms.Key(this, 'Key');\nnew User(this, 'User', {\n encryptionKey: encryptionKey,\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nBy default, a username is automatically generated from the user construct ID and its path\nin the construct tree. You can specify a particular username by providing a value for the\n`username` property. Usernames must be valid identifiers; see: [Names and\nidentifiers](https://docs.aws.amazon.com/redshift/latest/dg/r_names.html) in the *Amazon\nRedshift Database Developer Guide*.\n\n```ts fixture=cluster\nnew User(this, 'User', {\n username: 'myuser',\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nThe user password is generated by AWS Secrets Manager using the default configuration\nfound in\n[`secretsmanager.SecretStringGenerator`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-secretsmanager.SecretStringGenerator.html),\nexcept with password length `30` and some SQL-incompliant characters excluded. The\nplaintext for the password will never be present in the CDK application; instead, a\n[CloudFormation Dynamic\nReference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)\nwill be used wherever the password value is required.\n\n### Creating Tables\n\nCreate a table within a Redshift cluster database by instantiating a `Table`\nconstruct. This will make a query to the Redshift cluster to create a new database table\nwith the supplied schema.\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nThe table can be configured to have distStyle attribute and a distKey column:\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [\n { name: 'col1', dataType: 'varchar(4)', distKey: true },\n { name: 'col2', dataType: 'float' },\n ],\n cluster: cluster,\n databaseName: 'databaseName',\n distStyle: TableDistStyle.KEY,\n});\n```\n\nThe table can also be configured to have sortStyle attribute and sortKey columns:\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [\n { name: 'col1', dataType: 'varchar(4)', sortKey: true },\n { name: 'col2', dataType: 'float', sortKey: true },\n ],\n cluster: cluster,\n databaseName: 'databaseName',\n sortStyle: TableSortStyle.COMPOUND,\n});\n```\n\n### Granting Privileges\n\nYou can give a user privileges to perform certain actions on a table by using the\n`Table.grant()` method.\n\n```ts fixture=cluster\nconst user = new User(this, 'User', {\n cluster: cluster,\n databaseName: 'databaseName',\n});\nconst table = new Table(this, 'Table', {\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: 'databaseName',\n});\n\ntable.grant(user, TableAction.DROP, TableAction.SELECT);\n```\n\nTake care when managing privileges via the CDK, as attempting to manage a user's\nprivileges on the same table in multiple CDK applications could lead to accidentally\noverriding these permissions. Consider the following two CDK applications which both refer\nto the same user and table. In application 1, the resources are created and the user is\ngiven `INSERT` permissions on the table:\n\n```ts fixture=cluster\nconst databaseName = 'databaseName';\nconst username = 'myuser'\nconst tableName = 'mytable'\n\nconst user = new User(this, 'User', {\n username: username,\n cluster: cluster,\n databaseName: databaseName,\n});\nconst table = new Table(this, 'Table', {\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: databaseName,\n});\ntable.grant(user, TableAction.INSERT);\n```\n\nIn application 2, the resources are imported and the user is given `INSERT` permissions on\nthe table:\n\n```ts fixture=cluster\nconst databaseName = 'databaseName';\nconst username = 'myuser'\nconst tableName = 'mytable'\n\nconst user = User.fromUserAttributes(this, 'User', {\n username: username,\n password: SecretValue.unsafePlainText('NOT_FOR_PRODUCTION'),\n cluster: cluster,\n databaseName: databaseName,\n});\nconst table = Table.fromTableAttributes(this, 'Table', {\n tableName: tableName,\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: 'databaseName',\n});\ntable.grant(user, TableAction.INSERT);\n```\n\nBoth applications attempt to grant the user the appropriate privilege on the table by\nsubmitting a `GRANT USER` SQL query to the Redshift cluster. Note that the latter of these\ntwo calls will have no effect since the user has already been granted the privilege.\n\nNow, if application 1 were to remove the call to `grant`, a `REVOKE USER` SQL query is\nsubmitted to the Redshift cluster. In general, application 1 does not know that\napplication 2 has also granted this permission and thus cannot decide not to issue the\nrevocation. This leads to the undesirable state where application 2 still contains the\ncall to `grant` but the user does not have the specified permission.\n\nNote that this does not occur when duplicate privileges are granted within the same\napplication, as such privileges are de-duplicated before any SQL query is submitted.\n\n## Rotating credentials\n\nWhen the master password is generated and stored in AWS Secrets Manager, it can be rotated automatically:\n\n```ts fixture=cluster\ncluster.addRotationSingleUser(); // Will rotate automatically after 30 days\n```\n\nThe multi user rotation scheme is also available:\n\n```ts fixture=cluster\n\nconst user = new User(this, 'User', {\n cluster: cluster,\n databaseName: 'databaseName',\n});\ncluster.addRotationMultiUser('MultiUserRotation', {\n secret: user.secret,\n});\n```\n\n## Adding Parameters\n\nYou can add a parameter to a parameter group with`ClusterParameterGroup.addParameter()`.\n\n```ts\nconst params = new ClusterParameterGroup(stack, 'Params', {\n description: 'desc',\n parameters: {\n require_ssl: 'true',\n },\n});\n\nparams.addParameter('enable_user_activity_logging', 'true');\n```\n\nAdditionally, you can add a parameter to the cluster's associated parameter group with `Cluster.addToParameterGroup()`. If the cluster does not have an associated parameter group, a new parameter group is created.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nconst cluster = new Cluster(this, 'Cluster', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n});\n\ncluster.addToParameterGroup('enable_user_activity_logging', 'true');\n```\n\n## Elastic IP\n\nIf you configure your cluster to be publicly accessible, you can optionally select an *elastic IP address* to use for the external IP address. An elastic IP address is a static IP address that is associated with your AWS account. You can use an elastic IP address to connect to your cluster from outside the VPC. An elastic IP address gives you the ability to change your underlying configuration without affecting the IP address that clients use to connect to your cluster. This approach can be helpful for situations such as recovery after a failure.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nnew Cluster(stack, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n publiclyAccessible: true,\n elasticIp: '10.123.123.255', // A elastic ip you own\n})\n```\n\nIf the Cluster is in a VPC and you want to connect to it using the private IP address from within the cluster, it is important to enable *DNS resolution* and *DNS hostnames* in the VPC config. If these parameters would not be set, connections from within the VPC would connect to the elastic IP address and not the private IP address.\n\n```ts\nconst vpc = new ec2.Vpc(this, 'VPC', {\n enableDnsSupport: true,\n enableDnsHostnames: true,\n});\n```\n\nNote that if there is already an existing, public accessible Cluster, which VPC configuration is changed to use *DNS hostnames* and *DNS resolution*, connections still use the elastic IP address until the cluster is resized.\n\n### Elastic IP vs. Cluster node public IP\n\nThe elastic IP address is an external IP address for accessing the cluster outside of a VPC. It's not related to the cluster node public IP addresses and private IP addresses that are accessible via the `clusterEndpoint` property. The public and private cluster node IP addresses appear regardless of whether the cluster is publicly accessible or not. They are used only in certain circumstances to configure ingress rules on the remote host. These circumstances occur when you load data from an Amazon EC2 instance or other remote host using a Secure Shell (SSH) connection.\n\n### Attach Elastic IP after Cluster creation\n\nIn some cases, you might want to associate the cluster with an elastic IP address or change an elastic IP address that is associated with the cluster. To attach an elastic IP address after the cluster is created, first update the cluster so that it is not publicly accessible, then make it both publicly accessible and add an Elastic IP address in the same operation.\n\n## Enhanced VPC Routing\n\nWhen you use Amazon Redshift enhanced VPC routing, Amazon Redshift forces all COPY and UNLOAD traffic between your cluster and your data repositories through your virtual private cloud (VPC) based on the Amazon VPC service. By using enhanced VPC routing, you can use standard VPC features, such as VPC security groups, network access control lists (ACLs), VPC endpoints, VPC endpoint policies, internet gateways, and Domain Name System (DNS) servers, as described in the Amazon VPC User Guide. You use these features to tightly manage the flow of data between your Amazon Redshift cluster and other resources. When you use enhanced VPC routing to route traffic through your VPC, you can also use VPC flow logs to monitor COPY and UNLOAD traffic.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nnew Cluster(stack, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n enhancedVpcRouting: true,\n})\n```\n\nIf enhanced VPC routing is not enabled, Amazon Redshift routes traffic through the internet, including traffic to other services within the AWS network.\n\n## Default IAM role\n\nSome Amazon Redshift features require Amazon Redshift to access other AWS services on your behalf. For your Amazon Redshift clusters to act on your behalf, you supply security credentials to your clusters. The preferred method to supply security credentials is to specify an AWS Identity and Access Management (IAM) role.\n\nWhen you create an IAM role and set it as the default for the cluster using console, you don't have to provide the IAM role's Amazon Resource Name (ARN) to perform authentication and authorization.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nconst defaultRole = new iam.Role(this, 'DefaultRole', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n},\n);\n\nnew Cluster(stack, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [defaultRole],\n defaultRole: defaultRole,\n});\n```\n\nA default role can also be added to a cluster using the `addDefaultIamRole` method.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nconst defaultRole = new iam.Role(this, 'DefaultRole', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n},\n);\n\nconst redshiftCluster = new Cluster(stack, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [defaultRole],\n});\n\nredshiftCluster.addDefaultIamRole(defaultRole);\n```\n"
|
|
3373
|
+
"markdown": "# Amazon Redshift Construct Library\n<!--BEGIN STABILITY BANNER-->\n\n---\n\n\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n\n<!--END STABILITY BANNER-->\n\n## Starting a Redshift Cluster Database\n\nTo set up a Redshift cluster, define a `Cluster`. It will be launched in a VPC.\nYou can specify a VPC, otherwise one will be created. The nodes are always launched in private subnets and are encrypted by default.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\n\nconst vpc = new ec2.Vpc(this, 'Vpc');\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc\n});\n```\n\nBy default, the master password will be generated and stored in AWS Secrets Manager.\n\nA default database named `default_db` will be created in the cluster. To change the name of this database set the `defaultDatabaseName` attribute in the constructor properties.\n\nBy default, the cluster will not be publicly accessible.\nDepending on your use case, you can make the cluster publicly accessible with the `publiclyAccessible` property.\n\n## Adding a logging bucket for database audit logging to S3\n\nAmazon Redshift logs information about connections and user activities in your database. These logs help you to monitor the database for security and troubleshooting purposes, a process called database auditing. To send these logs to an S3 bucket, specify the `loggingProperties` when creating a new cluster.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as s3 from 'aws-cdk-lib/aws-s3';\n\nconst vpc = new ec2.Vpc(this, 'Vpc');\nconst bucket = s3.Bucket.fromBucketName(this, 'bucket', 'logging-bucket');\n\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n loggingProperties: {\n loggingBucket: bucket,\n loggingKeyPrefix: 'prefix',\n }\n});\n```\n\n## Connecting\n\nTo control who can access the cluster, use the `.connections` attribute. Redshift Clusters have\na default port, so you don't need to specify the port:\n\n```ts fixture=cluster\ncluster.connections.allowDefaultPortFromAnyIpv4('Open to the world');\n```\n\nThe endpoint to access your database cluster will be available as the `.clusterEndpoint` attribute:\n\n```ts fixture=cluster\ncluster.clusterEndpoint.socketAddress; // \"HOSTNAME:PORT\"\n```\n\n## Database Resources\n\nThis module allows for the creation of non-CloudFormation database resources such as users\nand tables. This allows you to manage identities, permissions, and stateful resources\nwithin your Redshift cluster from your CDK application.\n\nBecause these resources are not available in CloudFormation, this library leverages\n[custom\nresources](https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html)\nto manage them. In addition to the IAM permissions required to make Redshift service\ncalls, the execution role for the custom resource handler requires database credentials to\ncreate resources within the cluster.\n\nThese database credentials can be supplied explicitly through the `adminUser` properties\nof the various database resource constructs. Alternatively, the credentials can be\nautomatically pulled from the Redshift cluster's default administrator\ncredentials. However, this option is only available if the password for the credentials\nwas generated by the CDK application (ie., no value vas provided for [the `masterPassword`\nproperty](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-redshift.Login.html#masterpasswordspan-classapi-icon-api-icon-experimental-titlethis-api-element-is-experimental-it-may-change-without-noticespan)\nof\n[`Cluster.masterUser`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-redshift.Cluster.html#masteruserspan-classapi-icon-api-icon-experimental-titlethis-api-element-is-experimental-it-may-change-without-noticespan)).\n\n### Creating Users\n\nCreate a user within a Redshift cluster database by instantiating a `User` construct. This\nwill generate a username and password, store the credentials in a [AWS Secrets Manager\n`Secret`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-secretsmanager.Secret.html),\nand make a query to the Redshift cluster to create a new database user with the\ncredentials.\n\n```ts fixture=cluster\nnew User(this, 'User', {\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nBy default, the user credentials are encrypted with your AWS account's default Secrets\nManager encryption key. You can specify the encryption key used for this purpose by\nsupplying a key in the `encryptionKey` property.\n\n```ts fixture=cluster\nimport * as kms from 'aws-cdk-lib/aws-kms';\n\nconst encryptionKey = new kms.Key(this, 'Key');\nnew User(this, 'User', {\n encryptionKey: encryptionKey,\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nBy default, a username is automatically generated from the user construct ID and its path\nin the construct tree. You can specify a particular username by providing a value for the\n`username` property. Usernames must be valid identifiers; see: [Names and\nidentifiers](https://docs.aws.amazon.com/redshift/latest/dg/r_names.html) in the *Amazon\nRedshift Database Developer Guide*.\n\n```ts fixture=cluster\nnew User(this, 'User', {\n username: 'myuser',\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nThe user password is generated by AWS Secrets Manager using the default configuration\nfound in\n[`secretsmanager.SecretStringGenerator`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-secretsmanager.SecretStringGenerator.html),\nexcept with password length `30` and some SQL-incompliant characters excluded. The\nplaintext for the password will never be present in the CDK application; instead, a\n[CloudFormation Dynamic\nReference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)\nwill be used wherever the password value is required.\n\n### Creating Tables\n\nCreate a table within a Redshift cluster database by instantiating a `Table`\nconstruct. This will make a query to the Redshift cluster to create a new database table\nwith the supplied schema.\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: 'databaseName',\n});\n```\n\nThe table can be configured to have distStyle attribute and a distKey column:\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [\n { name: 'col1', dataType: 'varchar(4)', distKey: true },\n { name: 'col2', dataType: 'float' },\n ],\n cluster: cluster,\n databaseName: 'databaseName',\n distStyle: TableDistStyle.KEY,\n});\n```\n\nThe table can also be configured to have sortStyle attribute and sortKey columns:\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [\n { name: 'col1', dataType: 'varchar(4)', sortKey: true },\n { name: 'col2', dataType: 'float', sortKey: true },\n ],\n cluster: cluster,\n databaseName: 'databaseName',\n sortStyle: TableSortStyle.COMPOUND,\n});\n```\n\nTables can also be configured with a comment:\n\n```ts fixture=cluster\nnew Table(this, 'Table', {\n tableColumns: [\n { name: 'col1', dataType: 'varchar(4)' },\n { name: 'col2', dataType: 'float' }\n ],\n cluster: cluster,\n databaseName: 'databaseName',\n comment: 'This is a comment',\n});\n```\n\n### Granting Privileges\n\nYou can give a user privileges to perform certain actions on a table by using the\n`Table.grant()` method.\n\n```ts fixture=cluster\nconst user = new User(this, 'User', {\n cluster: cluster,\n databaseName: 'databaseName',\n});\nconst table = new Table(this, 'Table', {\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: 'databaseName',\n});\n\ntable.grant(user, TableAction.DROP, TableAction.SELECT);\n```\n\nTake care when managing privileges via the CDK, as attempting to manage a user's\nprivileges on the same table in multiple CDK applications could lead to accidentally\noverriding these permissions. Consider the following two CDK applications which both refer\nto the same user and table. In application 1, the resources are created and the user is\ngiven `INSERT` permissions on the table:\n\n```ts fixture=cluster\nconst databaseName = 'databaseName';\nconst username = 'myuser'\nconst tableName = 'mytable'\n\nconst user = new User(this, 'User', {\n username: username,\n cluster: cluster,\n databaseName: databaseName,\n});\nconst table = new Table(this, 'Table', {\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: databaseName,\n});\ntable.grant(user, TableAction.INSERT);\n```\n\nIn application 2, the resources are imported and the user is given `INSERT` permissions on\nthe table:\n\n```ts fixture=cluster\nconst databaseName = 'databaseName';\nconst username = 'myuser'\nconst tableName = 'mytable'\n\nconst user = User.fromUserAttributes(this, 'User', {\n username: username,\n password: SecretValue.unsafePlainText('NOT_FOR_PRODUCTION'),\n cluster: cluster,\n databaseName: databaseName,\n});\nconst table = Table.fromTableAttributes(this, 'Table', {\n tableName: tableName,\n tableColumns: [{ name: 'col1', dataType: 'varchar(4)' }, { name: 'col2', dataType: 'float' }],\n cluster: cluster,\n databaseName: 'databaseName',\n});\ntable.grant(user, TableAction.INSERT);\n```\n\nBoth applications attempt to grant the user the appropriate privilege on the table by\nsubmitting a `GRANT USER` SQL query to the Redshift cluster. Note that the latter of these\ntwo calls will have no effect since the user has already been granted the privilege.\n\nNow, if application 1 were to remove the call to `grant`, a `REVOKE USER` SQL query is\nsubmitted to the Redshift cluster. In general, application 1 does not know that\napplication 2 has also granted this permission and thus cannot decide not to issue the\nrevocation. This leads to the undesirable state where application 2 still contains the\ncall to `grant` but the user does not have the specified permission.\n\nNote that this does not occur when duplicate privileges are granted within the same\napplication, as such privileges are de-duplicated before any SQL query is submitted.\n\n## Rotating credentials\n\nWhen the master password is generated and stored in AWS Secrets Manager, it can be rotated automatically:\n\n```ts fixture=cluster\ncluster.addRotationSingleUser(); // Will rotate automatically after 30 days\n```\n\nThe multi user rotation scheme is also available:\n\n```ts fixture=cluster\n\nconst user = new User(this, 'User', {\n cluster: cluster,\n databaseName: 'databaseName',\n});\ncluster.addRotationMultiUser('MultiUserRotation', {\n secret: user.secret,\n});\n```\n\n## Adding Parameters\n\nYou can add a parameter to a parameter group with`ClusterParameterGroup.addParameter()`.\n\n```ts\nimport { ClusterParameterGroup } from '@aws-cdk/aws-redshift-alpha';\n\nconst params = new ClusterParameterGroup(this, 'Params', {\n description: 'desc',\n parameters: {\n require_ssl: 'true',\n },\n});\n\nparams.addParameter('enable_user_activity_logging', 'true');\n```\n\nAdditionally, you can add a parameter to the cluster's associated parameter group with `Cluster.addToParameterGroup()`. If the cluster does not have an associated parameter group, a new parameter group is created.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as cdk from 'aws-cdk-lib';\ndeclare const vpc: ec2.Vpc;\n\nconst cluster = new Cluster(this, 'Cluster', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n});\n\ncluster.addToParameterGroup('enable_user_activity_logging', 'true');\n```\n\n## Elastic IP\n\nIf you configure your cluster to be publicly accessible, you can optionally select an *elastic IP address* to use for the external IP address. An elastic IP address is a static IP address that is associated with your AWS account. You can use an elastic IP address to connect to your cluster from outside the VPC. An elastic IP address gives you the ability to change your underlying configuration without affecting the IP address that clients use to connect to your cluster. This approach can be helpful for situations such as recovery after a failure.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as cdk from 'aws-cdk-lib';\ndeclare const vpc: ec2.Vpc;\n\nnew Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n publiclyAccessible: true,\n elasticIp: '10.123.123.255', // A elastic ip you own\n})\n```\n\nIf the Cluster is in a VPC and you want to connect to it using the private IP address from within the cluster, it is important to enable *DNS resolution* and *DNS hostnames* in the VPC config. If these parameters would not be set, connections from within the VPC would connect to the elastic IP address and not the private IP address.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nconst vpc = new ec2.Vpc(this, 'VPC', {\n enableDnsSupport: true,\n enableDnsHostnames: true,\n});\n```\n\nNote that if there is already an existing, public accessible Cluster, which VPC configuration is changed to use *DNS hostnames* and *DNS resolution*, connections still use the elastic IP address until the cluster is resized.\n\n### Elastic IP vs. Cluster node public IP\n\nThe elastic IP address is an external IP address for accessing the cluster outside of a VPC. It's not related to the cluster node public IP addresses and private IP addresses that are accessible via the `clusterEndpoint` property. The public and private cluster node IP addresses appear regardless of whether the cluster is publicly accessible or not. They are used only in certain circumstances to configure ingress rules on the remote host. These circumstances occur when you load data from an Amazon EC2 instance or other remote host using a Secure Shell (SSH) connection.\n\n### Attach Elastic IP after Cluster creation\n\nIn some cases, you might want to associate the cluster with an elastic IP address or change an elastic IP address that is associated with the cluster. To attach an elastic IP address after the cluster is created, first update the cluster so that it is not publicly accessible, then make it both publicly accessible and add an Elastic IP address in the same operation.\n\n## Enhanced VPC Routing\n\nWhen you use Amazon Redshift enhanced VPC routing, Amazon Redshift forces all COPY and UNLOAD traffic between your cluster and your data repositories through your virtual private cloud (VPC) based on the Amazon VPC service. By using enhanced VPC routing, you can use standard VPC features, such as VPC security groups, network access control lists (ACLs), VPC endpoints, VPC endpoint policies, internet gateways, and Domain Name System (DNS) servers, as described in the Amazon VPC User Guide. You use these features to tightly manage the flow of data between your Amazon Redshift cluster and other resources. When you use enhanced VPC routing to route traffic through your VPC, you can also use VPC flow logs to monitor COPY and UNLOAD traffic.\n\n```ts\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as cdk from 'aws-cdk-lib';\ndeclare const vpc: ec2.Vpc;\n\nnew Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n enhancedVpcRouting: true,\n})\n```\n\nIf enhanced VPC routing is not enabled, Amazon Redshift routes traffic through the internet, including traffic to other services within the AWS network.\n\n## Default IAM role\n\nSome Amazon Redshift features require Amazon Redshift to access other AWS services on your behalf. For your Amazon Redshift clusters to act on your behalf, you supply security credentials to your clusters. The preferred method to supply security credentials is to specify an AWS Identity and Access Management (IAM) role.\n\nWhen you create an IAM role and set it as the default for the cluster using console, you don't have to provide the IAM role's Amazon Resource Name (ARN) to perform authentication and authorization.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nconst defaultRole = new iam.Role(this, 'DefaultRole', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n},\n);\n\nnew Cluster(stack, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [defaultRole],\n defaultRole: defaultRole,\n});\n```\n\nA default role can also be added to a cluster using the `addDefaultIamRole` method.\n\n```ts\ndeclare const vpc: ec2.Vpc;\n\nconst defaultRole = new iam.Role(this, 'DefaultRole', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n},\n);\n\nconst redshiftCluster = new Cluster(stack, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [defaultRole],\n});\n\nredshiftCluster.addDefaultIamRole(defaultRole);\n```\n\n## IAM roles\n\nAttaching IAM roles to a Redshift Cluster grants permissions to the Redshift service to perform actions on your behalf.\n\n```ts\ndeclare const vpc: ec2.Vpc\n\nconst role = new iam.Role(this, 'Role', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n});\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [role],\n});\n```\n\nAdditional IAM roles can be attached to a cluster using the `addIamRole` method.\n\n```ts\ndeclare const vpc: ec2.Vpc\n\nconst role = new iam.Role(this, 'Role', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n});\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n});\ncluster.addIamRole(role);\n```\n"
|
|
3348
3374
|
},
|
|
3349
3375
|
"repository": {
|
|
3350
3376
|
"directory": "packages/individual-packages/aws-redshift",
|
|
@@ -3392,7 +3418,7 @@
|
|
|
3392
3418
|
},
|
|
3393
3419
|
"stability": "experimental",
|
|
3394
3420
|
"summary": "Create a Redshift cluster a given number of nodes.",
|
|
3395
|
-
"example": "declare const vpc: ec2.Vpc
|
|
3421
|
+
"example": "declare const vpc: ec2.Vpc\n\nconst role = new iam.Role(this, 'Role', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n});\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [role],\n});"
|
|
3396
3422
|
},
|
|
3397
3423
|
"fqn": "@aws-cdk/aws-redshift-alpha.Cluster",
|
|
3398
3424
|
"initializer": {
|
|
@@ -3401,7 +3427,7 @@
|
|
|
3401
3427
|
},
|
|
3402
3428
|
"locationInModule": {
|
|
3403
3429
|
"filename": "lib/cluster.ts",
|
|
3404
|
-
"line":
|
|
3430
|
+
"line": 480
|
|
3405
3431
|
},
|
|
3406
3432
|
"parameters": [
|
|
3407
3433
|
{
|
|
@@ -3478,7 +3504,7 @@
|
|
|
3478
3504
|
},
|
|
3479
3505
|
"locationInModule": {
|
|
3480
3506
|
"filename": "lib/cluster.ts",
|
|
3481
|
-
"line":
|
|
3507
|
+
"line": 697
|
|
3482
3508
|
},
|
|
3483
3509
|
"name": "addDefaultIamRole",
|
|
3484
3510
|
"parameters": [
|
|
@@ -3493,6 +3519,28 @@
|
|
|
3493
3519
|
}
|
|
3494
3520
|
]
|
|
3495
3521
|
},
|
|
3522
|
+
{
|
|
3523
|
+
"docs": {
|
|
3524
|
+
"stability": "experimental",
|
|
3525
|
+
"summary": "Adds a role to the cluster."
|
|
3526
|
+
},
|
|
3527
|
+
"locationInModule": {
|
|
3528
|
+
"filename": "lib/cluster.ts",
|
|
3529
|
+
"line": 751
|
|
3530
|
+
},
|
|
3531
|
+
"name": "addIamRole",
|
|
3532
|
+
"parameters": [
|
|
3533
|
+
{
|
|
3534
|
+
"docs": {
|
|
3535
|
+
"summary": "the role to add."
|
|
3536
|
+
},
|
|
3537
|
+
"name": "role",
|
|
3538
|
+
"type": {
|
|
3539
|
+
"fqn": "aws-cdk-lib.aws_iam.IRole"
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
]
|
|
3543
|
+
},
|
|
3496
3544
|
{
|
|
3497
3545
|
"docs": {
|
|
3498
3546
|
"stability": "experimental",
|
|
@@ -3500,7 +3548,7 @@
|
|
|
3500
3548
|
},
|
|
3501
3549
|
"locationInModule": {
|
|
3502
3550
|
"filename": "lib/cluster.ts",
|
|
3503
|
-
"line":
|
|
3551
|
+
"line": 636
|
|
3504
3552
|
},
|
|
3505
3553
|
"name": "addRotationMultiUser",
|
|
3506
3554
|
"parameters": [
|
|
@@ -3530,7 +3578,7 @@
|
|
|
3530
3578
|
},
|
|
3531
3579
|
"locationInModule": {
|
|
3532
3580
|
"filename": "lib/cluster.ts",
|
|
3533
|
-
"line":
|
|
3581
|
+
"line": 612
|
|
3534
3582
|
},
|
|
3535
3583
|
"name": "addRotationSingleUser",
|
|
3536
3584
|
"parameters": [
|
|
@@ -3558,7 +3606,7 @@
|
|
|
3558
3606
|
},
|
|
3559
3607
|
"locationInModule": {
|
|
3560
3608
|
"filename": "lib/cluster.ts",
|
|
3561
|
-
"line":
|
|
3609
|
+
"line": 676
|
|
3562
3610
|
},
|
|
3563
3611
|
"name": "addToParameterGroup",
|
|
3564
3612
|
"parameters": [
|
|
@@ -3784,11 +3832,11 @@
|
|
|
3784
3832
|
"docs": {
|
|
3785
3833
|
"custom": {
|
|
3786
3834
|
"resource": "AWS::Redshift::ClusterParameterGroup",
|
|
3787
|
-
"exampleMetadata": "
|
|
3835
|
+
"exampleMetadata": "infused"
|
|
3788
3836
|
},
|
|
3789
3837
|
"stability": "experimental",
|
|
3790
3838
|
"summary": "A cluster parameter group.",
|
|
3791
|
-
"example": "
|
|
3839
|
+
"example": "import { ClusterParameterGroup } from '@aws-cdk/aws-redshift-alpha';\n\nconst params = new ClusterParameterGroup(this, 'Params', {\n description: 'desc',\n parameters: {\n require_ssl: 'true',\n },\n});\n\nparams.addParameter('enable_user_activity_logging', 'true');"
|
|
3792
3840
|
},
|
|
3793
3841
|
"fqn": "@aws-cdk/aws-redshift-alpha.ClusterParameterGroup",
|
|
3794
3842
|
"initializer": {
|
|
@@ -3945,9 +3993,9 @@
|
|
|
3945
3993
|
"docs": {
|
|
3946
3994
|
"stability": "experimental",
|
|
3947
3995
|
"summary": "Properties for a parameter group.",
|
|
3948
|
-
"example": "
|
|
3996
|
+
"example": "import { ClusterParameterGroup } from '@aws-cdk/aws-redshift-alpha';\n\nconst params = new ClusterParameterGroup(this, 'Params', {\n description: 'desc',\n parameters: {\n require_ssl: 'true',\n },\n});\n\nparams.addParameter('enable_user_activity_logging', 'true');",
|
|
3949
3997
|
"custom": {
|
|
3950
|
-
"exampleMetadata": "
|
|
3998
|
+
"exampleMetadata": "infused"
|
|
3951
3999
|
}
|
|
3952
4000
|
},
|
|
3953
4001
|
"fqn": "@aws-cdk/aws-redshift-alpha.ClusterParameterGroupProps",
|
|
@@ -4006,7 +4054,7 @@
|
|
|
4006
4054
|
"docs": {
|
|
4007
4055
|
"stability": "experimental",
|
|
4008
4056
|
"summary": "Properties for a new database cluster.",
|
|
4009
|
-
"example": "declare const vpc: ec2.Vpc
|
|
4057
|
+
"example": "declare const vpc: ec2.Vpc\n\nconst role = new iam.Role(this, 'Role', {\n assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),\n});\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n roles: [role],\n});",
|
|
4010
4058
|
"custom": {
|
|
4011
4059
|
"exampleMetadata": "infused"
|
|
4012
4060
|
}
|
|
@@ -4369,7 +4417,7 @@
|
|
|
4369
4417
|
"abstract": true,
|
|
4370
4418
|
"docs": {
|
|
4371
4419
|
"default": "- No role is attached to the cluster.",
|
|
4372
|
-
"remarks": "
|
|
4420
|
+
"remarks": "The maximum number of roles to attach to a cluster is subject to a quota.",
|
|
4373
4421
|
"stability": "experimental",
|
|
4374
4422
|
"summary": "A list of AWS Identity and Access Management (IAM) role that can be used by the cluster to access other AWS services."
|
|
4375
4423
|
},
|
|
@@ -5195,7 +5243,7 @@
|
|
|
5195
5243
|
"kind": "interface",
|
|
5196
5244
|
"locationInModule": {
|
|
5197
5245
|
"filename": "lib/table.ts",
|
|
5198
|
-
"line":
|
|
5246
|
+
"line": 132
|
|
5199
5247
|
},
|
|
5200
5248
|
"methods": [
|
|
5201
5249
|
{
|
|
@@ -5206,7 +5254,7 @@
|
|
|
5206
5254
|
},
|
|
5207
5255
|
"locationInModule": {
|
|
5208
5256
|
"filename": "lib/table.ts",
|
|
5209
|
-
"line":
|
|
5257
|
+
"line": 156
|
|
5210
5258
|
},
|
|
5211
5259
|
"name": "grant",
|
|
5212
5260
|
"parameters": [
|
|
@@ -5238,7 +5286,7 @@
|
|
|
5238
5286
|
"immutable": true,
|
|
5239
5287
|
"locationInModule": {
|
|
5240
5288
|
"filename": "lib/table.ts",
|
|
5241
|
-
"line":
|
|
5289
|
+
"line": 146
|
|
5242
5290
|
},
|
|
5243
5291
|
"name": "cluster",
|
|
5244
5292
|
"type": {
|
|
@@ -5254,7 +5302,7 @@
|
|
|
5254
5302
|
"immutable": true,
|
|
5255
5303
|
"locationInModule": {
|
|
5256
5304
|
"filename": "lib/table.ts",
|
|
5257
|
-
"line":
|
|
5305
|
+
"line": 151
|
|
5258
5306
|
},
|
|
5259
5307
|
"name": "databaseName",
|
|
5260
5308
|
"type": {
|
|
@@ -5270,7 +5318,7 @@
|
|
|
5270
5318
|
"immutable": true,
|
|
5271
5319
|
"locationInModule": {
|
|
5272
5320
|
"filename": "lib/table.ts",
|
|
5273
|
-
"line":
|
|
5321
|
+
"line": 141
|
|
5274
5322
|
},
|
|
5275
5323
|
"name": "tableColumns",
|
|
5276
5324
|
"type": {
|
|
@@ -5291,7 +5339,7 @@
|
|
|
5291
5339
|
"immutable": true,
|
|
5292
5340
|
"locationInModule": {
|
|
5293
5341
|
"filename": "lib/table.ts",
|
|
5294
|
-
"line":
|
|
5342
|
+
"line": 136
|
|
5295
5343
|
},
|
|
5296
5344
|
"name": "tableName",
|
|
5297
5345
|
"type": {
|
|
@@ -5421,7 +5469,7 @@
|
|
|
5421
5469
|
"docs": {
|
|
5422
5470
|
"stability": "experimental",
|
|
5423
5471
|
"summary": "Logging bucket and S3 prefix combination.",
|
|
5424
|
-
"example": "import * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as s3 from 'aws-cdk-lib/aws-s3';\n\nconst vpc = new ec2.Vpc(this, 'Vpc');\nconst bucket = s3.Bucket.fromBucketName(
|
|
5472
|
+
"example": "import * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as s3 from 'aws-cdk-lib/aws-s3';\n\nconst vpc = new ec2.Vpc(this, 'Vpc');\nconst bucket = s3.Bucket.fromBucketName(this, 'bucket', 'logging-bucket');\n\nconst cluster = new Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n },\n vpc,\n loggingProperties: {\n loggingBucket: bucket,\n loggingKeyPrefix: 'prefix',\n }\n});",
|
|
5425
5473
|
"custom": {
|
|
5426
5474
|
"exampleMetadata": "infused"
|
|
5427
5475
|
}
|
|
@@ -5476,7 +5524,7 @@
|
|
|
5476
5524
|
"docs": {
|
|
5477
5525
|
"stability": "experimental",
|
|
5478
5526
|
"summary": "Username and password combination.",
|
|
5479
|
-
"example": "
|
|
5527
|
+
"example": "import * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as cdk from 'aws-cdk-lib';\ndeclare const vpc: ec2.Vpc;\n\nnew Cluster(this, 'Redshift', {\n masterUser: {\n masterUsername: 'admin',\n masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),\n },\n vpc,\n enhancedVpcRouting: true,\n})",
|
|
5480
5528
|
"custom": {
|
|
5481
5529
|
"exampleMetadata": "infused"
|
|
5482
5530
|
}
|
|
@@ -5700,7 +5748,7 @@
|
|
|
5700
5748
|
},
|
|
5701
5749
|
"locationInModule": {
|
|
5702
5750
|
"filename": "lib/table.ts",
|
|
5703
|
-
"line":
|
|
5751
|
+
"line": 217
|
|
5704
5752
|
},
|
|
5705
5753
|
"parameters": [
|
|
5706
5754
|
{
|
|
@@ -5729,7 +5777,7 @@
|
|
|
5729
5777
|
"kind": "class",
|
|
5730
5778
|
"locationInModule": {
|
|
5731
5779
|
"filename": "lib/table.ts",
|
|
5732
|
-
"line":
|
|
5780
|
+
"line": 197
|
|
5733
5781
|
},
|
|
5734
5782
|
"methods": [
|
|
5735
5783
|
{
|
|
@@ -5739,7 +5787,7 @@
|
|
|
5739
5787
|
},
|
|
5740
5788
|
"locationInModule": {
|
|
5741
5789
|
"filename": "lib/table.ts",
|
|
5742
|
-
"line":
|
|
5790
|
+
"line": 201
|
|
5743
5791
|
},
|
|
5744
5792
|
"name": "fromTableAttributes",
|
|
5745
5793
|
"parameters": [
|
|
@@ -5777,7 +5825,7 @@
|
|
|
5777
5825
|
},
|
|
5778
5826
|
"locationInModule": {
|
|
5779
5827
|
"filename": "lib/table.ts",
|
|
5780
|
-
"line":
|
|
5828
|
+
"line": 264
|
|
5781
5829
|
},
|
|
5782
5830
|
"name": "applyRemovalPolicy",
|
|
5783
5831
|
"parameters": [
|
|
@@ -5796,7 +5844,7 @@
|
|
|
5796
5844
|
},
|
|
5797
5845
|
"locationInModule": {
|
|
5798
5846
|
"filename": "lib/table.ts",
|
|
5799
|
-
"line":
|
|
5847
|
+
"line": 189
|
|
5800
5848
|
},
|
|
5801
5849
|
"name": "grant",
|
|
5802
5850
|
"overrides": "@aws-cdk/aws-redshift-alpha.ITable",
|
|
@@ -5828,7 +5876,7 @@
|
|
|
5828
5876
|
"immutable": true,
|
|
5829
5877
|
"locationInModule": {
|
|
5830
5878
|
"filename": "lib/table.ts",
|
|
5831
|
-
"line":
|
|
5879
|
+
"line": 212
|
|
5832
5880
|
},
|
|
5833
5881
|
"name": "cluster",
|
|
5834
5882
|
"overrides": "@aws-cdk/aws-redshift-alpha.ITable",
|
|
@@ -5844,7 +5892,7 @@
|
|
|
5844
5892
|
"immutable": true,
|
|
5845
5893
|
"locationInModule": {
|
|
5846
5894
|
"filename": "lib/table.ts",
|
|
5847
|
-
"line":
|
|
5895
|
+
"line": 213
|
|
5848
5896
|
},
|
|
5849
5897
|
"name": "databaseName",
|
|
5850
5898
|
"overrides": "@aws-cdk/aws-redshift-alpha.ITable",
|
|
@@ -5860,7 +5908,7 @@
|
|
|
5860
5908
|
"immutable": true,
|
|
5861
5909
|
"locationInModule": {
|
|
5862
5910
|
"filename": "lib/table.ts",
|
|
5863
|
-
"line":
|
|
5911
|
+
"line": 211
|
|
5864
5912
|
},
|
|
5865
5913
|
"name": "tableColumns",
|
|
5866
5914
|
"overrides": "@aws-cdk/aws-redshift-alpha.ITable",
|
|
@@ -5881,7 +5929,7 @@
|
|
|
5881
5929
|
"immutable": true,
|
|
5882
5930
|
"locationInModule": {
|
|
5883
5931
|
"filename": "lib/table.ts",
|
|
5884
|
-
"line":
|
|
5932
|
+
"line": 210
|
|
5885
5933
|
},
|
|
5886
5934
|
"name": "tableName",
|
|
5887
5935
|
"overrides": "@aws-cdk/aws-redshift-alpha.ITable",
|
|
@@ -5978,7 +6026,7 @@
|
|
|
5978
6026
|
"kind": "interface",
|
|
5979
6027
|
"locationInModule": {
|
|
5980
6028
|
"filename": "lib/table.ts",
|
|
5981
|
-
"line":
|
|
6029
|
+
"line": 162
|
|
5982
6030
|
},
|
|
5983
6031
|
"name": "TableAttributes",
|
|
5984
6032
|
"properties": [
|
|
@@ -5991,7 +6039,7 @@
|
|
|
5991
6039
|
"immutable": true,
|
|
5992
6040
|
"locationInModule": {
|
|
5993
6041
|
"filename": "lib/table.ts",
|
|
5994
|
-
"line":
|
|
6042
|
+
"line": 176
|
|
5995
6043
|
},
|
|
5996
6044
|
"name": "cluster",
|
|
5997
6045
|
"type": {
|
|
@@ -6007,7 +6055,7 @@
|
|
|
6007
6055
|
"immutable": true,
|
|
6008
6056
|
"locationInModule": {
|
|
6009
6057
|
"filename": "lib/table.ts",
|
|
6010
|
-
"line":
|
|
6058
|
+
"line": 181
|
|
6011
6059
|
},
|
|
6012
6060
|
"name": "databaseName",
|
|
6013
6061
|
"type": {
|
|
@@ -6023,7 +6071,7 @@
|
|
|
6023
6071
|
"immutable": true,
|
|
6024
6072
|
"locationInModule": {
|
|
6025
6073
|
"filename": "lib/table.ts",
|
|
6026
|
-
"line":
|
|
6074
|
+
"line": 171
|
|
6027
6075
|
},
|
|
6028
6076
|
"name": "tableColumns",
|
|
6029
6077
|
"type": {
|
|
@@ -6044,7 +6092,7 @@
|
|
|
6044
6092
|
"immutable": true,
|
|
6045
6093
|
"locationInModule": {
|
|
6046
6094
|
"filename": "lib/table.ts",
|
|
6047
|
-
"line":
|
|
6095
|
+
"line": 166
|
|
6048
6096
|
},
|
|
6049
6097
|
"name": "tableName",
|
|
6050
6098
|
"type": {
|
|
@@ -6068,7 +6116,7 @@
|
|
|
6068
6116
|
"kind": "enum",
|
|
6069
6117
|
"locationInModule": {
|
|
6070
6118
|
"filename": "lib/table.ts",
|
|
6071
|
-
"line":
|
|
6119
|
+
"line": 305
|
|
6072
6120
|
},
|
|
6073
6121
|
"members": [
|
|
6074
6122
|
{
|
|
@@ -6200,6 +6248,24 @@
|
|
|
6200
6248
|
"fqn": "@aws-cdk/aws-redshift-alpha.TableSortStyle"
|
|
6201
6249
|
}
|
|
6202
6250
|
},
|
|
6251
|
+
{
|
|
6252
|
+
"abstract": true,
|
|
6253
|
+
"docs": {
|
|
6254
|
+
"default": "- no comment",
|
|
6255
|
+
"stability": "experimental",
|
|
6256
|
+
"summary": "A comment to attach to the table."
|
|
6257
|
+
},
|
|
6258
|
+
"immutable": true,
|
|
6259
|
+
"locationInModule": {
|
|
6260
|
+
"filename": "lib/table.ts",
|
|
6261
|
+
"line": 126
|
|
6262
|
+
},
|
|
6263
|
+
"name": "tableComment",
|
|
6264
|
+
"optional": true,
|
|
6265
|
+
"type": {
|
|
6266
|
+
"primitive": "string"
|
|
6267
|
+
}
|
|
6268
|
+
},
|
|
6203
6269
|
{
|
|
6204
6270
|
"abstract": true,
|
|
6205
6271
|
"docs": {
|
|
@@ -6235,7 +6301,7 @@
|
|
|
6235
6301
|
"kind": "enum",
|
|
6236
6302
|
"locationInModule": {
|
|
6237
6303
|
"filename": "lib/table.ts",
|
|
6238
|
-
"line":
|
|
6304
|
+
"line": 330
|
|
6239
6305
|
},
|
|
6240
6306
|
"members": [
|
|
6241
6307
|
{
|
|
@@ -6639,6 +6705,6 @@
|
|
|
6639
6705
|
"symbolId": "lib/user:UserProps"
|
|
6640
6706
|
}
|
|
6641
6707
|
},
|
|
6642
|
-
"version": "2.
|
|
6708
|
+
"version": "2.65.0-alpha.0",
|
|
6643
6709
|
"fingerprint": "**********"
|
|
6644
6710
|
}
|
package/.jsii.tabl.json.gz
CHANGED
|
Binary file
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
|
48
48
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
49
49
|
|
|
50
50
|
const vpc = new ec2.Vpc(this, 'Vpc');
|
|
51
|
-
const bucket = s3.Bucket.fromBucketName(
|
|
51
|
+
const bucket = s3.Bucket.fromBucketName(this, 'bucket', 'logging-bucket');
|
|
52
52
|
|
|
53
53
|
const cluster = new Cluster(this, 'Redshift', {
|
|
54
54
|
masterUser: {
|
|
@@ -56,7 +56,7 @@ const cluster = new Cluster(this, 'Redshift', {
|
|
|
56
56
|
},
|
|
57
57
|
vpc,
|
|
58
58
|
loggingProperties: {
|
|
59
|
-
loggingBucket
|
|
59
|
+
loggingBucket: bucket,
|
|
60
60
|
loggingKeyPrefix: 'prefix',
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -194,6 +194,20 @@ new Table(this, 'Table', {
|
|
|
194
194
|
});
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
+
Tables can also be configured with a comment:
|
|
198
|
+
|
|
199
|
+
```ts fixture=cluster
|
|
200
|
+
new Table(this, 'Table', {
|
|
201
|
+
tableColumns: [
|
|
202
|
+
{ name: 'col1', dataType: 'varchar(4)' },
|
|
203
|
+
{ name: 'col2', dataType: 'float' }
|
|
204
|
+
],
|
|
205
|
+
cluster: cluster,
|
|
206
|
+
databaseName: 'databaseName',
|
|
207
|
+
comment: 'This is a comment',
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
197
211
|
### Granting Privileges
|
|
198
212
|
|
|
199
213
|
You can give a user privileges to perform certain actions on a table by using the
|
|
@@ -299,7 +313,9 @@ cluster.addRotationMultiUser('MultiUserRotation', {
|
|
|
299
313
|
You can add a parameter to a parameter group with`ClusterParameterGroup.addParameter()`.
|
|
300
314
|
|
|
301
315
|
```ts
|
|
302
|
-
|
|
316
|
+
import { ClusterParameterGroup } from '@aws-cdk/aws-redshift-alpha';
|
|
317
|
+
|
|
318
|
+
const params = new ClusterParameterGroup(this, 'Params', {
|
|
303
319
|
description: 'desc',
|
|
304
320
|
parameters: {
|
|
305
321
|
require_ssl: 'true',
|
|
@@ -312,6 +328,8 @@ params.addParameter('enable_user_activity_logging', 'true');
|
|
|
312
328
|
Additionally, you can add a parameter to the cluster's associated parameter group with `Cluster.addToParameterGroup()`. If the cluster does not have an associated parameter group, a new parameter group is created.
|
|
313
329
|
|
|
314
330
|
```ts
|
|
331
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
332
|
+
import * as cdk from 'aws-cdk-lib';
|
|
315
333
|
declare const vpc: ec2.Vpc;
|
|
316
334
|
|
|
317
335
|
const cluster = new Cluster(this, 'Cluster', {
|
|
@@ -330,9 +348,11 @@ cluster.addToParameterGroup('enable_user_activity_logging', 'true');
|
|
|
330
348
|
If you configure your cluster to be publicly accessible, you can optionally select an *elastic IP address* to use for the external IP address. An elastic IP address is a static IP address that is associated with your AWS account. You can use an elastic IP address to connect to your cluster from outside the VPC. An elastic IP address gives you the ability to change your underlying configuration without affecting the IP address that clients use to connect to your cluster. This approach can be helpful for situations such as recovery after a failure.
|
|
331
349
|
|
|
332
350
|
```ts
|
|
351
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
352
|
+
import * as cdk from 'aws-cdk-lib';
|
|
333
353
|
declare const vpc: ec2.Vpc;
|
|
334
354
|
|
|
335
|
-
new Cluster(
|
|
355
|
+
new Cluster(this, 'Redshift', {
|
|
336
356
|
masterUser: {
|
|
337
357
|
masterUsername: 'admin',
|
|
338
358
|
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
|
|
@@ -346,6 +366,7 @@ new Cluster(stack, 'Redshift', {
|
|
|
346
366
|
If the Cluster is in a VPC and you want to connect to it using the private IP address from within the cluster, it is important to enable *DNS resolution* and *DNS hostnames* in the VPC config. If these parameters would not be set, connections from within the VPC would connect to the elastic IP address and not the private IP address.
|
|
347
367
|
|
|
348
368
|
```ts
|
|
369
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
349
370
|
const vpc = new ec2.Vpc(this, 'VPC', {
|
|
350
371
|
enableDnsSupport: true,
|
|
351
372
|
enableDnsHostnames: true,
|
|
@@ -367,9 +388,11 @@ In some cases, you might want to associate the cluster with an elastic IP addres
|
|
|
367
388
|
When you use Amazon Redshift enhanced VPC routing, Amazon Redshift forces all COPY and UNLOAD traffic between your cluster and your data repositories through your virtual private cloud (VPC) based on the Amazon VPC service. By using enhanced VPC routing, you can use standard VPC features, such as VPC security groups, network access control lists (ACLs), VPC endpoints, VPC endpoint policies, internet gateways, and Domain Name System (DNS) servers, as described in the Amazon VPC User Guide. You use these features to tightly manage the flow of data between your Amazon Redshift cluster and other resources. When you use enhanced VPC routing to route traffic through your VPC, you can also use VPC flow logs to monitor COPY and UNLOAD traffic.
|
|
368
389
|
|
|
369
390
|
```ts
|
|
391
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
392
|
+
import * as cdk from 'aws-cdk-lib';
|
|
370
393
|
declare const vpc: ec2.Vpc;
|
|
371
394
|
|
|
372
|
-
new Cluster(
|
|
395
|
+
new Cluster(this, 'Redshift', {
|
|
373
396
|
masterUser: {
|
|
374
397
|
masterUsername: 'admin',
|
|
375
398
|
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
|
|
@@ -425,3 +448,39 @@ const redshiftCluster = new Cluster(stack, 'Redshift', {
|
|
|
425
448
|
|
|
426
449
|
redshiftCluster.addDefaultIamRole(defaultRole);
|
|
427
450
|
```
|
|
451
|
+
|
|
452
|
+
## IAM roles
|
|
453
|
+
|
|
454
|
+
Attaching IAM roles to a Redshift Cluster grants permissions to the Redshift service to perform actions on your behalf.
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
declare const vpc: ec2.Vpc
|
|
458
|
+
|
|
459
|
+
const role = new iam.Role(this, 'Role', {
|
|
460
|
+
assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),
|
|
461
|
+
});
|
|
462
|
+
const cluster = new Cluster(this, 'Redshift', {
|
|
463
|
+
masterUser: {
|
|
464
|
+
masterUsername: 'admin',
|
|
465
|
+
},
|
|
466
|
+
vpc,
|
|
467
|
+
roles: [role],
|
|
468
|
+
});
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Additional IAM roles can be attached to a cluster using the `addIamRole` method.
|
|
472
|
+
|
|
473
|
+
```ts
|
|
474
|
+
declare const vpc: ec2.Vpc
|
|
475
|
+
|
|
476
|
+
const role = new iam.Role(this, 'Role', {
|
|
477
|
+
assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),
|
|
478
|
+
});
|
|
479
|
+
const cluster = new Cluster(this, 'Redshift', {
|
|
480
|
+
masterUser: {
|
|
481
|
+
masterUsername: 'admin',
|
|
482
|
+
},
|
|
483
|
+
vpc,
|
|
484
|
+
});
|
|
485
|
+
cluster.addIamRole(role);
|
|
486
|
+
```
|