ACM를 사용한 예제 AWS SDK for .NET - AWS SDK코드 예제

AWS 문서 AWS SDK SDK 예제 GitHub 리포지토리에 더 많은 예제가 있습니다.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

ACM를 사용한 예제 AWS SDK for .NET

다음 코드 예제는 with 를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다ACM. AWS SDK for .NET

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 호출하는 방법을 보여 주며 관련 시나리오와 교차 서비스 예시에서 컨텍스트에 맞는 작업을 볼 수 있습니다.

시나리오는 동일한 서비스 내에서 여러 함수를 호출하여 특정 태스크를 수행하는 방법을 보여주는 코드 예시입니다.

각 예제에는 컨텍스트에서 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있는 링크가 포함되어 있습니다. GitHub

주제

작업

다음 코드 예시에서는 DescribeCertificate을 사용하는 방법을 보여 줍니다.

AWS SDK for .NET
참고

자세한 내용은 여기를 참조하십시오 GitHub. AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

using System; using System.Threading.Tasks; using Amazon; using Amazon.CertificateManager; using Amazon.CertificateManager.Model; namespace DescribeCertificate { class DescribeCertificate { // The following example retrieves and displays the metadata for a // certificate using the AWS Certificate Manager (ACM) service. // Specify your AWS Region (an example Region is shown). private static readonly RegionEndpoint ACMRegion = RegionEndpoint.USEast1; private static AmazonCertificateManagerClient _client; static void Main(string[] args) { _client = new Amazon.CertificateManager.AmazonCertificateManagerClient(ACMRegion); var describeCertificateReq = new DescribeCertificateRequest(); // The ARN used here is just an example. Replace it with the ARN of // a certificate that exists on your account. describeCertificateReq.CertificateArn = "arn:aws:acm:us-east-1:123456789012:certificate/8cfd7dae-9b6a-2d07-92bc-1c309EXAMPLE"; var certificateDetailResp = DescribeCertificateResponseAsync(client: _client, request: describeCertificateReq); var certificateDetail = certificateDetailResp.Result.Certificate; if (certificateDetail is not null) { DisplayCertificateDetails(certificateDetail); } } /// <summary> /// Displays detailed metadata about a certificate retrieved /// using the ACM service. /// </summary> /// <param name="certificateDetail">The object that contains details /// returned from the call to DescribeCertificateAsync.</param> static void DisplayCertificateDetails(CertificateDetail certificateDetail) { Console.WriteLine("\nCertificate Details: "); Console.WriteLine($"Certificate Domain: {certificateDetail.DomainName}"); Console.WriteLine($"Certificate Arn: {certificateDetail.CertificateArn}"); Console.WriteLine($"Certificate Subject: {certificateDetail.Subject}"); Console.WriteLine($"Certificate Status: {certificateDetail.Status}"); foreach (var san in certificateDetail.SubjectAlternativeNames) { Console.WriteLine($"Certificate SubjectAlternativeName: {san}"); } } /// <summary> /// Retrieves the metadata associated with the ACM service certificate. /// </summary> /// <param name="client">An AmazonCertificateManagerClient object /// used to call DescribeCertificateResponse.</param> /// <param name="request">The DescribeCertificateRequest object that /// will be passed to the method call.</param> /// <returns></returns> static async Task<DescribeCertificateResponse> DescribeCertificateResponseAsync( AmazonCertificateManagerClient client, DescribeCertificateRequest request) { var response = new DescribeCertificateResponse(); try { response = await client.DescribeCertificateAsync(request); } catch (InvalidArnException) { Console.WriteLine($"Error: The ARN specified is invalid."); } catch (ResourceNotFoundException) { Console.WriteLine($"Error: The specified certificate could not be found."); } return response; } } }

다음 코드 예시에서는 ListCertificates을 사용하는 방법을 보여 줍니다.

AWS SDK for .NET
참고

더 많은 정보가 있습니다 GitHub. AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

using System; using System.Threading.Tasks; using Amazon; using Amazon.CertificateManager; using Amazon.CertificateManager.Model; namespace ListCertificates { // The following example retrieves and displays a list of the // certificates defined for the default account using the AWS // Certificate Manager (ACM) service. class ListCertificates { // Specify your AWS Region (an example Region is shown). private static readonly RegionEndpoint ACMRegion = RegionEndpoint.USEast1; private static AmazonCertificateManagerClient _client; static void Main(string[] args) { _client = new AmazonCertificateManagerClient(ACMRegion); var certificateList = ListCertificatesResponseAsync(client: _client); Console.WriteLine("Certificate Summary List\n"); foreach (var certificate in certificateList.Result.CertificateSummaryList) { Console.WriteLine($"Certificate Domain: {certificate.DomainName}"); Console.WriteLine($"Certificate ARN: {certificate.CertificateArn}\n"); } } /// <summary> /// Retrieves a list of the certificates defined in this Region. /// </summary> /// <param name="client">The ACM client object passed to the /// ListCertificateResAsync method call.</param> /// <param name="request"></param> /// <returns>The ListCertificatesResponse.</returns> static async Task<ListCertificatesResponse> ListCertificatesResponseAsync( AmazonCertificateManagerClient client) { var request = new ListCertificatesRequest(); var response = await client.ListCertificatesAsync(request); return response; } } }