-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_aws_cli.ps1
More file actions
39 lines (29 loc) · 1.38 KB
/
test_aws_cli.ps1
File metadata and controls
39 lines (29 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# test_aws_cli.ps1
# A bash script to test tiny-object-storage using the AWS CLI
$ENDPOINT = "http://127.0.0.1:9000"
$BUCKET = "aws-cli-test-bucket"
$OBJECT = "test-folder/hello-cli.txt"
$FILE_PATH = "sample_upload.txt"
# Set dummy AWS credentials for this session
$env:AWS_ACCESS_KEY_ID="dummy"
$env:AWS_SECRET_ACCESS_KEY="dummy"
$env:AWS_DEFAULT_REGION="us-east-1"
Write-Host "Creating sample file..."
Set-Content -Path $FILE_PATH -Value "Hello from AWS CLI to tiny-object-storage!"
Write-Host "`n1. Creating bucket '$BUCKET'..."
aws s3 mb s3://$BUCKET --endpoint-url $ENDPOINT
Write-Host "`n2. Uploading object..."
aws s3 cp $FILE_PATH s3://$BUCKET/$OBJECT --endpoint-url $ENDPOINT
Write-Host "`n3. Listing objects in bucket..."
aws s3 ls s3://$BUCKET/ --recursive --endpoint-url $ENDPOINT
Write-Host "`n4. Downloading object..."
aws s3 cp s3://$BUCKET/$OBJECT downloaded_sample.txt --endpoint-url $ENDPOINT
$DownloadedContent = Get-Content -Path downloaded_sample.txt
Write-Host "Downloaded content: $DownloadedContent"
Write-Host "`n5. Cleaning up (Deleting object and bucket)..."
aws s3 rm s3://$BUCKET/$OBJECT --endpoint-url $ENDPOINT
aws s3 rb s3://$BUCKET --endpoint-url $ENDPOINT
# Clean up local temporary files
Remove-Item -Path $FILE_PATH -ErrorAction SilentlyContinue
Remove-Item -Path downloaded_sample.txt -ErrorAction SilentlyContinue
Write-Host "`nAWS CLI Test completed successfully!"