Skip to content

Commit

Permalink
Merge pull request #2 from fieldju/feature/more_logging
Browse files Browse the repository at this point in the history
Add more logging
  • Loading branch information
fieldju committed Mar 6, 2017
2 parents bb089f9 + 618e461 commit bd08a5a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.fieldju
artifactId=gradle-aws-sam-deployer-plugin
version=1.1.0
version=1.2.0
1 change: 1 addition & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.7'
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: "$awsSDKVersion"
compile group: 'com.amazonaws', name: 'aws-java-sdk-cloudformation', version: "$awsSDKVersion"
compile group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: "$awsSDKVersion"


testCompile "junit:junit:4.12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.amazonaws.waiters.Waiter
import com.amazonaws.waiters.WaiterParameters
import com.fieldju.gradle.plugins.lambdasam.AwsSamDeployerPlugin
import groovy.util.logging.Slf4j
import org.gradle.api.logging.LogLevel
import org.gradle.testfixtures.ProjectBuilder
import org.junit.After
import org.junit.Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class S3Uploader {

def s3Uri = "s3://${bucket}/${key}"

logger.lifecycle("Generated md5 hash: ${md5Hash} attempting to put ${file.getName()} at ${s3Uri}}")
if (! forceUploads && transferManager.getAmazonS3Client().doesObjectExist(bucket, key)) {
logger.lifecycle("File: ${file.absolutePath} with MD5: ${md5Hash} already uploaded at: ${s3Uri} skipping ...")
return s3Uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DeploySamTask extends SamTask {
@TaskAction
void taskAction() {
def config = project.extensions.getByName(AwsSamDeployerPlugin.EXTENSION_NAME) as AwsSamDeployerExtension
logExtraDetails(config)

CloudFormationDeployer deployer = new CloudFormationDeployer(
AmazonCloudFormationClient.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class PackageSamTask extends SamTask {
@TaskAction
void taskAction() {
def config = project.extensions.getByName(AwsSamDeployerPlugin.EXTENSION_NAME) as AwsSamDeployerExtension
logExtraDetails(config)

def s3Bucket = config.getS3Bucket()
def s3Prefix = config.getS3Prefix()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.fieldju.gradle.plugins.lambdasam.tasks

import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient;
import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest
import com.fieldju.gradle.plugins.lambdasam.AwsSamDeployerExtension
import org.gradle.api.DefaultTask;

public abstract class SamTask extends DefaultTask {

protected void logExtraDetails(AwsSamDeployerExtension extension) {
try {
def stsClient = AWSSecurityTokenServiceClient.builder().standard().withRegion(extension.getRegion()).build()
def res = stsClient.getCallerIdentity(new GetCallerIdentityRequest())
logger.lifecycle("Running Command: ${this.name} with AWS Identity info, ARN: ${res.arn}, Account: ${res.account}, UserId: ${res.userId}")
} catch (Throwable t) {
logger.error("Failed to get caller identity via AWS STS", t)
}

logger.info("region: ${extension.region}")
logger.info("s3Bucket: ${extension.s3Bucket}")
logger.info("s3Prefix: ${extension.s3Prefix}")
logger.info("kmsKeyId: ${extension.kmsKeyId}")
logger.info("samTemplatePath: ${extension.samTemplatePath}")
logger.info("stackName: ${extension.stackName}")
logger.info("tokenArtifactMap: ${extension.tokenArtifactMap}")
logger.info("parameterOverrides: ${extension.parameterOverrides}")
logger.info("forceUploads: ${extension.forceUploads}")
}
}

This file was deleted.

0 comments on commit bd08a5a

Please sign in to comment.