// From an **asynchronous** calling function
ListBucketsResponse response = await MyListBuckets();
Console.WriteLine($"Number of buckets: {response.Buckets.Count}");
// OR From a **synchronous** calling function
Task<ListBucketsResponse> response = MyListBuckets();
Console.WriteLine($"Number of buckets: {response.Result.Buckets.Count}");
Migrating to version 3.7 of the AWS SDK for .NET
As of version 3.7, the AWS SDK for .NET no longer supports .NET Standard 1.3.
For information about migrating from .NET Standard 1.3, see Migrating from .NET Standard 1.3 (p. 61).
Migrating from .NET Standard 1.3
On June 27 2019 Microsoft ended support for .NET Core 1.0 and .NET Core 1.1 versions. Following this announcement, AWS ended support for .NET Standard 1.3 on the AWS SDK for .NET on December 31, 2020.
AWS continued to provide service updates and security fixes on the AWS SDK for .NET targeting .NET Standard 1.3 until October 1, 2020. After that date, the .NET Standard 1.3 target went into Maintenance mode, which meant that no new updates were released; AWS applied critical bug fixes and security patches only.
On December 31, 2020, support for .NET Standard 1.3 on the AWS SDK for .NET came to its end of life.
After that date no bug fixes or security patches were applied. Artifacts built with that target remain available for download on NuGet.
What you need to do
• If you're running applications using .NET Framework, you're not affected.
• If you're running applications using .NET Core 2.0 or higher, you're not affected.
• If you're running applications using .NET Core 1.0 or .NET Core 1.1, migrate your applications to a newer version of .NET Core by following Microsoft migration instructions. We recommend a minimum of .NET Core 3.1.
Migrating from .NET Standard 1.3
• If you're running business critical applications that cannot be upgraded at this time, you can continue using your current version of AWS SDK for .NET.
If you have questions or concerns, contact AWS Support.
Code examples with guidance
Working with AWS services in the AWS SDK for .NET
The following sections contain examples, tutorials, tasks, and guides that show you how to use the AWS SDK for .NET to work with AWS services.
If you're new to the AWS SDK for .NET, you might want to check out the Quick tour (p. 4) topic first. It gives you an introduction to the SDK.
You can find more code examples in the AWS Code Examples Repository and the awslabs repository on GitHub.
Before you begin, be sure you have set up your environment (p. 14). Also review the information in Setting up your project (p. 16) and SDK features (p. 48).
Topics
• Code examples with guidance for the AWS SDK for .NET (p. 63)
• Additional code examples for the AWS SDK for .NET (p. 186)
• Programming AWS OpsWorks to Work with stacks and applications (p. 258)
• Support for other AWS services and configuration (p. 259)
Code examples with guidance for the AWS SDK for .NET
The following sections contain code examples and provide guidance for the examples. They can help you learn how to use the AWS SDK for .NET to work with AWS services.
If you're new to the AWS SDK for .NET, you might want to check out the Quick tour (p. 4) topic first. It gives you an introduction to the SDK.
Before you begin, be sure you have set up your environment (p. 14). Also review the information in Setting up your project (p. 16) and SDK features (p. 48).
Topics
• Accessing AWS CloudFormation with the AWS SDK for .NET (p. 64)
• Authenticating users with Amazon Cognito (p. 65)
• Using Amazon DynamoDB NoSQL databases (p. 71)
• Working with Amazon EC2 (p. 91)
• Accessing AWS Identity and Access Management (IAM) with the AWS SDK for .NET (p. 132)
• Using Amazon Simple Storage Service Internet storage (p. 154)
• Sending Notifications From the Cloud Using Amazon Simple Notification Service (p. 161)
• Messaging using Amazon SQS (p. 164)
AWS CloudFormation
Accessing AWS CloudFormation with the AWS SDK for .NET
The AWS SDK for .NET supports AWS CloudFormation, which creates and provisions AWS infrastructure deployments predictably and repeatedly.
APIs
The AWS SDK for .NET provides APIs for AWS CloudFormation clients. The APIs enable you to work with AWS CloudFormation features such as templates and stacks. This section contains a small number of examples that show you the patterns you can follow when working with these APIs. To view the full set of APIs, see the AWS SDK for .NET API Reference (and scroll to "Amazon.CloudFormation").
The AWS CloudFormation APIs are provided by the AWSSDK.CloudFormation package.
Prerequisites
Before you begin, be sure you have set up your environment (p. 14). Also review the information in Setting up your project (p. 16) and SDK features (p. 48).
Topics
Topics
• Listing AWS resources using AWS CloudFormation (p. 64)
Listing AWS resources using AWS CloudFormation
This example shows you how to use the AWS SDK for .NET to list the resources in AWS CloudFormation stacks. The example uses the low-level API. The application takes no arguments, but simply gathers information for all stacks that are accessible to the user's credentials and then displays information about those stacks.
SDK references
NuGet packages:• AWSSDK.CloudFormation
Programming elements:
• Namespace Amazon.CloudFormation Class AmazonCloudFormationClient
• Namespace Amazon.CloudFormation.Model Class DescribeStackResourcesRequest Class DescribeStackResourcesResponse Class DescribeStacksResponse
Class Stack
Class StackResource Class Tag
Amazon Cognito
static async Task Main(string[] args) {
// Create the CloudFormation client
var cfnClient = new AmazonCloudFormationClient();
// List the resources for each stack
await ListResources(cfnClient, await cfnClient.DescribeStacksAsync());
} //
// Method to list stack resources and other information private static async Task ListResources(
IAmazonCloudFormation cfnClient, DescribeStacksResponse responseDescribeStacks) {
Console.WriteLine("Getting CloudFormation stack information...");
foreach (Stack stack in responseDescribeStacks.Stacks) {
// Basic information for each stack
Console.WriteLine("\n---");
Console.WriteLine($"\nStack: {stack.StackName}");
Console.WriteLine($" Status: {stack.StackStatus.Value}");
Console.WriteLine($" Created: {stack.CreationTime}");
// The tags of each stack (etc.)
DescribeStackResourcesResponse responseDescribeResources =
await cfnClient.DescribeStackResourcesAsync(new DescribeStackResourcesRequest{
StackName = stack.StackName});
if(responseDescribeResources.StackResources.Count > 0) {
Console.WriteLine(" Resources:");
foreach(StackResource resource in responseDescribeResources.StackResources) Console.WriteLine($" {resource.LogicalResourceId}:
{resource.ResourceStatus}");
} }
Console.WriteLine("\n---");
} }}