|
1 | | -# Amazon Redshift code examples for the SDK for .NET Framework 4.x |
| 1 | +# Amazon Redshift code examples for the SDK for .NET (v4) |
2 | 2 |
|
3 | 3 | ## Overview |
4 | 4 |
|
5 | | -This folder contains code examples that demonstrate how to use the AWS SDK for .NET Framework 4.x to interact with Amazon Redshift. |
| 5 | +Shows how to use the AWS SDK for .NET (v4) to work with Amazon Redshift. |
6 | 6 |
|
7 | | -Amazon Redshift is a fast, fully managed, petabyte-scale data warehouse service that makes it simple and cost-effective to efficiently analyze all your data using your existing business intelligence tools. |
| 7 | +<!--custom.overview.start--> |
| 8 | +<!--custom.overview.end--> |
| 9 | + |
| 10 | +_Amazon Redshift is a fast, fully managed, petabyte-scale data warehouse service that makes it simple and cost-effective to efficiently analyze all your data using your existing business intelligence tools._ |
8 | 11 |
|
9 | 12 | ## ⚠ Important |
10 | 13 |
|
11 | | -* Running this code might result in charges to your AWS account. |
| 14 | +* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/). |
12 | 15 | * Running the tests might result in charges to your AWS account. |
13 | 16 | * We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). |
14 | 17 | * This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). |
15 | 18 |
|
| 19 | +<!--custom.important.start--> |
| 20 | +<!--custom.important.end--> |
| 21 | + |
16 | 22 | ## Code examples |
17 | 23 |
|
18 | | -### Actions |
| 24 | +### Prerequisites |
19 | 25 |
|
20 | | -Code excerpts that show you how to call individual service functions: |
| 26 | +For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv4` folder. |
21 | 27 |
|
22 | | -- [CreateCluster](Actions/RedshiftWrapper.cs#L28) (`CreateCluster`) |
23 | | -- [DeleteCluster](Actions/RedshiftWrapper.cs#L118) (`DeleteCluster`) |
24 | | -- [DescribeClusters](Actions/RedshiftWrapper.cs#L69) (`DescribeClusters`) |
25 | | -- [ModifyCluster](Actions/RedshiftWrapper.cs#L96) (`ModifyCluster`) |
26 | | -- [CreateTable](Actions/RedshiftWrapper.cs#L157) (`ExecuteStatement`) |
27 | | -- [InsertMovie](Actions/RedshiftWrapper.cs#L193) (`ExecuteStatement`) |
28 | | -- [QueryMoviesByYear](Actions/RedshiftWrapper.cs#L227) (`ExecuteStatement`, `GetStatementResult`) |
29 | | -- [DescribeStatement](Actions/RedshiftWrapper.cs#L269) (`DescribeStatement`) |
30 | | -- [GetStatementResult](Actions/RedshiftWrapper.cs#L289) (`GetStatementResult`) |
31 | | -- [ListDatabases](Actions/RedshiftWrapper.cs#L130) (`ListDatabases`) |
32 | 28 |
|
33 | | -### Scenarios |
| 29 | +<!--custom.prerequisites.start--> |
| 30 | +<!--custom.prerequisites.end--> |
34 | 31 |
|
35 | | -Code examples that show you how to accomplish a specific task by calling multiple functions within the same service: |
| 32 | +### Get started |
36 | 33 |
|
37 | | -- [Get started with Redshift clusters](Scenarios/RedshiftBasics.cs) - Learn the basics of Amazon Redshift by creating a cluster, adding a table, inserting data, and querying the table. |
| 34 | +- [Hello Amazon Redshift](Actions/HelloRedshift.cs#L20) (`DescribeClusters`) |
38 | 35 |
|
39 | | -### Hello |
40 | 36 |
|
41 | | -- [Hello Amazon Redshift](Hello/HelloRedshift.cs) - A simple example that shows how to get started with Amazon Redshift by listing existing clusters. |
| 37 | +### Basics |
42 | 38 |
|
43 | | -## Run the examples |
| 39 | +Code examples that show you how to perform the essential operations within a service. |
44 | 40 |
|
45 | | -### Prerequisites |
| 41 | +- [Learn the basics](Actions/RedshiftWrapper.cs) |
46 | 42 |
|
47 | | -For general prerequisites, see the [README](../../README.md) in the `dotnetv4` folder. |
48 | 43 |
|
49 | | -After the example compiles, you can run it from the command line. To do so, navigate to the folder that contains the .csproj file and run the following command: |
| 44 | +### Single actions |
50 | 45 |
|
51 | | -``` |
52 | | -dotnet run |
53 | | -``` |
| 46 | +Code excerpts that show you how to call individual service functions. |
54 | 47 |
|
55 | | -Alternatively, you can run the example from within your IDE. |
| 48 | +- [CreateCluster](Actions/RedshiftWrapper.cs#L34) |
| 49 | +- [DeleteCluster](Actions/RedshiftWrapper.cs#L143) |
| 50 | +- [DescribeClusters](Actions/RedshiftWrapper.cs#L77) |
| 51 | +- [DescribeStatement](Actions/RedshiftWrapper.cs#L375) |
| 52 | +- [GetStatementResult](Actions/RedshiftWrapper.cs#L406) |
| 53 | +- [ListDatabases](Actions/RedshiftWrapper.cs#L176) |
| 54 | +- [ModifyCluster](Actions/RedshiftWrapper.cs#L109) |
56 | 55 |
|
57 | | -### Hello Amazon Redshift |
58 | 56 |
|
59 | | -This example shows you how to get started using Amazon Redshift. |
| 57 | +<!--custom.examples.start--> |
| 58 | +<!--custom.examples.end--> |
60 | 59 |
|
61 | | -#### Purpose |
| 60 | +## Run the examples |
62 | 61 |
|
63 | | -Shows how to use the AWS SDK for .NET to get started using Amazon Redshift. Lists existing Redshift clusters in your account. |
| 62 | +### Instructions |
64 | 63 |
|
65 | | -### Redshift Basics Scenario |
66 | 64 |
|
67 | | -This scenario demonstrates how to interact with Amazon Redshift using the AWS SDK for .NET. It demonstrates various tasks such as creating a Redshift cluster, verifying its readiness, creating a table, populating the table with data, executing SQL queries, and finally cleaning up resources. |
| 65 | +<!--custom.instructions.start--> |
| 66 | +<!--custom.instructions.end--> |
68 | 67 |
|
69 | | -#### Purpose |
| 68 | +#### Hello Amazon Redshift |
70 | 69 |
|
71 | | -Demonstrates how to: |
| 70 | +This example shows you how to get started using Amazon Redshift. |
72 | 71 |
|
73 | | -1. Create an Amazon Redshift cluster. |
74 | | -2. Wait for the cluster to become available. |
75 | | -3. List databases in the cluster. |
76 | | -4. Create a "Movies" table. |
77 | | -5. Populate the "Movies" table using sample data. |
78 | | -6. Query the "Movies" table by year. |
79 | | -7. Modify the Redshift cluster. |
80 | | -8. Delete the Amazon Redshift cluster. |
81 | 72 |
|
82 | | -#### Usage |
| 73 | +#### Learn the basics |
83 | 74 |
|
84 | | -1. Clone the repository or download the source code files. |
85 | | -2. Open the code in your preferred .NET IDE. |
86 | | -3. Update the following variables in the `RunScenarioAsync()` method if needed: |
87 | | - - `userName`: The username for the Redshift cluster. |
88 | | - - `userPassword`: The password for the Redshift cluster. |
89 | | - - `databaseName`: The name of the database to use ("dev"). |
90 | | -4. Run the `RedshiftBasics` class. |
| 75 | +This example shows you how to do the following: |
91 | 76 |
|
92 | | -The program will guide you through the scenario, prompting you to enter a cluster ID and the number of records to add to the "Movies" table. The program will also display the progress and results of the various operations. |
| 77 | +- Create a Redshift cluster. |
| 78 | +- List databases in the cluster. |
| 79 | +- Create a table named Movies. |
| 80 | +- Populate the Movies table. |
| 81 | +- Query the Movies table by year. |
| 82 | +- Modify the Redshift cluster. |
| 83 | +- Delete the Amazon Redshift cluster. |
93 | 84 |
|
94 | | -## Tests |
| 85 | +<!--custom.basic_prereqs.redshift_Scenario.start--> |
| 86 | +<!--custom.basic_prereqs.redshift_Scenario.end--> |
95 | 87 |
|
96 | | -### Unit tests |
97 | 88 |
|
98 | | -Unit tests in this solution use MSTest. The tests use Moq to mock AWS service client dependencies. |
| 89 | +<!--custom.basics.redshift_Scenario.start--> |
| 90 | +<!--custom.basics.redshift_Scenario.end--> |
99 | 91 |
|
100 | | -Run unit tests with this command: |
101 | 92 |
|
102 | | -``` |
103 | | -dotnet test Tests/RedshiftTests.csproj |
104 | | -``` |
| 93 | +### Tests |
105 | 94 |
|
106 | | -### Integration tests |
| 95 | +⚠ Running tests might result in charges to your AWS account. |
107 | 96 |
|
108 | | -⚠️ Running the integration tests might result in charges to your AWS account. |
109 | 97 |
|
110 | | -The integration tests in this solution require access to AWS services and will create and delete AWS resources. Make sure you have valid AWS credentials configured before running these tests. |
| 98 | +To find instructions for running these tests, see the [README](../README.md#Tests) |
| 99 | +in the `dotnetv4` folder. |
111 | 100 |
|
112 | | -Run integration tests with this command: |
113 | 101 |
|
114 | | -``` |
115 | | -dotnet test IntegrationTests/RedshiftIntegrationTests.csproj |
116 | | -``` |
117 | 102 |
|
118 | | -Note: The full workflow integration test can take 10-15 minutes to complete due to cluster creation time. |
| 103 | +<!--custom.tests.start--> |
| 104 | +<!--custom.tests.end--> |
119 | 105 |
|
120 | 106 | ## Additional resources |
121 | 107 |
|
122 | 108 | - [Amazon Redshift Management Guide](https://docs.aws.amazon.com/redshift/latest/mgmt/welcome.html) |
123 | 109 | - [Amazon Redshift API Reference](https://docs.aws.amazon.com/redshift/latest/APIReference/Welcome.html) |
124 | | -- [SDK for .NET Amazon Redshift reference](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Redshift/NRedshift.html) |
| 110 | +- [SDK for .NET (v4) Amazon Redshift reference](https://docs.aws.amazon.com/sdkfornet/v4/apidocs/items/Redshift/NRedshift.html) |
| 111 | + |
| 112 | +<!--custom.resources.start--> |
| 113 | +<!--custom.resources.end--> |
125 | 114 |
|
126 | 115 | --- |
127 | 116 |
|
128 | | -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 117 | +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 118 | + |
129 | 119 | SPDX-License-Identifier: Apache-2.0 |
0 commit comments