Exemples d’utilisation de l’AWS CLI avec App Runner
Les exemples de code suivants montrent comment réaliser des actions et mettre en œuvre des scénarios courants en utilisant l’AWS Command Line Interface avec 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 utiliser associate-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écialwww.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, consultez AssociateCustomDomain
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser create-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 le paramètreMinSizesur 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) en fonction de la région AWS.L’appel renvoie un objet
AutoScalingConfigurationdont les autres paramètres sont définis sur leur valeur 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, consultez CreateAutoScalingConfiguration
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser create-connection.
- AWS CLI
-
Pour créer une connexion GitHub
L’exemple
create-connectionsuivant crée une connexion à un référentiel de code GitHub privé. Le statut de la connexion après un appel réussi estPENDING_HANDSHAKE. Cela est dû au fait qu’aucune liaison d’authentification avec le fournisseur n’a encore été établie. Établissez 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 Managing App Runner connections dans le Manuel du développeur AWS App Runner.
-
Pour plus de détails sur l’API, consultez CreateConnection
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser create-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, consultez CreateService
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser delete-auto-scaling-configuration.
- AWS CLI
-
Exemple 1 : pour supprimer la dernière révision active d’une configuration d’autoscaling
L’exemple
delete-auto-scaling-configurationsuivant supprime la dernière révision active d’une configuration d’autoscaling 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, il existe deux révisions 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 sa suppression, 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 d’autoscaling
L’exemple
delete-auto-scaling-configurationsuivant supprime une révision spécifique d’une configuration d’autoscaling App Runner. Pour supprimer une révision spécifique, indiquez un ARN qui inclut le numéro de révision.Dans l’exemple, il existe plusieurs révisions 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, consultez DeleteAutoScalingConfiguration
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser delete-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, consultez DeleteConnection
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser delete-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, consultez DeleteService
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-auto-scaling-configuration.
- AWS CLI
-
Exemple 1 : pour décrire la dernière révision active d’une configuration d’autoscaling
L’exemple
describe-auto-scaling-configurationsuivant obtient une description de la dernière révision active d’une configuration d’autoscaling 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, il existe deux révisions. 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 d’autoscaling
L’exemple
describe-auto-scaling-configurationsuivant obtient une description d’une révision spécifique d’une configuration d’autoscaling 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, il existe plusieurs révisions, 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, consultez DescribeAutoScalingConfiguration
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-custom-domains.
- AWS CLI
-
Pour obtenir des descriptions de noms de domaine personnalisés associés à un service
L’exemple
describe-custom-domainssuivant obtient les 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, consultez DescribeCustomDomains
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser describe-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, consultez DescribeService
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser disassociate-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, consultez DisassociateCustomDomain
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser list-auto-scaling-configurations.
- AWS CLI
-
Pour obtenir une liste paginée des configurations d’autoscaling App Runner
L’exemple
list-auto-scaling-configurationssuivant répertorie toutes les configurations d’autoscaling App Runner de votre compte AWS. Jusqu’à cinq configurations d’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, consultez ListAutoScalingConfigurations
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser list-connections.
- AWS CLI
-
Exemple 1 : pour répertorier toutes les connexions
L’exemple
list-connectionssuivant répertorie toutes les connexions App Runner du compte AWS.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, consultez ListConnections
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser list-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, consultez ListOperations
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser list-services.
- AWS CLI
-
Pour obtenir une liste paginée des services App Runner
L’exemple
list-servicessuivant répertorie tous les services App Runner du compte AWS. 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 pourra ê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, consultez ListServices
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser list-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, consultez ListTagsForResource
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser pause-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, consultez PauseService
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser resume-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, consultez ResumeService
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser start-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, consultez StartDeployment
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser tag-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, consultez TagResource
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser untag-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, consultez UntagResource
dans la Référence des commandes de l’AWS CLI.
-
L’exemple de code suivant montre comment utiliser update-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 pour qu’elle atteigne 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, consultez UpdateService
dans la Référence des commandes de l’AWS CLI.
-