forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloAurora.cs
37 lines (31 loc) · 1.5 KB
/
HelloAurora.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[Aurora.dotnetv3.HelloAurora]
using Amazon.RDS;
using Amazon.RDS.Model;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace AuroraActions;
public static class HelloAurora
{
static async Task Main(string[] args)
{
// Use the AWS .NET Core Setup package to set up dependency injection for the
// Amazon Relational Database Service (Amazon RDS).
// Use your AWS profile name, or leave it blank to use the default profile.
using var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((_, services) =>
services.AddAWSService<IAmazonRDS>()
).Build();
// Now the client is available for injection. Fetching it directly here for example purposes only.
var rdsClient = host.Services.GetRequiredService<IAmazonRDS>();
// You can use await and any of the async methods to get a response.
var response = await rdsClient.DescribeDBClustersAsync(new DescribeDBClustersRequest { IncludeShared = true });
Console.WriteLine($"Hello Amazon RDS Aurora! Let's list some clusters in this account:");
foreach (var cluster in response.DBClusters)
{
Console.WriteLine($"\tCluster: database: {cluster.DatabaseName} identifier: {cluster.DBClusterIdentifier}.");
}
}
}
// snippet-end:[Aurora.dotnetv3.HelloAurora]