Esempi di App Runner utilizzando AWS CLI - AWS Command Line Interface

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à.

Esempi di App Runner utilizzando AWS CLI

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface con App Runner.

Le azioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzareassociate-custom-domain.

AWS CLI

Come associare un nome di dominio e il sottodominio www a un servizio

L’esempio associate-custom-domain seguente associa un nome di dominio personalizzato controllato dall’utente a un servizio App Runner. Il nome di dominio è il dominio root example.com, incluso il sottodominio speciale www.example.com.

aws apprunner associate-custom-domain \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "DomainName": "example.com", "EnableWWWSubdomain": true }

Output:

{ "CustomDomain": { "CertificateValidationRecords": [ { "Name": "_70d3f50a94f7c72dc28784cf55db2f6b.example.com", "Status": "PENDING_VALIDATION", "Type": "CNAME", "Value": "_1270c137383c6307b6832db02504c4b0.bsgbmzkfwj.acm-validations.aws." }, { "Name": "_287870d3f50a94f7c72dc4cf55db2f6b.www.example.com", "Status": "PENDING_VALIDATION", "Type": "CNAME", "Value": "_832db01270c137383c6307b62504c4b0.mzkbsgbfwj.acm-validations.aws." } ], "DomainName": "example.com", "EnableWWWSubdomain": true, "Status": "CREATING" }, "DNSTarget": "psbqam834h.us-east-1.awsapprunner.com", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Il seguente esempio di codice mostra come utilizzarecreate-auto-scaling-configuration.

AWS CLI

Come creare una configurazione di dimensionamento automatico ad elevata disponibilità

L’esempio create-auto-scaling-configuration seguente crea una configurazione del dimensionamento automatico ottimizzata per la disponibilità elevata impostando MinSize su 5. Con questa configurazione, App Runner tenta di distribuire le istanze del servizio nella maggior parte delle zone di disponibilità possibili, fino a cinque, a seconda della AWS regione.

La chiamata restituisce un oggetto AutoScalingConfiguration con le altre impostazioni configurate sui valori predefiniti. Nell’esempio, questa è la prima chiamata per creare una configurazione denominata high-availability. La revisione è impostata su 1 ed è l’ultima revisione.

aws apprunner create-auto-scaling-configuration \ --cli-input-json file://input.json

Contenuto di input.json:

{ "AutoScalingConfigurationName": "high-availability", "MinSize": 5 }

Output:

{ "AutoScalingConfiguration": { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1/2f50e7656d7819fead0f59672e68042e", "AutoScalingConfigurationName": "high-availability", "AutoScalingConfigurationRevision": 1, "CreatedAt": "2020-11-03T00:29:17Z", "Latest": true, "Status": "ACTIVE", "MaxConcurrency": 100, "MaxSize": 50, "MinSize": 5 } }

Il seguente esempio di codice mostra come utilizzarecreate-connection.

AWS CLI

Per creare una GitHub connessione

L'create-connectionesempio seguente crea una connessione a un archivio di GitHub codice privato. Lo stato della connessione dopo una chiamata riuscita è PENDING_HANDSHAKE. Questo perché l’handshake di autenticazione con il provider non è ancora avvenuto. Completa l’handshake utilizzando la console App Runner.

aws apprunner create-connection \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ConnectionName": "my-github-connection", "ProviderType": "GITHUB" }

Output:

{ "Connection": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection", "ConnectionName": "my-github-connection", "Status": "PENDING_HANDSHAKE", "CreatedAt": "2020-11-03T00:32:51Z", "ProviderType": "GITHUB" } }

Per ulteriori informazioni, consulta Gestione delle connessioni di App Runner nella Guida per gli sviluppatori di AWS App Runner.

Il seguente esempio di codice mostra come utilizzarecreate-service.

AWS CLI

Esempio 1: come creare un servizio di repository di codice sorgente

L’esempio create-service seguente crea un servizio App Runner basato su un repository di codice sorgente Python.

aws apprunner create-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceName": "python-app", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" }, "CodeConfiguration": { "ConfigurationSource": "API", "CodeConfigurationValues": { "Runtime": "PYTHON_3", "BuildCommand": "pip install -r requirements.txt", "StartCommand": "python server.py", "Port": "8080", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ] } } } }, "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-20T19:05:25Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Esempio 2: come creare un servizio di repository di codice sorgente

L’esempio create-service seguente crea un servizio App Runner basato su un repository di codice sorgente Python.

