gradle-aws-plugin
gradle-aws-plugin copied to clipboard
AWS SAM Support
Currently, I have my build tool download python and the aws cli to deploy my SAM template. My current deploy task looks like:
task packageSam(dependsOn: getTasksByName("shadowJar", true)) {
doLast {
exec {
commandLine "aws", "cloudformation", "package", "--template-file", "service.yml", "--s3-bucket", deploymentBucketName, "--output-template-file", "service-out.yml"
}
}
}
task deploy(dependsOn: packageSam) {
doLast {
exec {
commandLine "aws", "cloudformation", "deploy", "--template-file", "service-out.yml", "--stack-name", "my-service", "--parameter-overrides", "Stage=latest", "--capabilities", "CAPABILITY_IAM"
}
}
}
I think I'd be able to use this tool and eliminate the aws cli if it supported the cloudformation package
and cloudformation deploy
commands.
+1
I believe cloudformation package
part can currently be replicated using the existing AmazonS3FileUploadTask
, Gradle variables and CloudFormation parameters. For example, in my case I read an S3 bucket name and key from config, upload code for a Lambda function to S3 using the AmazonS3FileUploadTask
with the given bucket and key, and pass the same key and bucket as CloudFormation parameters when deploying using awsCfnMigrateStack
.
The cloudformation package
command creates and executes a change set, which is required for templates containing transforms. I've added a similar Gradle task that does the same here: https://github.com/classmethod/gradle-aws-plugin/pull/146. I've done some testing and it works well for my use cases; would be good if others could take a look.