34 lines
1.3 KiB
PowerShell
34 lines
1.3 KiB
PowerShell
# 로컬 경로 지정
|
|
$localPath="c:\users\admin\aws\s3sync"
|
|
|
|
# AWS PowerShell .Net Core 모듈 확인 및 설치
|
|
if (!(Get-Module -ListAvailable -Name AWSPowerShell.NetCore)) {
|
|
Write-Host "AWS PowerShell .Net Core module is not installed. Installing now..."
|
|
Install-Module -Name AWSPowerShell.NetCore -Force -Confirm:$false
|
|
}
|
|
|
|
# 필요한 파라미터 설정
|
|
$localPath = 'c:\users\admin\aws\s3sync' # 로컬 디렉토리 경로
|
|
$s3_bucket="metaverse-client-launch"
|
|
$s3_dir="s3sync"
|
|
$bucketName = "$s3_bucket/$s3_dir"
|
|
|
|
# AWS CLI가 설치되어 있는지 확인하고, 없다면 설치
|
|
if (!(Get-Command aws -ErrorAction SilentlyContinue)) {
|
|
Write-Host "AWS CLI is not installed. Please install it first."
|
|
Exit
|
|
}
|
|
|
|
# 로컬 디렉토리의 모든 파일 및 하위 디렉토리를 S3로 전송
|
|
Get-ChildItem $localPath -Recurse | ForEach-Object {
|
|
if (! $_.PSIsContainer) {
|
|
$start = Get-Date
|
|
Write-Host "Uploading $($_.FullName)"
|
|
$key = $_.FullName.Substring($localPath.Length + 1)
|
|
aws s3 cp $_.FullName s3://$bucketName/$key
|
|
$end = Get-Date
|
|
$size = (Get-Item $_.FullName).Length / 1MB
|
|
$duration = $end - $start
|
|
Write-Host "Uploaded $($_.FullName) of size $size MB, took $duration seconds"
|
|
}
|
|
} |