고급 마이그레이션 시나리오 - AWS Elastic Beanstalk

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

고급 마이그레이션 시나리오

이 섹션에서는 복잡한 IIS 배포를 위한 고급 마이그레이션 시나리오를 다룹니다.

Application Request Routing(ARR)을 사용한 다중 사이트 마이그레이션

eb migrate 명령은 마이그레이션 중에 ARR 구성을 자동으로 감지하고 보존합니다. IIS에서 ARR 설정을 식별하면 대상 EC2 인스턴스에 ARR을 다시 설치하고 구성하는 데 필요한 PowerShell 스크립트가 applicationHost.config생성됩니다.

ARR 구성 감지

마이그레이션 프로세스는 IIS의 세 가지 주요 구성 섹션을 검사합니다.

  • system.webServer/proxy: 코어 ARR 프록시 설정

  • system.webServer/rewrite: URL 재작성 규칙

  • system.webServer/caching: 캐싱 구성

예를 들어 포트 80에서 RouterSite 실행되는가 각각 포트 8081 APIService 및 8082에 대한 요청을 프록시하고 포트 8081 및 8082에서 AdminPortal 실행되는 공통 ARR 구성을 생각해 보십시오.

<!-- Original IIS ARR Configuration --> <rewrite> <rules> <rule name="Route to API" stopProcessing="true"> <match url="^api/(.*)$" /> <action type="Rewrite" url="http://backend:8081/api/{R:1}" /> </rule> <rule name="Route to Admin" stopProcessing="true"> <match url="^admin/(.*)$" /> <action type="Rewrite" url="http://backend:8082/admin/{R:1}" /> </rule> </rules> </rewrite>

다음 다이어그램은 이러한 규칙이 IIS 서버의 포트 80 뒤에 숨겨지고 EC2 보안 그룹을 통해 노출되지 않는 방법을 보여줍니다. 포트 80만 Application Load Balancer에 액세스할 수 있으며 포트 80에서 모든 트래픽이 대상 그룹으로 라우팅됩니다.

Application Request Routing(ARR)을 사용하는 Elastic Beanstalk 아키텍처

다음 명령은이 구성을 마이그레이션할 수 있습니다.