aws apprunner create-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceName": "python-app", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" }, "CodeConfiguration": { "ConfigurationSource": "API", "CodeConfigurationValues": { "Runtime": "PYTHON_3", "BuildCommand": "pip install -r requirements.txt", "StartCommand": "python server.py", "Port": "8080", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ] } } } }, "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-20T19:05:25Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Esempio 3: come creare un servizio di repository di immagini di origine

L’esempio create-service seguente crea un servizio App Runner basato su un’immagine archiviata in Elastic Container Registry (ECR).

aws apprunner create-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceName": "golang-container-app", "SourceConfiguration": { "AuthenticationConfiguration": { "AccessRoleArn": "arn:aws:iam::123456789012:role/my-ecr-role" }, "AutoDeploymentsEnabled": true, "ImageRepository": { "ImageIdentifier": "123456789012.dkr.ecr.us-east-1.amazonaws.com/golang-app:latest", "ImageConfiguration": { "Port": "8080", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ] }, "ImageRepositoryType": "ECR" } }, "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-06T23:15:30Z", "UpdatedAt": "2020-11-06T23:15:30Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/golang-container-app/51728f8a20ce46d39b25398a6c8e9d1a", "ServiceId": "51728f8a20ce46d39b25398a6c8e9d1a", "ServiceName": "golang-container-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "AccessRoleArn": "arn:aws:iam::123456789012:role/my-ecr-role" }, "AutoDeploymentsEnabled": true, "ImageRepository": { "ImageIdentifier": "123456789012.dkr.ecr.us-east-1.amazonaws.com/golang-app:latest", "ImageConfiguration": { "Port": "8080", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ] }, "ImageRepositoryType": "ECR" } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Il seguente esempio di codice mostra come utilizzaredelete-auto-scaling-configuration.

AWS CLI

Esempio 1: come eliminare l’ultima revisione attiva di una configurazione di dimensionamento automatico

L’esempio delete-auto-scaling-configuration seguente elimina l’ultima revisione attiva di una configurazione di dimensionamento automatico di App Runner. Per eliminare l’ultima revisione attiva, specifica un nome della risorsa Amazon (ARN) che termini con il nome della configurazione, senza includere il componente della revisione.

Nell’esempio, prima di questa azione esistono due revisioni. Pertanto, viene eliminata la revisione 2 (l’ultima). Tuttavia, ora viene mostra "Latest": false, perché, dopo essere stata eliminata, non è più l’ultima revisione attiva.

aws apprunner delete-auto-scaling-configuration \ --cli-input-json file://input.json

Contenuto di input.json:

