Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Contoh App Runner menggunakan AWS CLI
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum menggunakan AWS Command Line Interface With App Runner.
Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanassociate-custom-domain
.
- AWS CLI
-
Untuk mengaitkan nama domain dan subdomain www dengan layanan
associate-custom-domain
Contoh berikut mengaitkan nama domain kustom yang Anda kontrol dengan layanan App Runner. Nama domain adalah domain rootexample.com
, termasuk subdomain kasus khusus.www.example.com
aws apprunner associate-custom-domain \ --cli-input-json
file://input.json
Isi dari
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" }
-
Untuk API detailnya, lihat AssociateCustomDomain
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-auto-scaling-configuration
.
- AWS CLI
-
Untuk membuat konfigurasi auto scaling ketersediaan tinggi
create-auto-scaling-configuration
Contoh berikut membuat konfigurasi penskalaan otomatis yang dioptimalkan untuk ketersediaan tinggi dengan menyetelMinSize
ke 5. Dengan konfigurasi ini, App Runner mencoba menyebarkan instans layanan Anda ke sebagian besar Availability Zone, hingga lima, tergantung pada AWS Wilayah.Panggilan mengembalikan
AutoScalingConfiguration
objek dengan pengaturan lain yang disetel ke defaultnya. Dalam contoh, ini adalah panggilan pertama untuk membuat konfigurasi bernamahigh-availability
. Revisi diatur ke 1, dan ini adalah revisi terbaru.aws apprunner create-auto-scaling-configuration \ --cli-input-json
file://input.json
Isi dari
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 } }
-
Untuk API detailnya, lihat CreateAutoScalingConfiguration
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-connection
.
- AWS CLI
-
Untuk membuat GitHub koneksi
create-connection
Contoh berikut membuat koneksi ke repositori GitHub kode pribadi. Status koneksi setelah panggilan berhasil adalahPENDING_HANDSHAKE
. Ini karena jabat tangan otentikasi dengan penyedia masih belum terjadi. Selesaikan jabat tangan menggunakan konsol App Runner.aws apprunner create-connection \ --cli-input-json
file://input.json
Isi dari
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" } }
Untuk informasi selengkapnya, lihat Mengelola koneksi App Runner di Panduan Pengembang AWS App Runner.
-
Untuk API detailnya, lihat CreateConnection
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-service
.
- AWS CLI
-
Contoh 1: Untuk membuat layanan repositori kode sumber
create-service
Contoh berikut membuat layanan App Runner berdasarkan repositori kode sumber Python.aws apprunner create-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
Contoh 2: Untuk membuat layanan repositori kode sumber
create-service
Contoh berikut membuat layanan App Runner berdasarkan repositori kode sumber Python.aws apprunner create-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
Contoh 3: Untuk membuat layanan repositori gambar sumber
create-service
Contoh berikut membuat layanan App Runner berdasarkan gambar yang disimpan di Elastic Container Registry (ECR).aws apprunner create-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
-
Untuk API detailnya, lihat CreateService
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-auto-scaling-configuration
.
- AWS CLI
-
Contoh 1: Untuk menghapus revisi aktif terbaru dari konfigurasi penskalaan otomatis
delete-auto-scaling-configuration
Contoh berikut menghapus revisi aktif terbaru dari konfigurasi penskalaan otomatis App Runner. Untuk menghapus revisi aktif terbaru, tentukan Amazon Resource Name (ARN) yang diakhiri dengan nama konfigurasi, tanpa komponen revisi.Dalam contoh, ada dua revisi sebelum tindakan ini. Oleh karena itu, revisi 2 (terbaru) dihapus. Namun, sekarang ditampilkan
"Latest": false
, karena, setelah dihapus, itu bukan revisi aktif terbaru lagi.aws apprunner delete-auto-scaling-configuration \ --cli-input-json
file://input.json
Isi dari
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 } }
Contoh 2: Untuk menghapus revisi tertentu dari konfigurasi penskalaan otomatis
delete-auto-scaling-configuration
Contoh berikut menghapus revisi spesifik konfigurasi penskalaan otomatis App Runner. Untuk menghapus revisi tertentu, tentukan ARN yang menyertakan nomor revisi.Dalam contoh, beberapa revisi ada sebelum tindakan ini. Tindakan menghapus
1
revisi.aws apprunner delete-auto-scaling-configuration \ --cli-input-json
file://input.json
Isi dari
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 } }
-
Untuk API detailnya, lihat DeleteAutoScalingConfiguration
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-connection
.
- AWS CLI
-
Untuk menghapus koneksi
delete-connection
Contoh berikut menghapus koneksi App Runner. Status koneksi setelah panggilan berhasil adalahDELETED
. Ini karena koneksi tidak lagi tersedia.aws apprunner delete-connection \ --cli-input-json
file://input.json
Isi dari
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" } }
-
Untuk API detailnya, lihat DeleteConnection
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-service
.
- AWS CLI
-
Untuk menghapus layanan
delete-service
Contoh berikut menghapus layanan App Runner.aws apprunner delete-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
-
Untuk API detailnya, lihat DeleteService
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-auto-scaling-configuration
.
- AWS CLI
-
Contoh 1: Untuk menjelaskan revisi aktif terbaru dari konfigurasi penskalaan otomatis
describe-auto-scaling-configuration
Contoh berikut mendapatkan deskripsi revisi aktif terbaru dari konfigurasi penskalaan otomatis App Runner. Untuk menjelaskan revisi aktif terbaru, tentukan ARN yang diakhiri dengan nama konfigurasi, tanpa komponen revisi.Dalam contoh, ada dua revisi. Oleh karena itu, revisi
2
(terbaru) dijelaskan. Objek yang dihasilkan menunjukkan"Latest": true
.aws apprunner describe-auto-scaling-configuration \ --cli-input-json
file://input.json
Isi dari
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 } }
Contoh 2: Untuk menjelaskan revisi spesifik dari konfigurasi penskalaan otomatis
describe-auto-scaling-configuration
Contoh berikut mendapatkan deskripsi revisi spesifik konfigurasi penskalaan otomatis App Runner. Untuk menggambarkan revisi tertentu, tentukan ARN yang menyertakan nomor revisi.Dalam contoh, beberapa revisi ada dan revisi
1
ditanyakan. Objek yang dihasilkan menunjukkan"Latest": false
.aws apprunner describe-auto-scaling-configuration \ --cli-input-json
file://input.json
Isi dari
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 } }
-
Untuk API detailnya, lihat DescribeAutoScalingConfiguration
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-custom-domains
.
- AWS CLI
-
Untuk mendapatkan deskripsi nama domain kustom yang terkait dengan layanan
describe-custom-domains
Contoh berikut mendapatkan deskripsi dan status nama domain kustom yang terkait dengan layanan App Runner.aws apprunner describe-custom-domains \ --cli-input-json
file://input.json
Isi dari
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" }
-
Untuk API detailnya, lihat DescribeCustomDomains
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-service
.
- AWS CLI
-
Untuk menggambarkan layanan
describe-service
Contoh berikut mendapatkan deskripsi layanan App Runner.aws apprunner describe-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
-
Untuk API detailnya, lihat DescribeService
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandisassociate-custom-domain
.
- AWS CLI
-
Untuk memisahkan nama domain dari layanan
disassociate-custom-domain
Contoh berikut memisahkan domainexample.com
dari layanan App Runner. Panggilan juga memisahkan subdomainwww.example.com
yang dikaitkan bersama dengan domain root.aws apprunner disassociate-custom-domain \ --cli-input-json
file://input.json
Isi dari
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" }
-
Untuk API detailnya, lihat DisassociateCustomDomain
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-auto-scaling-configurations
.
- AWS CLI
-
Untuk mendapatkan daftar paginasi konfigurasi penskalaan otomatis App Runner
list-auto-scaling-configurations
Contoh berikut mencantumkan semua konfigurasi penskalaan otomatis App Runner di akun Anda. AWS Hingga lima konfigurasi penskalaan otomatis tercantum di setiap respons.AutoScalingConfigurationName
danLatestOnly
tidak ditentukan. Defaultnya menyebabkan revisi terbaru dari semua konfigurasi aktif terdaftar.Dalam contoh ini, respons mencakup dua hasil dan tidak ada yang tambahan, jadi
NextToken
tidak dikembalikan.aws apprunner list-auto-scaling-configurations \ --cli-input-json
file://input.json
Isi dari
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 } ] }
-
Untuk API detailnya, lihat ListAutoScalingConfigurations
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-connections
.
- AWS CLI
-
Contoh 1: Untuk daftar semua koneksi
list-connections
Contoh berikut mencantumkan semua koneksi App Runner di AWS akun.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" } ] }
Contoh 2: Untuk membuat daftar koneksi dengan nama
list-connections
Contoh berikut mencantumkan koneksi dengan namanya.aws apprunner list-connections \ --cli-input-json
file://input.json
Isi dari
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" } ] }
-
Untuk API detailnya, lihat ListConnections
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-operations
.
- AWS CLI
-
Untuk membuat daftar operasi yang terjadi pada servicee
list-operations
Contoh berikut mencantumkan semua operasi yang terjadi pada layanan App Runner sejauh ini. Dalam contoh ini, layanan ini baru dan hanya satu operasi tipe yangCREATE_SERVICE
telah terjadi.aws apprunner list-operations \ --cli-input-json
file://input.json
Isi dari
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 } ] }
-
Untuk API detailnya, lihat ListOperations
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-services
.
- AWS CLI
-
Untuk mendapatkan daftar paginasi layanan App Runner
list-services
Contoh berikut mencantumkan semua layanan App Runner di AWS akun. Hingga dua layanan tercantum dalam setiap tanggapan. Contoh ini menunjukkan permintaan pertama. Respons mencakup dua hasil dan token yang dapat digunakan dalam permintaan berikutnya. Ketika respons berikutnya tidak menyertakan token, semua layanan telah terdaftar.aws apprunner list-services \ --cli-input-json
file://input.json
Isi dari
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" } ] }
-
Untuk API detailnya, lihat ListServices
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-tags-for-resource
.
- AWS CLI
-
Untuk mencantumkan tag yang terkait dengan layanan App Runner
list-tags-for-resource
Contoh berikut mencantumkan semua tag yang terkait dengan layanan App Runner.aws apprunner list-tags-for-resource \ --cli-input-json
file://input.json
Isi dari
input.json
:{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }
Output:
{ "Tags": [ { "Key": "Department", "Value": "Retail" }, { "Key": "CustomerId", "Value": "56439872357912" } ] }
-
Untuk API detailnya, lihat ListTagsForResource
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanpause-service
.
- AWS CLI
-
Untuk menjeda layanan
pause-service
Contoh berikut menjeda layanan App Runner.aws apprunner pause-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
-
Untuk API detailnya, lihat PauseService
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanresume-service
.
- AWS CLI
-
Untuk melanjutkan layanan
resume-service
Contoh berikut melanjutkan layanan App Runner.aws apprunner resume-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
-
Untuk API detailnya, lihat ResumeService
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanstart-deployment
.
- AWS CLI
-
Untuk memulai penerapan manual
start-deployment
Contoh berikut melakukan penerapan manual ke layanan App Runner.aws apprunner start-deployment \ --cli-input-json
file://input.json
Isi dari
input.json
:{ "ServiceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa" }
Output:
{ "OperationId": "853a7d5b-fc9f-4730-831b-fd8037ab832a" }
-
Untuk API detailnya, lihat StartDeployment
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakantag-resource
.
- AWS CLI
-
Untuk menambahkan tag ke layanan App Runner
tag-resource
Contoh berikut menambahkan dua tag ke layanan App Runner.aws apprunner tag-resource \ --cli-input-json
file://input.json
Isi dari
input.json
:{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "Tags": [ { "Key": "Department", "Value": "Retail" }, { "Key": "CustomerId", "Value": "56439872357912" } ] }
Perintah ini tidak menghasilkan output.
-
Untuk API detailnya, lihat TagResource
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanuntag-resource
.
- AWS CLI
-
Untuk menghapus tag dari layanan App Runner
untag-resource
Contoh berikut menghapus dua tag dari layanan App Runner.aws apprunner untag-resource \ --cli-input-json
file://input.json
Isi dari
input.json
:{ "ResourceArn": "arn:aws:apprunner:us-east-1:123456789012:service/python-app/8fe1e10304f84fd2b0df550fe98a71fa", "TagKeys": [ "Department", "CustomerId" ] }
Perintah ini tidak menghasilkan output.
-
Untuk API detailnya, lihat UntagResource
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanupdate-service
.
- AWS CLI
-
Untuk memperbarui ukuran memori
update-service
Contoh berikut memperbarui ukuran memori instance (unit penskalaan) layanan App Runner menjadi 2048 MiB.Ketika panggilan berhasil, App Runner memulai proses pembaruan asinkron.
Service
Struktur yang dikembalikan oleh panggilan mencerminkan nilai memori baru yang sedang diterapkan oleh panggilan ini.aws apprunner update-service \ --cli-input-json
file://input.json
Isi dari
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" } } }
-
Untuk API detailnya, lihat UpdateService
di Referensi AWS CLI Perintah.
-