Posts Tagged ‘AWSLambda’
[NodeCongress2021] Infrastructure as Code with a Node Focus – Tejas Kumar
Infrastructure as code (IaC) reimagines cloud provisioning as programmable artifacts, sidestepping manual drudgery for reproducible orchestration. Tejas Kumar, from G2i, spotlights this paradigm through a Node.js lens, particularly serverless stacks, advocating IaC’s collaborative potency in fostering velocity without opacity.
Tejas frames infrastructure broadly—from servers to CDNs—noting traditional GUI/CLIs’ pitfalls: non-versioned tweaks, manual sprawl, and siloed knowledge. IaC counters with textual manifests, git-checkable and diffable, enabling state snapshots akin to React’s reconciliation.
Embracing Terraform for Node.js Workflows
Terraform, HashiCorp’s declarative engine, shines for its provider-agnosticism, though Tejas demos AWS Lambda via HCL. A nascent function—invoking Puppeteer for screenshots—evolves: outputs expose ARNs, inputs parameterize runtimes.
Scaling introduces necessities: API Gateways proxy requests, integrations bridge methods to Lambdas, deployments stage changes. Tejas’s script weaves resources—REST APIs, paths proxying /{proxy+}, permissions invoking functions—culminating in endpoints serving dynamic images, like NodeCongress.com captures.
Apply commands enact diffs surgically: eight additions manifest sans recreating existents, yielding invocable URLs. Destruction symmetrizes, underscoring ephemerality’s purity.
Key Principles for IaC Adoption
Tejas distills wisdom: mechanize over manual for iterability; ephemeral over eternal to evade corruption; repeatable over rare for testability; transparent over turbid for team synergy. In Node.js contexts, IaC unifies app-infra pipelines, amplifying open-source virtues in scalable, auditable deployments.
Links:
[KotlinConf2019] Kotless: A Kotlin-Native Approach to Serverless with Vladislav Tankov
Serverless computing has revolutionized how applications are deployed and scaled, but it often comes with its own set of complexities, including managing deployment DSLs like Terraform or CloudFormation. Vladislav Tankov, then a Software Developer at JetBrains, introduced Kotless at KotlinConf 2019 as a Kotlin Serverless Framework designed to simplify this landscape. Kotless aims to eliminate the need for external deployment DSLs by allowing developers to define serverless applications—including REST APIs and event handling—directly within their Kotlin code using familiar annotations. The project can be found on GitHub at github.com/JetBrains/kotless.
Vladislav’s presentation provided an overview of the Kotless Client API, demonstrated its use with a simple example, and delved into the architecture and design concepts behind its code-to-deployment pipeline. The core promise of Kotless is to make serverless computations easily understandable for anyone familiar with event-based architectures, particularly those comfortable with JAX-RS-like annotations.
Simplifying Serverless Deployment with Kotlin Annotations
The primary innovation of Kotless, as highlighted by Vladislav Tankov, is its ability to interpret Kotlin code and annotations to automatically generate the necessary deployment configurations for cloud providers like AWS (initially). Instead of writing separate configuration files in YAML or other DSLs, developers can define their serverless functions, API gateways, permissions, and scheduled events using Kotlin annotations directly on their functions and classes.
For example, creating a REST API endpoint could be as simple as annotating a Kotlin function with @Get("/mypath")
. Kotless then parses these annotations during the build process and generates the required infrastructure definitions, deploys the lambdas, and configures the API Gateway. This approach significantly reduces boilerplate and the cognitive load associated with learning and maintaining separate infrastructure-as-code tools. Vladislav emphasized that a developer only needs familiarity with these annotations to create and deploy a serverless REST API application.
Architecture and Code-to-Deployment Pipeline
Vladislav Tankov provided insights into the inner workings of Kotless, explaining its architecture and the pipeline that transforms Kotlin code into a deployed serverless application. This process generally involves:
1. Annotation Processing: During compilation, Kotless processes the special annotations in the Kotlin code to understand the desired serverless architecture (e.g., API routes, event triggers, scheduled tasks).
2. Terraform Generation (Initially): Kotless then generates the necessary infrastructure-as-code configurations (initially using Terraform as a backend for AWS) based on these processed annotations. This includes defining Lambda functions, API Gateway resources, IAM roles, and event source mappings.
3. Deployment: Kotless handles the deployment of these generated configurations and the application code to the target cloud provider.
He also touched upon optimizations built into Kotless, such as “outer warming” of lambdas to reduce cold starts and optimizing lambdas by size. This focus on performance and ease of use is central to Kotless’s philosophy. The framework aims to abstract away the underlying complexities of serverless platforms, allowing developers to concentrate on their application logic.
Future Directions and Multiplatform Aspirations
Looking ahead, Vladislav Tankov discussed the future roadmap for Kotless, including ambitious plans for supporting Kotlin Multiplatform Projects (MPP). This would allow developers to choose different runtimes for their lambdas—JVM, JavaScript, or even Kotlin/Native—depending on the task and performance requirements. Supporting JavaScript lambdas, for example, could open up compatibility with platforms like Google Cloud Platform more broadly, which at the time had better support for JavaScript runtimes than JVM for serverless functions.
Other planned enhancements included extended event handling for custom events on AWS and other platforms, and continued work on performance optimizations. The vision for Kotless was to provide a comprehensive and flexible serverless solution for Kotlin developers, empowering them to build efficient and scalable cloud-native applications with minimal friction. Vladislav encouraged attendees to try Kotless and contribute to its development, positioning it as a community-driven effort to improve the Kotlin serverless experience.