3
3
import com .amazonaws .services .lambda .runtime .Context ;
4
4
import com .amazonaws .services .lambda .runtime .events .CloudFormationCustomResourceEvent ;
5
5
import java .util .Objects ;
6
- import org .apache . logging . log4j . LogManager ;
7
- import org .apache . logging . log4j . Logger ;
6
+ import org .slf4j . Logger ;
7
+ import org .slf4j . LoggerFactory ;
8
8
import software .amazon .awssdk .awscore .exception .AwsServiceException ;
9
9
import software .amazon .awssdk .core .exception .SdkClientException ;
10
10
import software .amazon .awssdk .core .waiters .WaiterResponse ;
24
24
*/
25
25
26
26
public class App extends AbstractCustomResourceHandler {
27
- private final static Logger log = LogManager .getLogger (App .class );
27
+ private static final Logger log = LoggerFactory .getLogger (App .class );
28
28
private final S3Client s3Client ;
29
29
30
30
public App () {
@@ -47,7 +47,7 @@ protected Response create(CloudFormationCustomResourceEvent cloudFormationCustom
47
47
Objects .requireNonNull (cloudFormationCustomResourceEvent .getResourceProperties ().get ("BucketName" ),
48
48
"BucketName cannot be null." );
49
49
50
- log .info (cloudFormationCustomResourceEvent );
50
+ log .info (cloudFormationCustomResourceEvent . toString () );
51
51
String bucketName = (String ) cloudFormationCustomResourceEvent .getResourceProperties ().get ("BucketName" );
52
52
log .info ("Bucket Name {}" , bucketName );
53
53
try {
@@ -57,7 +57,7 @@ protected Response create(CloudFormationCustomResourceEvent cloudFormationCustom
57
57
return Response .success (bucketName );
58
58
} catch (AwsServiceException | SdkClientException e ) {
59
59
// In case of error, return a failed response, with the bucketName as the physicalResourceId
60
- log .error (e );
60
+ log .error ("Unable to create bucket" , e );
61
61
return Response .failed (bucketName );
62
62
}
63
63
}
@@ -77,7 +77,7 @@ protected Response update(CloudFormationCustomResourceEvent cloudFormationCustom
77
77
Objects .requireNonNull (cloudFormationCustomResourceEvent .getResourceProperties ().get ("BucketName" ),
78
78
"BucketName cannot be null." );
79
79
80
- log .info (cloudFormationCustomResourceEvent );
80
+ log .info (cloudFormationCustomResourceEvent . toString () );
81
81
// Get the physicalResourceId. physicalResourceId is the value returned to CloudFormation in the Create request, and passed in on subsequent requests (e.g. UPDATE or DELETE)
82
82
String physicalResourceId = cloudFormationCustomResourceEvent .getPhysicalResourceId ();
83
83
log .info ("Physical Resource ID {}" , physicalResourceId );
@@ -94,7 +94,7 @@ protected Response update(CloudFormationCustomResourceEvent cloudFormationCustom
94
94
// Return a successful response with the newBucketName
95
95
return Response .success (newBucketName );
96
96
} catch (AwsServiceException | SdkClientException e ) {
97
- log .error (e );
97
+ log .error ("Unable to create bucket" , e );
98
98
return Response .failed (newBucketName );
99
99
}
100
100
} else {
@@ -120,7 +120,7 @@ protected Response delete(CloudFormationCustomResourceEvent cloudFormationCustom
120
120
Objects .requireNonNull (cloudFormationCustomResourceEvent .getPhysicalResourceId (),
121
121
"PhysicalResourceId cannot be null." );
122
122
123
- log .info (cloudFormationCustomResourceEvent );
123
+ log .info (cloudFormationCustomResourceEvent . toString () );
124
124
// Get the physicalResourceId. physicalResourceId is the value provided to CloudFormation in the Create request.
125
125
String bucketName = cloudFormationCustomResourceEvent .getPhysicalResourceId ();
126
126
log .info ("Bucket Name {}" , bucketName );
@@ -135,7 +135,7 @@ protected Response delete(CloudFormationCustomResourceEvent cloudFormationCustom
135
135
return Response .success (bucketName );
136
136
} catch (AwsServiceException | SdkClientException e ) {
137
137
// Return a failed response in case of errors during the bucket deletion
138
- log .error (e );
138
+ log .error ("Unable to delete bucket" , e );
139
139
return Response .failed (bucketName );
140
140
}
141
141
} else {
@@ -166,7 +166,7 @@ private void createBucket(String bucketName) {
166
166
s3Client .createBucket (createBucketRequest );
167
167
WaiterResponse <HeadBucketResponse > waiterResponse =
168
168
waiter .waitUntilBucketExists (HeadBucketRequest .builder ().bucket (bucketName ).build ());
169
- waiterResponse .matched ().response ().ifPresent (log :: info );
169
+ waiterResponse .matched ().response ().ifPresent (res -> log . info ( res . toString ()) );
170
170
log .info ("Bucket Created {}" , bucketName );
171
171
}
172
172
}
0 commit comments