PS C:\migrations_workspace> eb migrate --sites "RouterSite,APIService,AdminPortal" ` --copy-firewall-config

ARR 마이그레이션 프로세스

마이그레이션 프로세스는 여러 단계를 통해 ARR 구성을 보존합니다.

구성 내보내기

도구는 세 개의 키 구성 섹션에서 ebmigrateScripts 디렉터리에 저장된 별도의 XML 파일로 기존 ARR 설정을 내보냅니다.

ebmigrateScripts\ ├── arr_config_proxy.xml ├── arr_config_rewrite.xml └── arr_config_caching.xml
설치 스크립트

ARR 설정을 처리하기 위해 두 개의 PowerShell 스크립트가 생성됩니다.

  1. arr_msi_installer.ps1: ARR 모듈을 다운로드하고 설치합니다.

  2. arr_configuration_importer_script.ps1: 내보낸 ARR 구성을 가져옵니다.

배포 매니페스트 통합

스크립트는의 항목을 통해 배포 프로세스에 통합됩니다aws-windows-deployment-manifest.json.

{ "manifestVersion": 1, "deployments": { "custom": [ { "name": "WindowsProxyFeatureEnabler", "scripts": { "install": { "file": "ebmigrateScripts\\windows_proxy_feature_enabler.ps1" } } }, { "name": "ArrConfigurationImporterScript", "scripts": { "install": { "file": "ebmigrateScripts\\arr_configuration_importer_script.ps1" } } } ] } }

로드 밸런서 통합

마이그레이션 프로세스는 가능한 경우 ARR 규칙을 Application Load Balancer(ALB) 리스너 규칙으로 변환합니다. 예를 들어 위의 ARR 구성을 사용하면 EC2 인스턴스에서 내부 라우팅을 유지하면서 URL 경로 패턴을 기반으로 트래픽을 라우팅하는 ALB 규칙이 생성됩니다.

결과 환경은 AWS의 탄력적 인프라를 활용하면서 ARR 라우팅 로직을 유지합니다. Application Load Balancer가 외부 트래픽 배포를 관리하는 동안 ARR이 내부 라우팅을 처리하는 등 애플리케이션은 이전과 같이 계속 작동합니다.

호스트 기반 라우팅을 사용한 ARR 없는 다중 사이트 마이그레이션

Application Request Routing(ARR)은 IIS에서 여러 사이트를 관리하는 일반적인 접근 방식이지만 Application Load Balancer의 호스트 기반 라우팅 기능을 활용하여 ARR 없이 다중 사이트 배포를 Elastic Beanstalk로 직접 마이그레이션할 수도 있습니다. 이 접근 방식은 추가 라우팅 계층을 제거하여 복잡성을 줄이고 성능을 개선할 수 있습니다.

호스트 기반 라우팅 개요

이 접근 방식에서는 각 IIS 사이트가 EC2 인스턴스 외부에 노출되고 Application Load Balancer는 호스트 헤더를 기반으로 트래픽을 적절한 포트로 직접 라우팅합니다. 이렇게 하면 애플리케이션 간의 분리를 유지하면서 ARR이 필요하지 않습니다.

자체 호스트 이름 바인딩이 있는 세 개의 사이트가 있는 다중 사이트 IIS 구성을 고려합니다.

<sites> <site name="Default Web Site" id="1"> <bindings> <binding protocol="http" bindingInformation="*:8081:www.example.com" /> </bindings> </site> <site name="InternalAPI" id="2"> <bindings> <binding protocol="http" bindingInformation="*:8082:api.internal" /> </bindings> </site> <site name="ReportingPortal" id="3"> <bindings> <binding protocol="http" bindingInformation="*:8083:reports.internal" /> </bindings> </site> </sites>

이러한 사이트는 EC2 보안 그룹을 통해 포트 8081, 8082 및 8083에 노출됩니다. Application Load Balancer는 Load Balancer서 리스너 규칙 구성을 기반으로 라우팅됩니다.

Application Request Routing(ARR)이 없는 Elastic Beanstalk 아키텍처

마이그레이션 프로세스

ARR을 사용하지 않고이 구성을 Elastic Beanstalk로 마이그레이션하려면 다음 예제에서 eb migrate 명령을 사용합니다.

PS C:\migrations_workspace> eb migrate --sites "Default Web Site,InternalAPI,ReportingPortal"

마이그레이션 프로세스는 호스트 헤더를 기반으로 트래픽을 적절한 대상 그룹으로 보내는 호스트 기반 라우팅 규칙을 사용하여 Application Load Balancer를 자동으로 구성합니다. 각 대상 그룹은 EC2 인스턴스의 해당 포트로 트래픽을 전달합니다.

  1. 호스트 헤더 www.example.com → 포트 8081의 대상 그룹

  2. 호스트 헤더 api.internal → 포트 8082의 대상 그룹

  3. 호스트 헤더 reports.internal → 포트 8083의 대상 그룹

SSL/TLS 구성

SSL/TLS로 애플리케이션을 보호하려면 다음 단계를 수행합니다.

  1. AWS Certificate Manager(ACM)을 통해 도메인에 대한 인증서를 요청합니다.

  2. 이러한 인증서를 사용하여 Application Load Balancer에서 HTTPS 리스너를 구성합니다.

  3. 다음 구성 옵션 설정으로 HTTPS 리스너를 포함하도록 환경 구성을 업데이트합니다.

    option_settings: aws:elb:listener:443: ListenerProtocol: HTTPS SSLCertificateId: arn:aws:acm:region:account-id:certificate/certificate-id InstancePort: 80 InstanceProtocol: HTTP

이 구성을 사용하면 로드 밸런서에서 SSL 종료가 수행되고 트래픽이 HTTP를 통해 인스턴스로 전달됩니다. 이렇게 하면 클라이언트와의 보안 연결을 유지하면서 인증서 관리를 간소화할 수 있습니다.

모범 사례

보안 그룹

Application Load Balancer 보안 그룹에서 IIS 사이트(이 예에서는 8081, 8082, 8083)에서 사용하는 포트에서만 인바운드 트래픽을 허용하도록 보안 그룹을 구성합니다.

상태 확인

트래픽이 정상 인스턴스로만 라우팅되도록 각 대상 그룹에 대한 상태 확인을 구성합니다. 아직 없는 경우 각 애플리케이션에 대한 상태 확인 엔드포인트를 생성합니다.

모니터링

CloudWatch 경보를 설정하여 각 대상 그룹의 상태와 성능을 개별적으로 모니터링합니다. 이를 통해 개별 애플리케이션과 관련된 문제를 식별할 수 있습니다.

스케일링

Auto Scaling 정책을 구성할 때 모든 애플리케이션의 리소스 요구 사항을 고려합니다. 한 애플리케이션에 리소스 요구 사항이 크게 다른 경우 별도의 환경으로 마이그레이션하는 것이 좋습니다.

가상 디렉터리 관리

eb migrate 명령은 IIS 애플리케이션을 Elastic Beanstalk로 마이그레이션하는 동안 가상 디렉터리 구조를 보존합니다.

기본 권한 구성

가상 디렉터리를 마이그레이션할 때는 ReadAndExecute에 다음에 대한 액세스 권한을 부여하여 기본 권한 세트를 eb migrate 설정합니다.

  • IIS_IUSRS

  • IUSR

  • 인증된 사용자

예를 들어 일반적인 가상 디렉터리 구조를 생각해 보세요.

<site name="CorporatePortal"> <application path="/" applicationPool="CorporatePortalPool"> <virtualDirectory path="/" physicalPath="C:\sites\portal" /> <virtualDirectory path="/shared" physicalPath="C:\shared\content" /> <virtualDirectory path="/reports" physicalPath="D:\reports" /> </application> </site>

암호로 보호되는 가상 디렉터리

에서 암호로 보호된 가상 디렉터리가 eb migrate 발생하면 경고가 발생하고 수동 개입이 필요합니다.

다음 구성 예제는 예제 다음에 오는 경고 응답을 발생시킵니다.

<virtualDirectory path="/secure" physicalPath="C:\secure\content" userName="DOMAIN\User" password="[encrypted]" />
[WARNING] CorporatePortal/secure is hosted at C:\secure\content which is password-protected and won't be copied.

암호 보호를 유지하려면 다음과 같은 사용자 지정 배포 스크립트를 생성합니다.

# PS C:\migrations_workspace> cat secure_vdir_config.ps1 $vdirPath = "C:\secure\content" $siteName = "CorporatePortal" $vdirName = "secure" $username = "DOMAIN\User" $password = "SecurePassword" # Ensure directory exists if (-not (Test-Path $vdirPath)) { Write-Host "Creating directory: $vdirPath" New-Item -Path $vdirPath -ItemType Directory -Force } # Configure virtual directory with credentials Write-Host "Configuring protected virtual directory: $vdirName" New-WebVirtualDirectory -Site $siteName -Name $vdirName ` -PhysicalPath $vdirPath -UserName $username -Password $password # Set additional permissions as needed $acl = Get-Acl $vdirPath $rule = New-Object System.Security.AccessControl.FileSystemAccessRule( $username, "ReadAndExecute", "ContainerInherit,ObjectInherit", "None", "Allow" ) $acl.AddAccessRule($rule) Set-Acl $vdirPath $acl