{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability" }

Output:

{ "AutoScalingConfiguration": { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/2/e76562f50d78042e819fead0f59672e6", "AutoScalingConfigurationName": "high-availability", "AutoScalingConfigurationRevision": 2, "CreatedAt": "2021-02-25T17:42:59Z", "DeletedAt": "2021-03-02T08:07:06Z", "Latest": false, "Status": "INACTIVE", "MaxConcurrency": 30, "MaxSize": 90, "MinSize": 5 } }

Esempio 2: come eliminare una revisione specifica di una configurazione di dimensionamento automatico

L’esempio delete-auto-scaling-configuration seguente elimina una revisione specifica di una configurazione di dimensionamento automatico di App Runner. Per eliminare una revisione specifica, specifica un ARN che includa il numero della revisione.

Nell’esempio, prima di questa azione esistono diverse revisioni. L’azione elimina la revisione 1.

aws apprunner delete-auto-scaling-configuration \ --cli-input-json file://input.json

Contenuto di input.json:

{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1" }

Output:

{ "AutoScalingConfiguration": { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1/2f50e7656d7819fead0f59672e68042e", "AutoScalingConfigurationName": "high-availability", "AutoScalingConfigurationRevision": 1, "CreatedAt": "2020-11-03T00:29:17Z", "DeletedAt": "2021-03-02T08:07:06Z", "Latest": false, "Status": "INACTIVE", "MaxConcurrency": 100, "MaxSize": 50, "MinSize": 5 } }

Il seguente esempio di codice mostra come utilizzaredelete-connection.

AWS CLI

Come eliminare una connessione

L’esempio delete-connection seguente elimina una connessione App Runner. Lo stato della connessione dopo una chiamata riuscita è DELETED. Questo perché la connessione non è più disponibile.

aws apprunner delete-connection \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection" }

Output:

{ "Connection": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection", "ConnectionName": "my-github-connection", "Status": "DELETED", "CreatedAt": "2020-11-03T00:32:51Z", "ProviderType": "GITHUB" } }

Il seguente esempio di codice mostra come utilizzaredelete-service.

AWS CLI

Come eliminare un servizio

L’esempio delete-service seguente elimina un servizio App Runner.

aws apprunner delete-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-20T19:05:25Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Il seguente esempio di codice mostra come utilizzaredescribe-auto-scaling-configuration.

AWS CLI

Esempio 1: come descrivere l’ultima revisione attiva di una configurazione di dimensionamento automatico

L’esempio describe-auto-scaling-configuration seguente ottiene una descrizione dell’ultima revisione attiva di una configurazione di dimensionamento automatico di App Runner. Per descrivere l’ultima revisione attiva, specifica un ARN che termini con il nome della configurazione, senza includere il componente della revisione.

Nell’esempio, esistono due revisioni. Pertanto, viene descritta la revisione 2 (l’ultima). L’oggetto risultante mostra "Latest": true.

aws apprunner describe-auto-scaling-configuration \ --cli-input-json file://input.json

Contenuto di input.json:

{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability" }

Output:

{ "AutoScalingConfiguration": { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/2/e76562f50d78042e819fead0f59672e6", "AutoScalingConfigurationName": "high-availability", "AutoScalingConfigurationRevision": 2, "CreatedAt": "2021-02-25T17:42:59Z", "Latest": true, "Status": "ACTIVE", "MaxConcurrency": 30, "MaxSize": 90, "MinSize": 5 } }

Esempio 2: come descrivere una revisione specifica di una configurazione di dimensionamento automatico

L’esempio describe-auto-scaling-configuration seguente ottiene una descrizione di una revisione specifica di una configurazione di dimensionamento automatico di App Runner. Per descrivere una revisione specifica, specifica un ARN che includa il numero della revisione.

Nell’esempio, esistono diverse revisioni e viene richiesta la revisione 1. L’oggetto risultante mostra "Latest": false.

aws apprunner describe-auto-scaling-configuration \ --cli-input-json file://input.json

Contenuto di input.json:

{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1" }

Output:

{ "AutoScalingConfiguration": { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1/2f50e7656d7819fead0f59672e68042e", "AutoScalingConfigurationName": "high-availability", "AutoScalingConfigurationRevision": 1, "CreatedAt": "2020-11-03T00:29:17Z", "Latest": false, "Status": "ACTIVE", "MaxConcurrency": 100, "MaxSize": 50, "MinSize": 5 } }

Il seguente esempio di codice mostra come utilizzaredescribe-custom-domains.

AWS CLI

Come ottenere le descrizioni dei nomi di dominio personalizzati associati a un servizio

L’esempio describe-custom-domains seguente ottiene le descrizioni e lo stato dei nomi di dominio personalizzati associati a un servizio App Runner.

aws apprunner describe-custom-domains \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "DomainName": "example.com", "EnableWWWSubdomain": true }

Output:

{ "CustomDomains": [ { "CertificateValidationRecords": [ { "Name": "_70d3f50a94f7c72dc28784cf55db2f6b.example.com", "Status": "PENDING_VALIDATION", "Type": "CNAME", "Value": "_1270c137383c6307b6832db02504c4b0.bsgbmzkfwj.acm-validations.aws." }, { "Name": "_287870d3f50a94f7c72dc4cf55db2f6b.www.example.com", "Status": "PENDING_VALIDATION", "Type": "CNAME", "Value": "_832db01270c137383c6307b62504c4b0.mzkbsgbfwj.acm-validations.aws." } ], "DomainName": "example.com", "EnableWWWSubdomain": true, "Status": "PENDING_CERTIFICATE_DNS_VALIDATION" }, { "CertificateValidationRecords": [ { "Name": "_a94f784c70d3f507c72dc28f55db2f6b.deals.example.com", "Status": "SUCCESS", "Type": "CNAME", "Value": "_2db02504c1270c137383c6307b6834b0.bsgbmzkfwj.acm-validations.aws." } ], "DomainName": "deals.example.com", "EnableWWWSubdomain": false, "Status": "ACTIVE" } ], "DNSTarget": "psbqam834h.us-east-1.awsapprunner.com", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Il seguente esempio di codice mostra come utilizzaredescribe-service.

AWS CLI

Come descrivere un servizio

L’esempio describe-service seguente ottiene una descrizione di un servizio App Runner.

aws apprunner describe-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-20T19:05:25Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "RUNNING", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Il seguente esempio di codice mostra come utilizzaredisassociate-custom-domain.

AWS CLI

Come annullare l’associazione di un nome di dominio da un servizio

L’esempio disassociate-custom-domain seguente annulla l’associazione tra il dominio example.com e un servizio App Runner. La chiamata annulla anche l’associazione del sottodominio www.example.com che era associato al dominio root.

aws apprunner disassociate-custom-domain \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "DomainName": "example.com" }

Output:

{ "CustomDomain": { "CertificateValidationRecords": [ { "Name": "_70d3f50a94f7c72dc28784cf55db2f6b.example.com", "Status": "PENDING_VALIDATION", "Type": "CNAME", "Value": "_1270c137383c6307b6832db02504c4b0.bsgbmzkfwj.acm-validations.aws." }, { "Name": "_287870d3f50a94f7c72dc4cf55db2f6b.www.example.com", "Status": "PENDING_VALIDATION", "Type": "CNAME", "Value": "_832db01270c137383c6307b62504c4b0.mzkbsgbfwj.acm-validations.aws." } ], "DomainName": "example.com", "EnableWWWSubdomain": true, "Status": "DELETING" }, "DNSTarget": "psbqam834h.us-east-1.awsapprunner.com", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Il seguente esempio di codice mostra come utilizzarelist-auto-scaling-configurations.

AWS CLI

Come ottenere un elenco impaginato delle configurazioni di dimensionamento automatico di App Runner

L'list-auto-scaling-configurationsesempio seguente elenca tutte le configurazioni di scalabilità automatica di App Runner presenti nell'account. AWS In ogni risposta sono elencate fino a cinque configurazioni di dimensionamento automatico. AutoScalingConfigurationName e LatestOnly non sono specificati. I loro valori predefiniti fanno sì che venga elencata l’ultima revisione di tutte le configurazioni attive.

In questo esempio, la risposta include due risultati e, non essendocene altri, non viene restituito alcun NextToken.

aws apprunner list-auto-scaling-configurations \ --cli-input-json file://input.json

Contenuto di input.json:

{ "MaxResults": 5 }

Output:

{ "AutoScalingConfigurationSummaryList": [ { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/2/e76562f50d78042e819fead0f59672e6", "AutoScalingConfigurationName": "high-availability", "AutoScalingConfigurationRevision": 2 }, { "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/low-cost/1/50d7804e7656fead0f59672e62f2e819", "AutoScalingConfigurationName": "low-cost", "AutoScalingConfigurationRevision": 1 } ] }

Il seguente esempio di codice mostra come utilizzarelist-connections.

AWS CLI

Esempio 1: come elencare tutte le connessioni

L'list-connectionsesempio seguente elenca tutte le connessioni App Runner nell' AWS account.

aws apprunner list-connections

Output:

{ "ConnectionSummaryList": [ { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection", "ConnectionName": "my-github-connection", "Status": "AVAILABLE", "CreatedAt": "2020-11-03T00:32:51Z", "ProviderType": "GITHUB" }, { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-org-connection", "ConnectionName": "my-github-org-connection", "Status": "AVAILABLE", "CreatedAt": "2020-11-03T02:54:17Z", "ProviderType": "GITHUB" } ] }

Esempio 2: come elencare una connessione in base al nome

L’esempio list-connections seguente elenca una connessione in base al relativo nome.

aws apprunner list-connections \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ConnectionName": "my-github-org-connection" }

Output:

{ "ConnectionSummaryList": [ { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-org-connection", "ConnectionName": "my-github-org-connection", "Status": "AVAILABLE", "CreatedAt": "2020-11-03T02:54:17Z", "ProviderType": "GITHUB" } ] }

Il seguente esempio di codice mostra come utilizzarelist-operations.

AWS CLI

Come elencare le operazioni eseguite su un servizio

L’esempio list-operations seguente elenca tutte le operazioni eseguite finora su un servizio App Runner. In questo esempio, il servizio è nuovo ed è stata eseguita solo una singola operazione di tipo CREATE_SERVICE.

aws apprunner list-operations \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "OperationSummaryList": [ { "EndedAt": 1606156217, "Id": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "StartedAt": 1606156014, "Status": "SUCCEEDED", "TargetArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "Type": "CREATE_SERVICE", "UpdatedAt": 1606156217 } ] }

Il seguente esempio di codice mostra come utilizzarelist-services.

AWS CLI

Come ottenere un elenco impaginato dei servizi App Runner

L'list-servicesesempio seguente elenca tutti i servizi App Runner dell' AWS account. In ogni risposta sono elencati fino a due servizi. In questo esempio viene mostrata la prima richiesta. La risposta include due risultati e un token che può essere utilizzato nella richiesta successiva. Quando una risposta successiva non include un token, significa che tutti i servizi sono stati elencati.

aws apprunner list-services \ --cli-input-json file://input.json

Contenuto di input.json:

{ "MaxResults": 2 }

Output:

{ "NextToken": "eyJDdXN0b21lckFjY291bnRJZCI6IjI3MDIwNTQwMjg0NSIsIlNlcnZpY2VTdGF0dXNDb2RlIjoiUFJPVklTSU9OSU5HIiwiSGFzaEtleSI6IjI3MDIwNTQwMjg0NSNhYjhmOTRjZmUyOWE0NjBmYjg3NjBhZmQyZWU4NzU1NSJ9", "ServiceSummaryList": [ { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-23T12:41:37Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "Status": "RUNNING" }, { "CreatedAt": "2020-11-06T23:15:30Z", "UpdatedAt": "2020-11-23T13:21:22Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/golang-container-app/ab8f94cfe29a460fb8760afd2ee87555", "ServiceId": "ab8f94cfe29a460fb8760afd2ee87555", "ServiceName": "golang-container-app", "ServiceUrl": "e2m8rrrx33.us-east-1.awsapprunner.com", "Status": "RUNNING" } ] }

Il seguente esempio di codice mostra come utilizzarelist-tags-for-resource.

AWS CLI

Come elencare tag associati a un servizio App Runner

L’esempio list-tags-for-resource seguente elenca tutti i tag associati a un servizio.

aws apprunner list-tags-for-resource \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "Tags": [ { "Key": "Department", "Value": "Retail" }, { "Key": "CustomerId", "Value": "56439872357912" } ] }

Il seguente esempio di codice mostra come utilizzarepause-service.

AWS CLI

Come sospendere un servizio

L’esempio pause-service seguente mette in pausa un servizio App Runner.

aws apprunner pause-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-23T12:41:37Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Il seguente esempio di codice mostra come utilizzareresume-service.

AWS CLI

Come riprendere un servizio

L’esempio resume-service seguente riprende l’esecuzione di un servizio App Runner.

aws apprunner resume-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-23T12:41:37Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "3 GB" } } }

Il seguente esempio di codice mostra come utilizzarestart-deployment.

AWS CLI

Come avviare un’implementazione manuale

L’esempio start-deployment seguente esegue un’implementazione manuale in un servizio App Runner.

aws apprunner start-deployment \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }

Output:

{ "OperationId": "853a7d5b-fc9f-4730-831b-fd8037ab832a" }

Il seguente esempio di codice mostra come utilizzaretag-resource.

AWS CLI

Come aggiungere tag a un servizio App Runner

L’esempio tag-resource seguente aggiunge due tag a un servizio App Runner.

aws apprunner tag-resource \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "Tags": [ { "Key": "Department", "Value": "Retail" }, { "Key": "CustomerId", "Value": "56439872357912" } ] }

Questo comando non produce alcun output.

Il seguente esempio di codice mostra come utilizzareuntag-resource.

AWS CLI

Come rimuovere tag da un servizio App Runner

L’esempio untag-resource seguente rimuove due tag da un servizio App Runner.

aws apprunner untag-resource \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "TagKeys": [ "Department", "CustomerId" ] }

Questo comando non produce alcun output.

Il seguente esempio di codice mostra come utilizzareupdate-service.

AWS CLI

Come aggiornare la dimensione della memoria

L’esempio update-service seguente aggiorna la dimensione della memoria delle istanze (unità di dimensionamento) di un servizio App Runner a 2048 MiB.

Quando la chiamata ha esito positivo, App Runner avvia un processo di aggiornamento asincrono. La struttura Service restituita dalla chiamata riflette il nuovo valore di memoria applicato da questa chiamata.

aws apprunner update-service \ --cli-input-json file://input.json

Contenuto di input.json:

{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "InstanceConfiguration": { "Memory": "4 GB" } }

Output:

{ "OperationId": "17fe9f55-7e91-4097-b243-fcabbb69a4cf", "Service": { "CreatedAt": "2020-11-20T19:05:25Z", "UpdatedAt": "2020-11-23T12:41:37Z", "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "ServiceId": "8fe1e10304f84fd2b0df550fe98a71fa", "ServiceName": "python-app", "ServiceUrl": "psbqam834h.us-east-1.awsapprunner.com", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "CodeConfiguration": { "CodeConfigurationValues": { "BuildCommand": "pip install -r requirements.txt", "Port": "8080", "Runtime": "PYTHON_3", "RuntimeEnvironmentVariables": [ { "NAME": "Jane" } ], "StartCommand": "python server.py" }, "ConfigurationSource": "Api" }, "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" } } }, "Status": "OPERATION_IN_PROGRESS", "InstanceConfiguration": { "CPU": "1 vCPU", "Memory": "4 GB" } } }