Cette documentation concerne AWS CLI uniquement la version 1. Pour la documentation relative à la version 2 du AWS CLI, consultez le guide de l'utilisateur de la version 2.
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Exemples d'utilisation d'App Runner AWS CLI
Les exemples de code suivants vous montrent comment effectuer des actions et implémenter des scénarios courants à l' AWS Command Line Interface aide d'App Runner.
Les actions sont des extraits de code de programmes plus larges et doivent être exécutées dans leur contexte. Alors que les actions vous indiquent comment appeler des fonctions de service individuelles, vous pouvez les voir en contexte dans leurs scénarios associés.
Chaque exemple inclut un lien vers le code source complet, où vous trouverez des instructions sur la configuration et l’exécution du code en contexte.
Rubriques
Actions
L'exemple de code suivant montre comment utiliserassociate-custom-domain.
- AWS CLI
-
Pour associer un nom de domaine et le sous-domaine www à un service
L’exemple
associate-custom-domainsuivant associe un nom de domaine personnalisé que vous contrôlez à un service App Runner. Le nom de domaine est le domaine racineexample.com, y compris le sous-domaine spécifiquewww.example.com.aws apprunner associate-custom-domain \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "DomainName": "example.com", "EnableWWWSubdomain": true }Sortie :
{ "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" }-
Pour plus de détails sur l'API, reportez-vous AssociateCustomDomain
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utilisercreate-auto-scaling-configuration.
- AWS CLI
-
Pour créer une configuration autoscaling à haute disponibilité
L’exemple
create-auto-scaling-configurationsuivant crée une configuration autoscaling optimisée pour une haute disponibilité en définissant la valeurMinSizesur 5. Avec cette configuration, App Runner tente de répartir vos instances de service sur le plus grand nombre possible de zones de disponibilité, jusqu'à cinq, selon la AWS région.L’appel renvoie un objet
AutoScalingConfigurationdont les autres paramètres sont définis par défaut. Dans l’exemple, il s’agit du premier appel pour créer une configuration nomméehigh-availability. La révision est définie sur 1 et il s’agit de la dernière révision.aws apprunner create-auto-scaling-configuration \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "AutoScalingConfigurationName": "high-availability", "MinSize": 5 }Sortie :
{ "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 } }-
Pour plus de détails sur l'API, reportez-vous CreateAutoScalingConfiguration
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utilisercreate-connection.
- AWS CLI
-
Pour créer une GitHub connexion
L'
create-connectionexemple suivant crée une connexion à un référentiel de GitHub code privé. Le statut de la connexion après un appel réussi estPENDING_HANDSHAKE. Cela est dû au fait qu’aucun établissement d’une liaison d’authentification avec le fournisseur n’a eu lieu pour le moment. Terminez l’établissement d’une liaison à l’aide de la console App Runner.aws apprunner create-connection \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ConnectionName": "my-github-connection", "ProviderType": "GITHUB" }Sortie :
{ "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" } }Pour plus d’informations, consultez Gestion des connexions App Runner dans le Guide du développeur AWS App Runner.
-
Pour plus de détails sur l'API, reportez-vous CreateConnection
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utilisercreate-service.
- AWS CLI
-
Exemple 1 : pour créer un service de référentiel de code source
L’exemple
create-servicesuivant crée un service App Runner basé sur un référentiel de code source Python.aws apprunner create-service \ --cli-input-jsonfile://input.jsonContenu de
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" } }Sortie :
{ "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" } } }Exemple 2 : pour créer un service de référentiel de code source
L’exemple
create-servicesuivant crée un service App Runner basé sur un référentiel de code source Python.aws apprunner create-service \ --cli-input-jsonfile://input.jsonContenu de
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" } }Sortie :
{ "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" } } }Exemple 3 : pour créer un service de référentiel d’images source
L’exemple
create-servicesuivant crée un service App Runner basé sur une image stockée dans Elastic Container Registry (ECR).aws apprunner create-service \ --cli-input-jsonfile://input.jsonContenu de
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" } }Sortie :
{ "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" } } }-
Pour plus de détails sur l'API, reportez-vous CreateService
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdelete-auto-scaling-configuration.
- AWS CLI
-
Exemple 1 : pour supprimer la dernière révision active d’une configuration autoscaling
L’exemple
delete-auto-scaling-configurationsuivant supprime la dernière révision active d’une configuration autoscaling d’App Runner. Pour supprimer la dernière révision active, spécifiez un Amazon Resource Name (ARN) qui se termine par le nom de la configuration, sans le composant de révision.Dans l’exemple, deux révisions existent avant cette action. Par conséquent, la révision 2 (la plus récente) est supprimée. Cependant, vous voyez désormais
"Latest": false, car, après avoir été supprimée, il ne s’agit plus de la dernière révision active.aws apprunner delete-auto-scaling-configuration \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability" }Sortie :
{ "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 } }Exemple 2 : pour supprimer une révision spécifique d’une configuration autoscaling
L’exemple
delete-auto-scaling-configurationsuivant supprime une révision spécifique d’une configuration autoscaling d’App Runner. Pour supprimer une révision spécifique, indiquez un ARN qui inclut le numéro de révision.Dans l’exemple, plusieurs révisions existent avant cette action. L’action supprime la révision
1.aws apprunner delete-auto-scaling-configuration \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1" }Sortie :
{ "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 } }-
Pour plus de détails sur l'API, reportez-vous DeleteAutoScalingConfiguration
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdelete-connection.
- AWS CLI
-
Pour supprimer une connexion
L’exemple
delete-connectionsuivant supprime une connexion App Runner. Le statut de la connexion après un appel réussi estDELETED. Cela est dû au fait que la connexion n’est plus disponible.aws apprunner delete-connection \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection" }Sortie :
{ "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" } }-
Pour plus de détails sur l'API, reportez-vous DeleteConnection
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdelete-service.
- AWS CLI
-
Pour supprimer un service
L’exemple
delete-servicesuivant supprime un service App Runner.aws apprunner delete-service \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "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" } } }-
Pour plus de détails sur l'API, reportez-vous DeleteService
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdescribe-auto-scaling-configuration.
- AWS CLI
-
Exemple 1 : pour décrire la dernière révision active d’une configuration autoscaling
L’exemple
describe-auto-scaling-configurationsuivant obtient une description de la dernière révision active d’une configuration autoscaling d’App Runner. Pour décrire la dernière révision active, spécifiez un ARN qui se termine par le nom de la configuration, sans le composant de révision.Dans l’exemple, deux révisions existent. Par conséquent, la révision
2(la plus récente) est décrite. L’objet obtenu affiche"Latest": true.aws apprunner describe-auto-scaling-configuration \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability" }Sortie :
{ "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 } }Exemple 2 : pour décrire une révision spécifique d’une configuration autoscaling
L’exemple
describe-auto-scaling-configurationsuivant obtient une description d’une révision spécifique d’une configuration autoscaling d’App Runner. Pour décrire une révision spécifique, spécifiez un ARN qui inclut le numéro de révision.Dans l’exemple, plusieurs révisions existent et la révision
1est interrogée. L’objet obtenu affiche"Latest": false.aws apprunner describe-auto-scaling-configuration \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "AutoScalingConfigurationArn": "arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/1" }Sortie :
{ "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 } }-
Pour plus de détails sur l'API, reportez-vous DescribeAutoScalingConfiguration
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdescribe-custom-domains.
- AWS CLI
-
Pour obtenir des descriptions de noms de domaine personnalisés associés à un service
L’exemple
describe-custom-domainssuivant obtient des descriptions et statuts des noms de domaine personnalisés associés à un service App Runner.aws apprunner describe-custom-domains \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "DomainName": "example.com", "EnableWWWSubdomain": true }Sortie :
{ "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" }-
Pour plus de détails sur l'API, reportez-vous DescribeCustomDomains
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdescribe-service.
- AWS CLI
-
Pour décrire un service
L’exemple
describe-servicesuivant obtient une description d’un service App Runner.aws apprunner describe-service \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "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" } } }-
Pour plus de détails sur l'API, reportez-vous DescribeService
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserdisassociate-custom-domain.
- AWS CLI
-
Pour dissocier un nom de domaine d’un service
L’exemple
disassociate-custom-domainsuivant dissocie le domaineexample.comd’un service App Runner. L’appel dissocie également le sous-domainewww.example.comqui était associé au domaine racine.aws apprunner disassociate-custom-domain \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "DomainName": "example.com" }Sortie :
{ "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" }-
Pour plus de détails sur l'API, reportez-vous DisassociateCustomDomain
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserlist-auto-scaling-configurations.
- AWS CLI
-
Pour obtenir une liste paginée des configurations autoscaling d’App Runner
L'
list-auto-scaling-configurationsexemple suivant répertorie toutes les configurations de mise à l'échelle automatique d'App Runner de votre AWS compte. Jusqu’à cinq configurations autoscaling sont répertoriées dans chaque réponse.AutoScalingConfigurationNameetLatestOnlyne sont pas spécifiés. Leurs valeurs par défaut répertorient la dernière révision de toutes les configurations actives.Dans cet exemple, la réponse inclut seulement deux résultats. Aucun résultat
NextTokenn’est donc renvoyé.aws apprunner list-auto-scaling-configurations \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "MaxResults": 5 }Sortie :
{ "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 } ] }-
Pour plus de détails sur l'API, reportez-vous ListAutoScalingConfigurations
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserlist-connections.
- AWS CLI
-
Exemple 1 : pour répertorier toutes les connexions
L'
list-connectionsexemple suivant répertorie toutes les connexions App Runner du AWS compte.aws apprunner list-connectionsSortie :
{ "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" } ] }Exemple 2 : pour répertorier une connexion par nom
L’exemple
list-connectionssuivant répertorie une connexion par son nom.aws apprunner list-connections \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ConnectionName": "my-github-org-connection" }Sortie :
{ "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" } ] }-
Pour plus de détails sur l'API, reportez-vous ListConnections
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserlist-operations.
- AWS CLI
-
Pour répertorier les opérations exécutées sur un service
L’exemple
list-operationssuivant répertorie toutes les opérations exécutées jusqu’à présent sur un service App Runner. Dans cet exemple, le service est nouveau et une seule opération de typeCREATE_SERVICEs’est produite.aws apprunner list-operations \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "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 } ] }-
Pour plus de détails sur l'API, reportez-vous ListOperations
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserlist-services.
- AWS CLI
-
Pour obtenir une liste paginée des services App Runner
L'
list-servicesexemple suivant répertorie tous les services App Runner du AWS compte. Jusqu’à deux services sont répertoriés dans chaque réponse. Cet exemple montre la première demande. La réponse inclut deux résultats et un jeton qui peut être utilisé dans la prochaine demande. Lorsqu’une réponse ultérieure n’inclut pas de jeton, tous les services ont été répertoriés.aws apprunner list-services \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "MaxResults": 2 }Sortie :
{ "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" } ] }-
Pour plus de détails sur l'API, reportez-vous ListServices
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserlist-tags-for-resource.
- AWS CLI
-
Pour répertorier les balises associées à un service App Runner
L’exemple
list-tags-for-resourcesuivant répertorie toutes les balises associées à un service App Runner.aws apprunner list-tags-for-resource \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "Tags": [ { "Key": "Department", "Value": "Retail" }, { "Key": "CustomerId", "Value": "56439872357912" } ] }-
Pour plus de détails sur l'API, reportez-vous ListTagsForResource
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserpause-service.
- AWS CLI
-
Pour suspendre un service
L’exemple
pause-servicesuivant suspend un service App Runner.aws apprunner pause-service \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "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" } } }-
Pour plus de détails sur l'API, reportez-vous PauseService
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserresume-service.
- AWS CLI
-
Pour reprendre un service
L’exemple
resume-servicesuivant reprend un service App Runner.aws apprunner resume-service \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "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" } } }-
Pour plus de détails sur l'API, reportez-vous ResumeService
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserstart-deployment.
- AWS CLI
-
Pour lancer un déploiement manuel
L’exemple
start-deploymentsuivant effectue un déploiement manuel vers un service App Runner.aws apprunner start-deployment \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }Sortie :
{ "OperationId": "853a7d5b-fc9f-4730-831b-fd8037ab832a" }-
Pour plus de détails sur l'API, reportez-vous StartDeployment
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utilisertag-resource.
- AWS CLI
-
Pour ajouter des balises à un service App Runner
L’exemple
tag-resourcesuivant ajoute deux balises à un service App Runner.aws apprunner tag-resource \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "Tags": [ { "Key": "Department", "Value": "Retail" }, { "Key": "CustomerId", "Value": "56439872357912" } ] }Cette commande ne produit aucune sortie.
-
Pour plus de détails sur l'API, reportez-vous TagResource
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliseruntag-resource.
- AWS CLI
-
Pour supprimer des balises d’un service App Runner
L’exemple
untag-resourcesuivant supprime deux balises d’un service App Runner.aws apprunner untag-resource \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "TagKeys": [ "Department", "CustomerId" ] }Cette commande ne produit aucune sortie.
-
Pour plus de détails sur l'API, reportez-vous UntagResource
à la section Référence des AWS CLI commandes.
-
L'exemple de code suivant montre comment utiliserupdate-service.
- AWS CLI
-
Pour mettre à jour la taille de la mémoire
L’exemple
update-servicesuivant met à jour la taille de mémoire des instances (unités de mise à l’échelle) d’un service App Runner à 2 048 Mio.Lorsque l’appel aboutit, App Runner lance un processus de mise à jour asynchrone. La structure
Servicerenvoyée par l’appel reflète la nouvelle valeur de mémoire appliquée par cet appel.aws apprunner update-service \ --cli-input-jsonfile://input.jsonContenu de
input.json:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "InstanceConfiguration": { "Memory": "4 GB" } }Sortie :
{ "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" } } }-
Pour plus de détails sur l'API, reportez-vous UpdateService
à la section Référence des AWS CLI commandes.
-