We are experimenting with Jetbrains Space as our code repo and CI/CD. We are trying to find a way to setup the .space.kts
file to deploy to AWS Lambda.
We want the develop
branch to publish to the Lambda $Latest
and when we merge to the main
branch from the develop
branch we want it to publish a new Lambda version and link that version to the alias pro
.
I've looked around but haven't found anything that would suggest there is a pre-built solution for controlling AWS Lambda so my current thinking is something like this:
job("Publish to Lambda Latest") {
startOn {
gitPush {
branchFilter {
+"refs/heads/develop"
}
}
}
container(displayName = "AWS Lambda CLI", image = "amazon/aws-cli") {
// Space Packages repository
env["REPOSITORY_URL"] = "https://..."
shellScript {
content = """
echo Deploying to Lambda Latest...
...
"""
}
}
}
I'm not convinced that using a shell script is a very robust way to do this as I will need to pass variables from one command to another. Is there a better way to do this?
There is no built-in DSL for interacting with AWS.
If you want a solution that is more type-safe than plain
shellScript
, and maybe reuse data between multiple calls etc, you can still use Kotlin code directly (in akotlinScript
block instead ofshellScript
).You can specify maven dependencies for your
.space.kts
script via the@DependsOn
annotation, which you can use for instance to add modules from the AWS Java SDK:The piece of code shown here is just for the sake of the example (to show that you can use the AWS SDK classes and methods), it's not a complete example on how to publish a lambda.