매니페스트에 포함시켜 배포에이 스크립트를 추가합니다.

{ "manifestVersion": 1, "deployments": { "custom": [ { "name": "SecureVirtualDirectory", "scripts": { "install": { "file": "secure_vdir_config.ps1" } } } ] } }

사용자 지정 권한 관리

eb migrate 명령은 기본값 이외의 권한이 필요한 애플리케이션을 수용하기 위한 사용자 지정 권한 스크립트용 프레임워크를 제공합니다.

$paths = @( "C:\sites\portal\uploads", "C:\shared\content" ) foreach ($path in $paths) { if (-not (Test-Path $path)) { Write-Host "Creating directory: $path" New-Item -Path $path -ItemType Directory -Force } $acl = Get-Acl $path # Add custom permissions $customRules = @( # Application Pool Identity - Full Control [System.Security.AccessControl.FileSystemAccessRule]::new( "IIS AppPool\CorporatePortalPool", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow" ), # Custom Service Account [System.Security.AccessControl.FileSystemAccessRule]::new( "NT SERVICE\CustomService", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow" ) ) foreach ($rule in $customRules) { $acl.AddAccessRule($rule) } Set-Acl $path $acl Write-Host "Custom permissions applied to: $path" }

모범 사례

다음 모범 사례에 따라 마이그레이션을 계획, 실행, 모니터링 및 확인합니다.

마이그레이션 전 계획

마이그레이션 전에 기존 권한 및 인증 요구 사항을 문서화합니다. 프로덕션에 배포하기 전에 개발 환경에서 사용자 지정 권한 스크립트를 테스트합니다.

공유 콘텐츠 관리

공유 콘텐츠 디렉터리의 경우 사용자 지정 스크립트를 통해 필요한 모든 파일 시스템 권한이 올바르게 구성되었는지 확인합니다. 공유 스토리지 요구 사항에 Amazon FSx for Windows File Server를 사용하는 것이 좋습니다.

모니터링 및 확인

마이그레이션 후 애플리케이션 로그를 모니터링하여 가상 디렉터리에 대한 적절한 액세스를 확인합니다. 다음 영역에 특히 주의하십시오.

  • 애플리케이션 풀 자격 증명 액세스

  • 사용자 지정 서비스 계정 권한

  • 네트워크 공유 연결

  • 인증 실패 횟수

사용자 지정 애플리케이션 풀 설정

eb migrate 명령은 기본적으로 사용자 지정 애플리케이션 풀 설정을 복사하지 않습니다. 사용자 지정 애플리케이션 풀 구성을 유지하려면 다음 절차에 따라 사용자 지정 매니페스트 섹션을 생성하고 적용합니다.

  1. 마이그레이션 아티팩트의 아카이브를 생성합니다.

    PS C:\migrations_workspace> eb migrate --archive
  2. 사용자 지정 PowerShell 스크립트를 생성하여 애플리케이션 풀을 구성합니다.

    # PS C:\migrations_workspace> cat .\migrations\latest\upload_target\customize_application_pool_config.ps1 $configPath = "$env:windir\System32\inetsrv\config\applicationHost.config" [xml]$config = Get-Content -Path $configPath $newPoolXml = @" <!-- Original IIS Configuration --> <applicationPools> <add name="CustomPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated"> <processModel identityType="SpecificUser" userName="AppPoolUser" password="[encrypted]" /> <recycling> <periodicRestart time="00:00:00"> <schedule> <add value="02:00:00" /> <add value="14:00:00" /> </schedule> </periodicRestart> </recycling> </add> </applicationPools> "@ $newPoolXmlNode = [xml]$newPoolXml # Find the applicationPools section $applicationPools = $config.SelectSingleNode("//configuration/system.applicationHost/applicationPools") # Import the new node into the document $importedNode = $config.ImportNode($newPoolXmlNode.DocumentElement, $true) $applicationPools.AppendChild($importedNode) # Save the changes $config.Save($configPath) Write-Host "ApplicationHost.config has been updated successfully."
  3. 사용자 지정 스크립트를 포함하도록 aws-windows-deployment-manifest.json 파일을 업데이트합니다.

    { "manifestVersion": 1, "deployments": { ... "custom": [ ..., { "name": "ModifyApplicationPoolConfig", "description": "Modify application pool configuration from source machine to remove", "scripts": { "install": { "file": "customize_application_pool_config.ps1" }, "restart": { "file": "ebmigrateScripts\\noop.ps1" }, "uninstall": { "file": "ebmigrateScripts\\noop.ps1" } } } ] } }
  4. 업데이트된 아카이브 디렉터리를 사용하여 환경을 생성합니다.

    PS C:\migrations_workspace> eb migrate ` --archive-dir '.\migrations\latest\upload_target\'

--archive-dir 인수는 새 아카이브가 생성되지 않도록 이전에 생성한 소스 코드를 사용하도록 eb migrate에 지시합니다.

이전 버전 배포

는 Elastic Beanstalk에서 타임스탬프가 지정된 디렉터리 및 애플리케이션 버전을 통해 마이그레이션 기록을 eb migrate 유지합니다. 각 마이그레이션은 필요한 경우 배포할 수 있는 고유한 zip 파일을 생성합니다.

PS C:\migrations_workspace> ls .\migrations\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----l 3/18/2025 10:34 PM latest d----- 3/16/2025 5:47 AM migration_1742104049.479849 d----- 3/17/2025 9:18 PM migration_1742246303.18056 d----- 3/17/2025 9:22 PM migration_1742246546.565739 ... d----- 3/18/2025 10:34 PM migration_1742337258.30742

latest 심볼 링크는 항상 가장 최근에 생성된 마이그레이션 아티팩트 디렉터리를 가리킵니다. 관련 애플리케이션 및 오류 로그 외에도 각 마이그레이션 아티팩트 디렉터리에는 Elastic Beanstalk에 배포할 수 있는 upload_target.zip 파일도 포함되어 있습니다.

PS C:\migrations_workspace> ls .\migrations\latest\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 3/18/2025 10:34 PM upload_target -a---- 3/18/2025 10:34 PM 13137 application.log -a---- 3/18/2025 10:34 PM 0 error.log -a---- 3/18/2025 10:34 PM 1650642 upload_target.zip

를 사용하여 upload_target.zip 파일을 배포할 수 있습니다eb migrate.

PS C:\migrations_workspace> eb migrate --zip .\migrations\latest\upload_target.zip