将 DescribeStackResource 与 CLI 配合使用 - AWS SDK 代码示例

AWS 文档 SDK 示例 GitHub 存储库中还有更多 AWS SDK 示例。

DescribeStackResource 与 CLI 配合使用

以下代码示例演示如何使用 DescribeStackResource

CLI
AWS CLI

获取有关堆栈资源的信息

以下 describe-stack-resource 示例显示指定堆栈中名为 MyFunction 的资源的详细信息。

aws cloudformation describe-stack-resource \ --stack-name MyStack \ --logical-resource-id MyFunction

输出:

{ "StackResourceDetail": { "StackName": "MyStack", "StackId": "arn:aws:cloudformation:us-east-2:123456789012:stack/MyStack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "MyFunction", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "LastUpdatedTimestamp": "2019-10-02T05:34:27.989Z", "ResourceStatus": "UPDATE_COMPLETE", "Metadata": "{}", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } } }
PowerShell
Tools for PowerShell V4

示例 1:返回与指定堆栈关联的模板中用逻辑 ID “MyDBInstance”标识的资源的描述。

Get-CFNStackResource -StackName "myStack" -LogicalResourceId "MyDBInstance"
  • 有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference(V4)》中的 DescribeStackResource

Tools for PowerShell V5

示例 1:返回与指定堆栈关联的模板中用逻辑 ID “MyDBInstance”标识的资源的描述。

Get-CFNStackResource -StackName "myStack" -LogicalResourceId "MyDBInstance"
  • 有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference(V5)》中的 DescribeStackResource