产品上架Amazon使用的资源Amazon CloudFormation - Amazon SDK for .NET
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

是否要将 .NET 应用程序部署到Amazon通过几个简单点击即可? 尝试我们的新.NET CLI 工具为了简化部署体验!阅读我们的博客帖子然后提交反馈GitHub

有关更多信息,请参阅部署工具

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

产品上架Amazon使用的资源Amazon CloudFormation

此示例向您演示如何使用Amazon SDK for .NET在中列出资源Amazon CloudFormation堆栈。该示例使用低级 API。该应用程序不需要参数,但只需收集用户凭据可访问的所有堆栈的信息,然后显示有关这些堆栈的信息。

using System; using System.Threading.Tasks; using Amazon.CloudFormation; using Amazon.CloudFormation.Model; namespace CFNListResources { class Program { 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.) if(stack.Tags.Count > 0) { Console.WriteLine(" Tags:"); foreach (Tag tag in stack.Tags) Console.WriteLine($" {tag.Key}, {tag.Value}"); } // The resources of each stack 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------------------------------------------------"); } } }