Gunakan DescribeApplications dengan AWS SDK atau CLI - AWS SDKContoh Kode

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.

Gunakan DescribeApplications dengan AWS SDK atau CLI

Contoh kode berikut menunjukkan cara menggunakanDescribeApplications.

CLI
AWS CLI

Untuk melihat daftar aplikasi

Perintah berikut mengambil informasi tentang aplikasi di wilayah saat ini:

aws elasticbeanstalk describe-applications

Output:

{ "Applications": [ { "ApplicationName": "ruby", "ConfigurationTemplates": [], "DateUpdated": "2015-08-13T21:05:44.376Z", "Versions": [ "Sample Application" ], "DateCreated": "2015-08-13T21:05:44.376Z" }, { "ApplicationName": "pythonsample", "Description": "Application created from the EB CLI using \"eb init\"", "Versions": [ "Sample Application" ], "DateCreated": "2015-08-13T19:05:43.637Z", "ConfigurationTemplates": [], "DateUpdated": "2015-08-13T19:05:43.637Z" }, { "ApplicationName": "nodejs-example", "ConfigurationTemplates": [], "DateUpdated": "2015-08-06T17:50:02.486Z", "Versions": [ "add elasticache", "First Release" ], "DateCreated": "2015-08-06T17:50:02.486Z" } ] }
Ruby
SDKuntuk Ruby
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

# Class to manage Elastic Beanstalk applications class ElasticBeanstalkManager def initialize(eb_client, logger: Logger.new($stdout)) @eb_client = eb_client @logger = logger end # Lists applications and their environments def list_applications @eb_client.describe_applications.applications.each do |application| log_application_details(application) list_environments(application.application_name) end rescue Aws::ElasticBeanstalk::Errors::ServiceError => e @logger.error("Elastic Beanstalk Service Error: #{e.message}") end private # Logs application details def log_application_details(application) @logger.info("Name: #{application.application_name}") @logger.info("Description: #{application.description}") end # Lists and logs details of environments for a given application def list_environments(application_name) @eb_client.describe_environments(application_name: application_name).environments.each do |env| @logger.info(" Environment: #{env.environment_name}") @logger.info(" URL: #{env.cname}") @logger.info(" Health: #{env.health}") end rescue Aws::ElasticBeanstalk::Errors::ServiceError => e @logger.error("Error listing environments for application #{application_name}: #{e.message}") end end