Esempi di CloudFormation con la AWS CLI
Gli esempi di codice seguenti mostrano come eseguire azioni e implementare scenari comuni utilizzando la AWS Command Line Interface con CloudFormation.
Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le operazioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.
Ogni esempio include un link al codice sorgente completo, dove è possibile trovare le istruzioni su come configurare ed eseguire il codice nel contesto.
Argomenti
Operazioni
L’esempio di codice seguente mostra come utilizzare activate-type.
- AWS CLI
-
Come attivare un tipo
L’esempio
activate-typeseguente attiva un’estensione pubblica di terze parti, rendendola disponibile per l’uso nei modelli di stack.aws cloudformation activate-type \ --regionus-west-2\ --typeRESOURCE\ --type-nameExample::Test::1234567890abcdef0\ --type-name-aliasExample::Test::AliasOutput:
{ "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Alias" }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta ActivateType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare batch-describe-type-configurations.
- AWS CLI
-
Come descrivere in batch una configurazione del tipo
L’esempio
batch-describe-type-configurationsseguente configura i dati per il tipo.aws cloudformation batch-describe-type-configurations \ --regionus-west-2\ --type-configuration-identifiers TypeArn="arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Type,TypeConfigurationAlias=MyConfiguration"Output:
{ "Errors": [], "UnprocessedTypeConfigurations": [], "TypeConfigurations": [ { "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Type", "Alias": "MyConfiguration", "Configuration": "{\n \"Example\": {\n \"ApiKey\": \"examplekey\",\n \"ApplicationKey\": \"examplekey1\",\n \"ApiURL\": \"exampleurl\"\n }\n}", "LastUpdated": "2021-10-01T15:25:46.210000+00:00", "TypeArn": "arn:aws:cloudformation:us-east-1:123456789012:type/resource/Example-Test-Type" } ] }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta BatchDescribeTypeConfigurations
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare cancel-update-stack.
- AWS CLI
-
Come annullare un aggiornamento di stack in corso
Il seguente comando
cancel-update-stackannulla un aggiornamento di stack nello stackmyteststack:aws cloudformation cancel-update-stack --stack-namemyteststack-
Per informazioni dettagliate sull’API, consulta CancelUpdateStack
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare continue-update-rollback.
- AWS CLI
-
Come riprovare il rollback dell’aggiornamento
L’esempio
continue-update-rollbackseguente riprende un’operazione di rollback da un aggiornamento dello stack precedentemente non riuscito.aws cloudformation continue-update-rollback \ --stack-namemy-stackQuesto comando non produce alcun output.
-
Per informazioni dettagliate sull’API, consulta ContinueUpdateRollback
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-change-set.
- AWS CLI
-
Per creare un set di modifiche
L’esempio
create-change-setseguente crea un set di modifiche con la capacitàCAPABILITY_IAM. Il filetemplate.yamlè un modello di AWS CloudFormation nella cartella corrente che definisce uno stack che include risorse IAM.aws cloudformation create-change-set \ --stack-namemy-application\ --change-set-namemy-change-set\ --template-bodyfile://template.yaml\ --capabilitiesCAPABILITY_IAMOutput:
{ "Id": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-application/d0a825a0-e4cd-xmpl-b9fb-061c69e99204" }-
Per informazioni dettagliate sull’API, consulta CreateChangeSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-stack-instances.
- AWS CLI
-
Come creare istanze di stack
L’esempio
create-stack-instancesseguente crea istanze di uno stack impostato in due account e quattro Regioni. L’impostazione della tolleranza ai guasti garantisce che l’aggiornamento venga tentato in tutti gli account e le Regioni, anche se non è possibile creare alcuni stack.aws cloudformation create-stack-instances \ --stack-set-namemy-stack-set\ --accounts123456789012223456789012\ --regionsus-east-1us-east-2us-west-1us-west-2\ --operation-preferencesFailureToleranceCount=7Output:
{ "OperationId": "d7995c31-83c2-xmpl-a3d4-e9ca2811563f" }Per creare uno stack, utilizzare il comando
create-stack-set.-
Per informazioni dettagliate sull’API, consulta CreateStackInstances
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-stack-set.
- AWS CLI
-
Come creare un set di stack
L’esempio
create-stack-setseguente crea un set di stack utilizzando il modello di file YAML specificato.template.yamlè un modello di AWS CloudFormation nella cartella corrente che definisce uno stack.aws cloudformation create-stack-set \ --stack-set-namemy-stack-set\ --template-bodyfile://template.yaml\ --description"SNS topic"Output:
{ "StackSetId": "my-stack-set:8d0f160b-d157-xmpl-a8e6-c0ce8e5d8cc1" }Per aggiungere istanze di stack al set di stack, utilizzare il comando
create-stack-instances.-
Per informazioni dettagliate sull’API, consulta CreateStackSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare create-stack.
- AWS CLI
-
Come creare uno stack AWS CloudFormation
Il seguente comando
create-stackscrea uno stack denominatomyteststackutilizzando il modellosampletemplate.json:aws cloudformation create-stack --stack-namemyteststack--template-bodyfile://sampletemplate.json--parametersParameterKey=KeyPairName,ParameterValue=TestKeyParameterKey=SubnetIDs,ParameterValue=SubnetID1\\,SubnetID2Output:
{ "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896" }Per ulteriori informazioni, consulta Stacks nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta CreateStack
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare deactivate-type.
- AWS CLI
-
Come disattivare un tipo
L’esempio
deactivate-typeseguente disattiva un’estensione pubblica precedentemente attivata in questo account e Regione.aws cloudformation deactivate-type \ --regionus-west-2\ --typeMODULE\ --type-nameExample::Test::Type::MODULEQuesto comando non produce alcun output.
Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DeactivateType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-change-set.
- AWS CLI
-
Per eliminare un set di modifiche
L’esempio
delete-change-setseguente elimina un set di modifiche specificando il nome del set di modifiche e il nome dello stack.aws cloudformation delete-change-set \ --stack-namemy-stack\ --change-set-namemy-change-setQuesto comando non produce alcun output.
L’esempio
delete-change-setseguente elimina un set di modifiche specificando l’ARN completo del set di modifiche.aws cloudformation delete-change-set \ --change-set-namearn:aws:cloudformation:us-east-2:123456789012:changeSet/my-change-set/4eca1a01-e285-xmpl-8026-9a1967bfb4b0Questo comando non produce alcun output.
-
Per informazioni dettagliate sull’API, consulta DeleteChangeSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-stack-instances.
- AWS CLI
-
Come eliminare istanze di stack
L’esempio
delete-stack-instancesseguente elimina le istanze di uno stack impostato in due account in due Regioni e termina gli stack.aws cloudformation delete-stack-instances \ --stack-set-namemy-stack-set\ --accounts123456789012567890123456\ --regionsus-east-1us-west-1\ --no-retain-stacksOutput:
{ "OperationId": "ad49f10c-fd1d-413f-a20a-8de6e2fa8f27" }Per eliminare un set di stack vuoto, utilizzare il comando
delete-stack-set.-
Per informazioni dettagliate sull’API, consulta DeleteStackInstances
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-stack-set.
- AWS CLI
-
Come eliminare un set di stack
Il comando seguente elimina il set di stack vuoto specificato. Il set di stack deve essere vuoto.
aws cloudformation delete-stack-set \ --stack-set-namemy-stack-setQuesto comando non produce alcun output.
Per eliminare le istanze dal set di stack, utilizzare il comando
delete-stack-instances.-
Per informazioni dettagliate sull’API, consulta DeleteStackSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare delete-stack.
- AWS CLI
-
Come eliminare uno stack
L’esempio
delete-stackseguente elimina lo stack specificato.aws cloudformation delete-stack \ --stack-namemy-stackQuesto comando non produce alcun output.
-
Per informazioni dettagliate sull’API, consulta DeleteStack
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare deploy.
- AWS CLI
-
Il comando seguente implementa il modello denominato
template.jsonin uno stack denominatomy-new-stack:aws cloudformation deploy --template-file/path_to_template/template.json--stack-namemy-new-stack--parameter-overridesKey1=Value1Key2=Value2--tagsKey1=Value1Key2=Value2-
Per informazioni dettagliate sull’API, consulta Deploy
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare deregister-type.
- AWS CLI
-
Come annullare la registrazione di una versione del tipo
L’esempio
deregister-typeseguente rimuove la versione del tipo specificata dall’utilizzo attivo nel registro CloudFormation, in modo che non possa più essere utilizzata nelle operazioni CloudFormation.aws cloudformation deregister-type \ --typeRESOURCE\ --type-nameMy::Logs::LogGroup\ --version-id00000002Questo comando non produce alcun output.
Per ulteriori informazioni, consulta Using the CloudFormation Registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DeregisterType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-account-limits.
- AWS CLI
-
Come ottenere informazioni sui limiti dell’account
Il comando seguente recupera un elenco di limiti regionali per l’account corrente.
aws cloudformation describe-account-limitsOutput:
{ "AccountLimits": [ { "Name": "StackLimit", "Value": 200 }, { "Name": "StackOutputsLimit", "Value": 60 }, { "Name": "ConcurrentResourcesLimit", "Value": 2500 } ] }-
Per informazioni dettagliate sull’API, consulta DescribeAccountLimits
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-change-set.
- AWS CLI
-
Come ottenere informazioni su un set di modifiche
L’esempio
describe-change-setseguente visualizza i dettagli del set di modifiche specificato tramite il nome del set di modifiche e il nome dello stack.aws cloudformation describe-change-set \ --change-set-namemy-change-set\ --stack-namemy-stackL’esempio
describe-change-setseguente visualizza i dettagli del set di modifiche specificato tramite l’ARN completo del set di modifiche:aws cloudformation describe-change-set \ --change-set-namearn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784Output:
{ "Changes": [ { "Type": "Resource", "ResourceChange": { "Action": "Modify", "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "Replacement": "False", "Scope": [ "Properties" ], "Details": [ { "Target": { "Attribute": "Properties", "Name": "Timeout", "RequiresRecreation": "Never" }, "Evaluation": "Static", "ChangeSource": "DirectModification" } ] } } ], "ChangeSetName": "my-change-set", "ChangeSetId": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/4eca1a01-e285-xmpl-8026-9a1967bfb4b0", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "StackName": "my-stack", "Description": null, "Parameters": null, "CreationTime": "2019-10-02T05:20:56.651Z", "ExecutionStatus": "AVAILABLE", "Status": "CREATE_COMPLETE", "StatusReason": null, "NotificationARNs": [], "RollbackConfiguration": {}, "Capabilities": [ "CAPABILITY_IAM" ], "Tags": null }-
Per informazioni dettagliate sull’API, consulta DescribeChangeSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-publisher.
- AWS CLI
-
Come descrivere un publisher
L’esempio
describe-publisherseguente configura le informazioni per un publisher.aws cloudformation describe-publisher \ --regionus-west-2\ --publisher-id000q6TfUovXsEMmgKowxDZLlwqr2QUshOutput:
{ "PublisherId": "000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c", "PublisherStatus": "VERIFIED", "IdentityProvider": "AWS_Marketplace", "PublisherProfile": "https://aws.amazon.com/marketplace/seller-profile?id=2c5dc1f0-17cd-4259-8e46-822a83gdtegd" }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DescribePublisher
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-drift-detection-status.
- AWS CLI
-
Come controllare lo stato di un’operazione di rilevamento delle deviazioni
L’esempio
describe-stack-drift-detection-statusseguente mostra lo stato di un’operazione di rilevamento delle deviazioni. Per ottenere l’ID, eseguire il comandodetect-stack-drift.aws cloudformation describe-stack-drift-detection-status \ --stack-drift-detection-id1a229160-e4d9-xmpl-ab67-0a4f93df83d4Output:
{ "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "StackDriftDetectionId": "1a229160-e4d9-xmpl-ab67-0a4f93df83d4", "StackDriftStatus": "DRIFTED", "DetectionStatus": "DETECTION_COMPLETE", "DriftedStackResourceCount": 1, "Timestamp": "2019-10-02T05:54:30.902Z" }-
Per informazioni dettagliate sull’API, consulta DescribeStackDriftDetectionStatus
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-events.
- AWS CLI
-
Come descrivere gli eventi dello stack
L’esempio
describe-stack-eventsseguente visualizza i 2 eventi più recenti per lo stack specificato.aws cloudformation describe-stack-events \ --stack-namemy-stack\ --max-items2{"StackEvents":[{"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "EventId": "4e1516d0-e4d6-xmpl-b94f-0a51958a168c", "StackName": "my-stack", "LogicalResourceId": "my-stack", "PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "ResourceType": "AWS::CloudFormation::Stack", "Timestamp": "2019-10-02T05:34:29.556Z", "ResourceStatus":"UPDATE_COMPLETE"},{"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "EventId": "4dd3c810-e4d6-xmpl-bade-0aaf8b31ab7a", "StackName": "my-stack", "LogicalResourceId": "my-stack", "PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "ResourceType": "AWS::CloudFormation::Stack", "Timestamp": "2019-10-02T05:34:29.127Z", "ResourceStatus":"UPDATE_COMPLETE_CLEANUP_IN_PROGRESS"}],"NextToken":"eyJOZXh0VG9XMPLiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ=="}-
Per informazioni dettagliate sull’API, consulta DescribeStackEvents
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-instance.
- AWS CLI
-
Come descrivere un’istanza di stack
Il comando seguente descrive un’istanza del set di stack specificato impostato nell’account e nella Regione specificati. Il set di stack si trova nella Regione e nell’account correnti e l’istanza si trova nella Regione
us-west-2dell’account123456789012:aws cloudformation describe-stack-instance \ --stack-set-namemy-stack-set\ --stack-instance-account123456789012\ --stack-instance-regionus-west-2Output:
{ "StackInstance": { "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Region": "us-west-2", "Account": "123456789012", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532/4287f9a0-e615-xmpl-894a-12b31d3117be", "ParameterOverrides": [], "Status": "OUTDATED", "StatusReason": "ResourceLogicalId:ConfigBucket, ResourceType:AWS::S3::Bucket, ResourceStatusReason:You have attempted to create more buckets than allowed (Service: Amazon S3; Status Code: 400; Error Code: TooManyBuckets; Request ID: F7F21CXMPL580224; S3 Extended Request ID: egd/Fdt89BXMPLyiqbMNljVk55Yqqvi3NYW2nKLUVWhUGEhNfCmZdyj967lhriaG/dWMobSO40o=)." } }-
Per informazioni dettagliate sull’API, consulta DescribeStackInstance
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-resource-drifts.
- AWS CLI
-
Come ottenere informazioni sulle risorse con deviazioni rispetto alla definizione dello stack
Il seguente comando visualizza informazioni sulle risorse con deviazioni per lo stack specificato. Per avviare il rilevamento delle deviazioni, utilizzare il comando
detect-stack-drift:aws cloudformation describe-stack-resource-drifts \ --stack-namemy-stackL’output mostra una funzione Lambda AWS che è stata modificata fuori banda:
{ "StackResourceDrifts": [ { "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", "ExpectedProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":128,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":900,\"TracingConfig\":{\"Mode\":\"Active\"}}", "ActualProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":256,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":22,\"TracingConfig\":{\"Mode\":\"Active\"}}", "PropertyDifferences": [ { "PropertyPath": "/MemorySize", "ExpectedValue": "128", "ActualValue": "256", "DifferenceType": "NOT_EQUAL" }, { "PropertyPath": "/Timeout", "ExpectedValue": "900", "ActualValue": "22", "DifferenceType": "NOT_EQUAL" } ], "StackResourceDriftStatus": "MODIFIED", "Timestamp": "2019-10-02T05:54:44.064Z" } ] }-
Per informazioni dettagliate sull’API, consulta DescribeStackResourceDrifts
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-resource.
- AWS CLI
-
Come ottenere informazioni su una risorsa di stack
L’esempio
describe-stack-resourceseguente visualizza i dettagli della risorsa denominataMyFunctionnello stack specificato.aws cloudformation describe-stack-resource \ --stack-nameMyStack\ --logical-resource-idMyFunctionOutput:
{ "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" } } }-
Per informazioni dettagliate sull’API, consulta DescribeStackResource
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-resources.
- AWS CLI
-
Come ottenere informazioni su una risorsa di stack
L’esempio
describe-stack-resourcesseguente visualizza i dettagli delle risorse nello stack specificato.aws cloudformation describe-stack-resources \ --stack-namemy-stackOutput:
{ "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 informazioni dettagliate sull’API, consulta DescribeStackResources
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-set-operation.
- AWS CLI
-
Come ottenere informazioni su un’operazione di set di stack
L’esempio describe-stack-set-operation` seguente visualizza i dettagli di un’operazione di aggiornamento sul set di stack specificato.
aws cloudformation describe-stack-set-operation \ --stack-set-nameenable-config\ --operation-id35d45ebc-ed88-xmpl-ab59-0197a1fc83a0Output:
{ "StackSetOperation": { "OperationId": "35d45ebc-ed88-xmpl-ab59-0197a1fc83a0", "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Action": "UPDATE", "Status": "SUCCEEDED", "OperationPreferences": { "RegionOrder": [ "us-east-1", "us-west-2", "eu-west-1", "us-west-1" ], "FailureToleranceCount": 7, "MaxConcurrentCount": 2 }, "AdministrationRoleARN": "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole", "ExecutionRoleName": "AWSCloudFormationStackSetExecutionRole", "CreationTimestamp": "2019-10-03T16:28:44.377Z", "EndTimestamp": "2019-10-03T16:42:08.607Z" } }-
Per informazioni dettagliate sull’API, consulta DescribeStackSetOperation
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stack-set.
- AWS CLI
-
Come ottenere informazioni su un set di stack
L’esempio describe-stack-set` seguente visualizza i dettagli del set di stack specificato.
aws cloudformation describe-stack-set \ --stack-set-namemy-stack-setOutput:
{ "StackSet": { "StackSetName": "my-stack-set", "StackSetId": "my-stack-set:296a3360-xmpl-40af-be78-9341e95bf743", "Description": "Create an Amazon SNS topic", "Status": "ACTIVE", "TemplateBody": "AWSTemplateFormatVersion: '2010-09-09'\nDescription: An AWS SNS topic\nResources:\n topic:\n Type: AWS::SNS::Topic", "Parameters": [], "Capabilities": [], "Tags": [], "StackSetARN": "arn:aws:cloudformation:us-west-2:123456789012:stackset/enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "AdministrationRoleARN": "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole", "ExecutionRoleName": "AWSCloudFormationStackSetExecutionRole" } }-
Per informazioni dettagliate sull’API, consulta DescribeStackSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-stacks.
- AWS CLI
-
Come descrivere gli stack AWS CloudFormation
Il comando
describe-stacksseguente mostra le informazioni di riepilogo per lo stackmyteststack:aws cloudformation describe-stacks --stack-namemyteststackOutput:
{ "Stacks": [ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896", "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Tags": [], "Outputs": [ { "Description": "Name of S3 bucket to hold website content", "OutputKey": "BucketName", "OutputValue": "myteststack-s3bucket-jssofi1zie2w" } ], "StackStatusReason": null, "CreationTime": "2013-08-23T01:02:15.422Z", "Capabilities": [], "StackName": "myteststack", "StackStatus": "CREATE_COMPLETE", "DisableRollback": false } ] }Per ulteriori informazioni, consulta Stacks nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DescribeStacks
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-type-registration.
- AWS CLI
-
Come visualizzare le informazioni di registrazione del tipo
L’esempio
describe-type-registrationseguente visualizza informazioni sulla registrazione del tipo specificato, inclusi lo stato, il tipo e la versione correnti del tipo.aws cloudformation describe-type-registration \ --registration-tokena1b2c3d4-5678-90ab-cdef-EXAMPLE11111Output:
{ "ProgressStatus": "COMPLETE", "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup", "Description": "Deployment is currently in DEPLOY_STAGE of status COMPLETED; ", "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup/00000001" }Per ulteriori informazioni, consulta Using the CloudFormation Registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DescribeTypeRegistration
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare describe-type.
- AWS CLI
-
Come visualizzare le informazioni sul tipo
L’esempio
describe-typeseguente visualizza le informazioni sul tipo specificato.aws cloudformation describe-type \ --type-nameMy::Logs::LogGroup\ --typeRESOURCEOutput:
{ "SourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs.git", "Description": "Customized resource derived from AWS::Logs::LogGroup", "TimeCreated": "2019-12-03T23:29:33.321Z", "Visibility": "PRIVATE", "TypeName": "My::Logs::LogGroup", "LastUpdated": "2019-12-03T23:29:33.321Z", "DeprecatedStatus": "LIVE", "ProvisioningType": "FULLY_MUTABLE", "Type": "RESOURCE", "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup/00000001", "Schema": "[details omitted]" }Per ulteriori informazioni, consulta Using the CloudFormation Registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DescribeType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare detect-stack-drift.
- AWS CLI
-
Come rilevare risorse con deviazioni
L’esempio
detect-stack-driftseguente avvia il rilevamento delle deviazioni per lo stack specificato.aws cloudformation detect-stack-drift \ --stack-namemy-stackOutput:
{ "StackDriftDetectionId": "1a229160-e4d9-xmpl-ab67-0a4f93df83d4" }È quindi possibile utilizzare questo ID con il comando
describe-stack-resource-driftsper descrivere le risorse con deviazioni.-
Per informazioni dettagliate sull’API, consulta DetectStackDrift
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare detect-stack-resource-drift.
- AWS CLI
-
Come rilevare la deviazione di una risorsa
L’esempio
detect-stack-resource-driftseguente verifica la presenza di deviazione per una risorsa denominataMyFunctionin uno stack denominatoMyStack:aws cloudformation detect-stack-resource-drift \ --stack-nameMyStack\ --logical-resource-idMyFunctionL’output mostra una funzione Lambda AWS che è stata modificata fuori banda:
{ "StackResourceDrift": { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/MyStack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "MyFunction", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "ExpectedProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":128,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":900,\"TracingConfig\":{\"Mode\":\"Active\"}}", "ActualProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":256,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":22,\"TracingConfig\":{\"Mode\":\"Active\"}}", "PropertyDifferences": [ { "PropertyPath": "/MemorySize", "ExpectedValue": "128", "ActualValue": "256", "DifferenceType": "NOT_EQUAL" }, { "PropertyPath": "/Timeout", "ExpectedValue": "900", "ActualValue": "22", "DifferenceType": "NOT_EQUAL" } ], "StackResourceDriftStatus": "MODIFIED", "Timestamp": "2019-10-02T05:58:47.433Z" } }-
Per informazioni dettagliate sull’API, consulta DetectStackResourceDrift
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare detect-stack-set-drift.
- AWS CLI
-
Come rilevare la deviazione su un set di stack e su tutte le istanze di stack associate
L’esempio
detect-stack-set-driftseguente avvia le operazioni di rilevamento delle deviazioni sul set di stack specificato, incluse tutte le istanze di stack associate al set di stack, e restituisce un ID di operazione che può essere utilizzato per tenere traccia dello stato dell’operazione di deviazione.aws cloudformation detect-stack-set-drift \ --stack-set-namestack-set-drift-exampleOutput:
{ "OperationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }Per ulteriori informazioni, consulta Detecting Unmanaged Configuration Changes in Stack Sets nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta DetectStackSetDrift
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare estimate-template-cost.
- AWS CLI
-
Come stimare il costo del modello
L’esempio
estimate-template-costseguente genera una stima del costo per un modello denominatotemplate.yamlnella cartella corrente.aws cloudformation estimate-template-cost \ --template-bodyfile://template.yamlOutput:
{ "Url": "http://calculator.s3.amazonaws.com/calc5.html?key=cloudformation/7870825a-xmpl-4def-92e7-c4f8dd360cca" }-
Per informazioni dettagliate sull’API, consulta EstimateTemplateCost
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare execute-change-set.
- AWS CLI
-
Per eseguire un set di modifiche
L’esempio
execute-change-setseguente esegue un set di modifiche specificato tramite il nome del set di modifiche e il nome dello stack.aws cloudformation execute-change-set \ --change-set-namemy-change-set\ --stack-namemy-stackL’esempio
execute-change-setseguente esegue un set di modifiche specificato tramite l’ARN completo del set di modifiche.aws cloudformation execute-change-set \ --change-set-namearn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784-
Per informazioni dettagliate sull’API, consulta ExecuteChangeSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-stack-policy.
- AWS CLI
-
Come visualizzare una policy di stack
L’esempio
get-stack-policyseguente visualizza la policy di stack per lo stack specificato. Per collegare una policy a uno stack, utilizzare il comandoset-stack-policy.aws cloudformation get-stack-policy \ --stack-namemy-stackOutput:
{ "StackPolicyBody": "{\n \"Statement\" : [\n {\n \"Effect\" : \"Allow\",\n \"Action\" : \"Update:*\",\n \"Principal\": \"*\",\n \"Resource\" : \"*\"\n },\n {\n \"Effect\" : \"Deny\",\n \"Action\" : \"Update:*\",\n \"Principal\": \"*\",\n \"Resource\" : \"LogicalResourceId/bucket\"\n }\n ]\n}\n" }-
Per informazioni dettagliate sull’API, consulta GetStackPolicy
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-template-summary.
- AWS CLI
-
Come visualizzare un riepilogo del modello
Il comando seguente visualizza informazioni di riepilogo sulle risorse e sui metadati per il file modello specificato.
aws cloudformation get-template-summary \ --template-bodyfile://template.yamlOutput:
{ "Parameters": [], "Description": "A VPC and subnets.", "ResourceTypes": [ "AWS::EC2::VPC", "AWS::EC2::Subnet", "AWS::EC2::Subnet", "AWS::EC2::RouteTable", "AWS::EC2::VPCEndpoint", "AWS::EC2::SubnetRouteTableAssociation", "AWS::EC2::SubnetRouteTableAssociation", "AWS::EC2::VPCEndpoint" ], "Version": "2010-09-09" }-
Per informazioni dettagliate sull’API, consulta GetTemplateSummary
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare get-template.
- AWS CLI
-
Come visualizzare il corpo del modello per uno stack AWS CloudFormation
Il comando
get-templateseguente mostra il modello per lo stackmyteststack:aws cloudformation get-template --stack-namemyteststackOutput:
{ "TemplateBody": { "AWSTemplateFormatVersion": "2010-09-09", "Outputs": { "BucketName": { "Description": "Name of S3 bucket to hold website content", "Value": { "Ref": "S3Bucket" } } }, "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Resources": { "S3Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "PublicRead" } } } } }-
Per informazioni dettagliate sull’API, consulta GetTemplate
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-change-sets.
- AWS CLI
-
Come elencare i set di modifiche
L’esempio
list-change-setsseguente visualizza un elenco dei set di modifiche in sospeso per lo stack specificato.aws cloudformation list-change-sets \ --stack-namemy-stackOutput:
{ "Summaries": [ { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "StackName": "my-stack", "ChangeSetId": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/70160340-7914-xmpl-bcbf-128a1fa78b5d", "ChangeSetName": "my-change-set", "ExecutionStatus": "AVAILABLE", "Status": "CREATE_COMPLETE", "CreationTime": "2019-10-02T05:38:54.297Z" } ] }-
Per informazioni dettagliate sull’API, consulta ListChangeSets
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-exports.
- AWS CLI
-
Come elencare le esportazioni
L’esempio
list-exportsseguente visualizza un elenco delle esportazioni dagli stack nella Regione corrente.aws cloudformation list-exportsOutput:
{ "Exports": [ { "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800", "Name": "private-vpc-subnet-a", "Value": "subnet-07b410xmplddcfa03" }, { "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800", "Name": "private-vpc-subnet-b", "Value": "subnet-075ed3xmplebd2fb1" }, { "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800", "Name": "private-vpc-vpcid", "Value": "vpc-011d7xmpl100e9841" } ] }-
Per informazioni dettagliate sull’API, consulta ListExports
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-imports.
- AWS CLI
-
Come elencare le importazioni
L’esempio
list-importsseguente elenca gli stack che importano l’esportazione specificata. Per ottenere l’elenco delle esportazioni disponibili, utilizzare il comandolist-exports.aws cloudformation list-imports \ --export-nameprivate-vpc-vpcidOutput:
{ "Imports": [ "my-database-stack" ] }-
Per informazioni dettagliate sull’API, consulta ListImports
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-stack-instances.
- AWS CLI
-
Come elencare le istanze di uno stack
L’esempio
list-stack-instancesseguente elenca le istanze create dal set di stack specificato.aws cloudformation list-stack-instances \ --stack-set-nameenable-configL’output di esempio include i dettagli su uno stack che non è stato aggiornato a causa di un errore:
{ "Summaries": [ { "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Region": "us-west-2", "Account": "123456789012", "StackId": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/StackSet-enable-config-35a6ac50-d9f8-4084-86e4-7da34d5de4c4/a1631cd0-e5fb-xmpl-b474-0aa20f14f06e", "Status": "CURRENT" }, { "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Region": "us-west-2", "Account": "123456789012", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532/eab53680-e5fa-xmpl-ba14-0a522351f81e", "Status": "OUTDATED", "StatusReason": "ResourceLogicalId:ConfigDeliveryChannel, ResourceType:AWS::Config::DeliveryChannel, ResourceStatusReason:Failed to put delivery channel 'StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532-ConfigDeliveryChannel-1OJWJ7XD59WR0' because the maximum number of delivery channels: 1 is reached. (Service: AmazonConfig; Status Code: 400; Error Code: MaxNumberOfDeliveryChannelsExceededException; Request ID: d14b34a0-ef7c-xmpl-acf8-8a864370ae56)." } ] }-
Per informazioni dettagliate sull’API, consulta ListStackInstances
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-stack-resources.
- AWS CLI
-
Come elencare le risorse in uno stack
Il comando seguente visualizza l’elenco delle risorse nello stack specificato.
aws cloudformation list-stack-resources \ --stack-namemy-stackOutput:
{ "StackResourceSummaries": [ { "LogicalResourceId": "bucket", "PhysicalResourceId": "my-stack-bucket-1vc62xmplgguf", "ResourceType": "AWS::S3::Bucket", "LastUpdatedTimestamp": "2019-10-02T04:34:11.345Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "LastUpdatedTimestamp": "2019-10-02T05:34:27.989Z", "ResourceStatus": "UPDATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "LogicalResourceId": "functionRole", "PhysicalResourceId": "my-functionRole-HIZXMPLEOM9E", "ResourceType": "AWS::IAM::Role", "LastUpdatedTimestamp": "2019-10-02T04:34:06.350Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } } ] }-
Per informazioni dettagliate sull’API, consulta ListStackResources
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-stack-set-operation-results.
- AWS CLI
-
Come elencare i risultati dell’operazione sul set di stack
Il comando seguente visualizza i risultati di un’operazione di aggiornamento sulle istanze del set di stack specificato.
aws cloudformation list-stack-set-operation-results \ --stack-set-nameenable-config\ --operation-id35d45ebc-ed88-xmpl-ab59-0197a1fc83a0Output:
{ "Summaries": [ { "Account": "223456789012", "Region": "us-west-2", "Status": "SUCCEEDED", "AccountGateResult": { "Status": "SKIPPED", "StatusReason": "Function not found: arn:aws:lambda:eu-west-1:223456789012:function:AWSCloudFormationStackSetAccountGate" } }, { "Account": "223456789012", "Region": "ap-south-1", "Status": "CANCELLED", "StatusReason": "Cancelled since failure tolerance has exceeded" } ] }Nota: lo stato
SKIPPEDdiAccountGateResultè previsto per le operazioni con esito positivo, a meno che non si crei una funzione di controllo dell’account.-
Per informazioni dettagliate sull’API, consulta ListStackSetOperationResults
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-stack-set-operations.
- AWS CLI
-
Come elencare le operazioni sul set di stack
L’esempio
list-stack-set-operationsseguente visualizza l’elenco delle operazioni più recenti sul set di stack specificato.aws cloudformation list-stack-set-operations \ --stack-set-namemy-stack-setOutput:
{ "Summaries": [ { "OperationId": "35d45ebc-ed88-xmpl-ab59-0197a1fc83a0", "Action": "UPDATE", "Status": "SUCCEEDED", "CreationTimestamp": "2019-10-03T16:28:44.377Z", "EndTimestamp": "2019-10-03T16:42:08.607Z" }, { "OperationId": "891aa98f-7118-xmpl-00b2-00954d1dd0d6", "Action": "UPDATE", "Status": "FAILED", "CreationTimestamp": "2019-10-03T15:43:53.916Z", "EndTimestamp": "2019-10-03T15:45:58.925Z" } ] }-
Per informazioni dettagliate sull’API, consulta ListStackSetOperations
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-stack-sets.
- AWS CLI
-
Come elencare i set di stack
L’esempio
list-stack-setsseguente visualizza l’elenco dei set di stack nella Regione e nell’account correnti.aws cloudformation list-stack-setsOutput:
{ "Summaries": [ { "StackSetName": "enable-config", "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Description": "Enable AWS Config", "Status": "ACTIVE" } ] }-
Per informazioni dettagliate sull’API, consulta ListStackSets
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-stacks.
- AWS CLI
-
Come elencare gli stack AWS CloudFormation
Il comando
list-stacksseguente mostra un riepilogo di tutti gli stack con statoCREATE_COMPLETE:aws cloudformation list-stacks --stack-status-filterCREATE_COMPLETEOutput:
[ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896", "TemplateDescription": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "StackStatusReason": null, "CreationTime": "2013-08-26T03:27:10.190Z", "StackName": "myteststack", "StackStatus": "CREATE_COMPLETE" } ]-
Per informazioni dettagliate sull’API, consulta ListStacks
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-type-registrations.
- AWS CLI
-
Come elencare le registrazioni completate di un tipo
L’esempio
list-type-registrationsseguente visualizza un elenco delle registrazioni di tipo completate per il tipo specificato.aws cloudformation list-type-registrations \ --typeRESOURCE\ --type-nameMy::Logs::LogGroup\ --registration-status-filterCOMPLETEOutput:
{ "RegistrationTokenList": [ "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333" ] }Per ulteriori informazioni, consulta Using the CloudFormation Registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta ListTypeRegistrations
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-type-versions.
- AWS CLI
-
Come elencare la versione di un’estensione
L’esempio
list-type-versionsseguente restituisce informazioni di riepilogo sulle versioni di un’estensione.aws cloudformation list-type-versions \ --endpointhttps://example.com\ --regionus-west-2\ --typeRESOURCE\ --type-nameMy::Resource::Example\ --publisher-id123456789012Questo comando non produce alcun output.
Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta ListTypeVersions
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare list-types.
- AWS CLI
-
Come elencare i tipi di risorsa privata di un account
L’esempio
list-typesseguente visualizza un elenco dei tipi di risorsa privata attualmente registrati nell’account AWS corrente.aws cloudformation list-typesOutput:
{ "TypeSummaries": [ { "Description": "WordPress blog resource for internal use", "LastUpdated": "2019-12-04T18:28:15.059Z", "TypeName": "My::WordPress::BlogExample", "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-WordPress-BlogExample", "DefaultVersionId": "00000005", "Type": "RESOURCE" }, { "Description": "Customized resource derived from AWS::Logs::LogGroup", "LastUpdated": "2019-12-04T18:28:15.059Z", "TypeName": "My::Logs::LogGroup", "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup", "DefaultVersionId": "00000003", "Type": "RESOURCE" } ] }Per ulteriori informazioni, consulta Using the CloudFormation Registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta ListTypes
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare package.
- AWS CLI
-
Il comando seguente esporta un modello denominato
template.jsoncaricando gli artefatti locali nel bucket S3bucket-namee scrive il modello esportato inpackaged-template.json.aws cloudformation package --template-file/path_to_template/template.json--s3-bucketbucket-name--output-template-filepackaged-template.json--use-json-
Per informazioni dettagliate sull’API, consulta Package
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare publish-type.
- AWS CLI
-
Come pubblicare un’estensione
L’esempio
publish-typeseguente pubblica l’estensione specificata nel registro CloudFormation come estensione pubblica in questa Regione.aws cloudformation publish-type \ --regionus-west-2\ --typeRESOURCE\ --type-nameExample::Test::1234567890abcdef0Output:
{ "PublicTypeArn":"arn:aws:cloudformation:us-west-2::type/resource/000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c/Example-Test-1234567890abcdef0/1.0.0" }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta PublishType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare register-publisher.
- AWS CLI
-
Come registrare un publisher
L’esempio
register-publisherseguente registra un publisher e accetta il parametro dei termini e delle condizioni.aws cloudformation register-publisher \ --regionus-west-2\ --accept-terms-and-conditionsOutput:
{ "PublisherId": "000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c" }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta RegisterPublisher
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare register-type.
- AWS CLI
-
Per registrare un tipo di risorsa
L’esempio
register-typeseguente registra il tipo di risorsa specificato come tipo di risorsa privata nell’account dell’utente.aws cloudformation register-type \ --type-nameMy::Organization::ResourceName\ --schema-handler-packages3://bucket_name/my-organization-resource_name.zip\ --typeRESOURCEOutput:
{ "RegistrationToken": "f5525280-104e-4d35-bef5-8f1f1example" }Per ulteriori informazioni, consulta Registering Resource Providers nella Guida per l’utente dell’interfaccia a riga di comando di CloudFormation per lo sviluppo del tipo.
-
Per informazioni dettagliate sull’API, consulta RegisterType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare set-stack-policy.
- AWS CLI
-
Come applicare una policy di stack
L’esempio
set-stack-policyseguente disabilita gli aggiornamenti per la risorsa specificata nello stack specificato.stack-policy.jsonè un documento JSON che definisce le operazioni consentite sulle risorse nello stack.aws cloudformation set-stack-policy \ --stack-namemy-stack\ --stack-policy-bodyfile://stack-policy.jsonOutput:
{ "Statement" : [ { "Effect" : "Allow", "Action" : "Update:*", "Principal": "*", "Resource" : "*" }, { "Effect" : "Deny", "Action" : "Update:*", "Principal": "*", "Resource" : "LogicalResourceId/bucket" } ] }-
Per informazioni dettagliate sull’API, consulta SetStackPolicy
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare set-type-configuration.
- AWS CLI
-
Come configurare i dati
L’esempio
set-type-configurationseguente specifica i dati di configurazione per un’estensione CloudFormation registrata, nell’account e nella Regione specificati.aws cloudformation set-type-configuration \ --regionus-west-2\ --typeRESOURCE\ --type-nameExample::Test::Type\ --configuration-aliasdefault\ --configuration "{\"CredentialKey\": \"testUserCredential\"}"Output:
{ "ConfigurationArn": "arn:aws:cloudformation:us-west-2:123456789012:type-configuration/resource/Example-Test-Type/default" }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta SetTypeConfiguration
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare set-type-default-version.
- AWS CLI
-
Come impostare una versione predefinita del tipo
L’esempio
set-type-default-versionseguente imposta la versione del tipo specificata da utilizzare come predefinita per questo tipo.aws cloudformation set-type-default-version \ --typeRESOURCE\ --type-nameMy::Logs::LogGroup\ --version-id00000003Questo comando non produce alcun output.
Per ulteriori informazioni, consulta Using the CloudFormation Registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta SetTypeDefaultVersion
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare signal-resource.
- AWS CLI
-
Come segnalare una risorsa
L’esempio
signal-resourceseguente segnalasuccessper soddisfare la condizione di attesa denominataMyWaitConditionnello stack denominatomy-stack.aws cloudformation signal-resource \ --stack-namemy-stack\ --logical-resource-idMyWaitCondition\ --unique-id1234\ --statusSUCCESSQuesto comando non produce alcun output.
-
Per informazioni dettagliate sull’API, consulta SignalResource
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare stop-stack-set-operation.
- AWS CLI
-
Come arrestare un’operazione del set di stack
L’esempio
stop-stack-set-operationseguente arresta un’operazione di aggiornamento in corso sul set di stack specificato.aws cloudformation stop-stack-set-operation \ --stack-set-namemy-stack-set\ --operation-id1261cd27-490b-xmpl-ab42-793a896c69e6Questo comando non produce alcun output.
-
Per informazioni dettagliate sull’API, consulta StopStackSetOperation
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare test-type.
- AWS CLI
-
Come testare un’estensione
L’esempio
test-typeseguente testa un’estensione registrata per verificare che soddisfi tutti i requisiti necessari per essere pubblicata nel registro CloudFormation.aws cloudformation test-type \ --arnarn:aws:cloudformation:us-west-2:123456789012:type/resource/Sample-Test-Resource123/00000001Output:
{ "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Sample-Test-Resource123/00000001" }Per ulteriori informazioni, consulta Using the AWS CloudFormation registry nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta TestType
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare update-stack-instances.
- AWS CLI
-
Come aggiornare le istanze di stack
L’esempio
update-stack-instancesseguente riprova a eseguire un aggiornamento sulle istanze di stack in due account presenti in due Regioni con le impostazioni più recenti. L’impostazione della tolleranza ai guasti specificata garantisce che l’aggiornamento venga tentato in tutti gli account e le Regioni, anche se non è possibile aggiornare alcuni stack.aws cloudformation update-stack-instances \ --stack-set-namemy-stack-set\ --accounts123456789012567890123456\ --regionsus-east-1us-west-2\ --operation-preferencesFailureToleranceCount=3Output:
{ "OperationId": "103ebdf2-21ea-xmpl-8892-de5e30733132" }-
Per informazioni dettagliate sull’API, consulta UpdateStackInstances
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare update-stack-set.
- AWS CLI
-
Come aggiornare un set di stack
L’esempio
update-stack-setseguente aggiunge un tag con il nome della chiaveOwnere il valoreITalle istanze di stack nel set di stack specificato.aws cloudformation update-stack-set \ --stack-set-namemy-stack-set\ --use-previous-template \ --tagsKey=Owner,Value=ITOutput:
{ "OperationId": "e2b60321-6cab-xmpl-bde7-530c6f47950e" }-
Per informazioni dettagliate sull’API, consulta UpdateStackSet
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare update-stack.
- AWS CLI
-
Come aggiornare gli stack AWS CloudFormation
Il comando
update-stackseguente aggiorna il modello e i parametri di input per lo stackmystack:aws cloudformation update-stack --stack-namemystack--template-urlhttps://s3.amazonaws.com/sample/updated.template--parametersParameterKey=KeyPairName,ParameterValue=SampleKeyPairParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1\\,SampleSubnetID2Il comando
update-stackseguente aggiorna solo il valore del parametroSubnetIDsper lo stackmystack: Se non si specifica un valore di parametro, viene utilizzato il valore predefinito specificato nel modello:aws cloudformation update-stack --stack-namemystack--template-urlhttps://s3.amazonaws.com/sample/updated.template--parametersParameterKey=KeyPairName,UsePreviousValue=trueParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1\\,UpdatedSampleSubnetID2Il comando
update-stackseguente aggiunge due argomenti di notifica per stack allo stackmystack:aws cloudformation update-stack --stack-namemystack--use-previous-template --notification-arns"arn:aws:sns:use-east-1:123456789012:mytopic1""arn:aws:sns:us-east-1:123456789012:mytopic2"Per ulteriori informazioni, consulta AWS CloudFormation stack updates nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta UpdateStack
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare update-termination-protection.
- AWS CLI
-
Come abilitare la protezione da terminazione
L’esempio
update-termination-protectionseguente abilita la protezione da terminazione nello stack specificato.aws cloudformation update-termination-protection \ --stack-namemy-stack\ --enable-termination-protectionOutput:
{ "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204" }-
Per informazioni dettagliate sull’API, consulta UpdateTerminationProtection
in AWS CLI Command Reference.
-
L’esempio di codice seguente mostra come utilizzare validate-template.
- AWS CLI
-
Come convalidare un modello AWS CloudFormation
Il comando
validate-templateseguente convalida il modellosampletemplate.json:aws cloudformation validate-template --template-bodyfile://sampletemplate.jsonOutput:
{ "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters": [], "Capabilities": [] }Per ulteriori informazioni, consulta Working with AWS CloudFormation Templates nella Guida per l’utente di AWS CloudFormation.
-
Per informazioni dettagliate sull’API, consulta ValidateTemplate
in AWS CLI Command Reference.
-