Sono disponibili altri esempi AWS SDK nel repository AWS Doc SDK
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzo DescribeStackResources
con un AWS SDK o una CLI
I seguenti esempi di codice mostrano come utilizzareDescribeStackResources
.
- CLI
-
- AWS CLI
-
Per ottenere informazioni su una risorsa dello stack
L'
describe-stack-resources
esempio seguente visualizza i dettagli delle risorse nello stack specificato.aws cloudformation describe-stack-resources \ --stack-name my-stack
Output:
{ "StackResources": [ { "StackName": "my-stack", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "bucket", "PhysicalResourceId": "my-stack-bucket-1vc62xmplgguf", "ResourceType": "AWS::S3::Bucket", "Timestamp": "2019-10-02T04:34:11.345Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "StackName": "my-stack", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "Timestamp": "2019-10-02T05:34:27.989Z", "ResourceStatus": "UPDATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "StackName": "my-stack", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "functionRole", "PhysicalResourceId": "my-functionRole-HIZXMPLEOM9E", "ResourceType": "AWS::IAM::Role", "Timestamp": "2019-10-02T04:34:06.350Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } } ] }
-
Per i dettagli sull'API, vedere DescribeStackResources
in AWS CLI Command Reference.
-
- PowerShell
-
- Strumenti per PowerShell
-
Esempio 1: restituisce le descrizioni AWS delle risorse per un massimo di 100 risorse associate allo stack specificato. Per ottenere i dettagli di tutte le risorse associate a uno stack, usa Get-CFNStackResourceSummary, che supporta anche la paginazione manuale dei risultati.
Get-CFNStackResourceList -StackName "myStack"
Esempio 2: restituisce la descrizione dell'istanza Amazon EC2 identificata nel modello associato allo stack specificato dall'ID logico «Ec2Instance».
Get-CFNStackResourceList -StackName "myStack" -LogicalResourceId "Ec2Instance"
Esempio 3: restituisce la descrizione di un massimo di 100 risorse associate allo stack contenente un'istanza Amazon EC2 identificata dall'ID di istanza «i-123456". Per ottenere i dettagli di tutte le risorse associate a uno stack, usa Get-CFN, che supporta anche la paginazione manuale StackResourceSummary dei risultati.
Get-CFNStackResourceList -PhysicalResourceId "i-123456"
Esempio 4: restituisce la descrizione dell'istanza Amazon EC2 identificata dall'ID logico «Ec2Instance» nel modello per uno stack. Lo stack viene identificato utilizzando l'ID della risorsa fisica di una risorsa che contiene, in questo caso anche un'istanza Amazon EC2 con ID di istanza «i-123456". È inoltre possibile utilizzare una risorsa fisica diversa per identificare lo stack in base al contenuto del modello, ad esempio un bucket Amazon S3.
Get-CFNStackResourceList -PhysicalResourceId "i-123456" -LogicalResourceId "Ec2Instance"
-
Per i dettagli sull'API, vedere DescribeStackResourcesin AWS Tools for PowerShell Cmdlet Reference.
-