@@ -43,7 +43,17 @@ IReadOnlyList<string> BuildAllowlist()
4343
4444async Task < SQSBatchResponse > Handler ( SQSEvent ev , ILambdaContext context )
4545{
46- using var s3Client = new AmazonS3Client ( ) ;
46+ var region = Amazon . RegionEndpoint . GetBySystemName (
47+ Environment . GetEnvironmentVariable ( "AWS_REGION" ) ?? "us-east-1" ) ;
48+ var credentials = new Amazon . Runtime . EnvironmentVariablesAWSCredentials ( ) ;
49+
50+ using var s3Client = new AmazonS3Client ( credentials , new AmazonS3Config
51+ {
52+ RegionEndpoint = region ,
53+ Timeout = TimeSpan . FromSeconds ( 10 ) ,
54+ MaxErrorRetry = 2
55+ } ) ;
56+
4757 var batchItemFailures = new List < SQSBatchResponse . BatchItemFailure > ( ) ;
4858
4959 foreach ( var message in ev . Records )
@@ -91,6 +101,7 @@ async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
91101
92102async Task DeleteFromPublicBucket ( IAmazonS3 s3Client , string key , ILambdaContext context )
93103{
104+ context . Logger . LogDebug ( $ "Removing { key } from the public bucket", key ) ;
94105 try
95106 {
96107 _ = await s3Client . DeleteObjectAsync ( new DeleteObjectRequest
@@ -108,6 +119,8 @@ async Task DeleteFromPublicBucket(IAmazonS3 s3Client, string key, ILambdaContext
108119
109120async Task ScrubAndCopyToPublicBucket ( IAmazonS3 s3Client , string sourceBucket , string key , ILambdaContext context )
110121{
122+ context . Logger . LogDebug ( "Scrubbing {Key} to public bucket" , key ) ;
123+
111124 var fileName = Path . GetFileName ( key ) ;
112125 if ( string . Equals ( fileName , "registry-index.json" , StringComparison . OrdinalIgnoreCase ) )
113126 {
@@ -128,6 +141,7 @@ async Task ScrubAndCopyToPublicBucket(IAmazonS3 s3Client, string sourceBucket, s
128141 return ;
129142 }
130143
144+ context . Logger . LogInformation ( "Getting {Key} from private bucket" , key ) ;
131145 var getResponse = await s3Client . GetObjectAsync ( new GetObjectRequest
132146 {
133147 BucketName = sourceBucket ,
@@ -138,8 +152,10 @@ async Task ScrubAndCopyToPublicBucket(IAmazonS3 s3Client, string sourceBucket, s
138152 using ( var reader = new StreamReader ( getResponse . ResponseStream ) )
139153 content = await reader . ReadToEndAsync ( ) ;
140154
155+ context . Logger . LogInformation ( "Performing scrub pass for {Key}" , key ) ;
141156 var scrubbed = await ScrubContent ( key , content , context ) ;
142157
158+ context . Logger . LogInformation ( "Putting scrubbed {Key} on public bucket" , key ) ;
143159 _ = await s3Client . PutObjectAsync ( new PutObjectRequest
144160 {
145161 BucketName = publicBucketName ,
0 commit comments