Lädt...


🔧 Bringing declarative infrastructure to developers


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Over the past decade, Terraform has revolutionized how operations (Ops) teams manage cloud infrastructure by providing a simple, declarative way to define and provision resources.
Terraform allows us to declare cloud resources using a simple configuration language (HCL), which can then be executed to create or modify resources.

Here’s a simple example of declaring a bucket:

resource "aws_s3_bucket" "example_bucket" {
  bucket = "my-example-bucket"
  acl    = "private"

  tags = {
    Name        = "MyExampleBucket"
    Environment = "Dev"
  }

  versioning {
    enabled = true
  }
}

When you run terraform apply, terraform relies on providers to parse and translate the configuration into API requests. The provider acts as a bridge between Terraform and the AWS API, it constructs the necessary API calls to fulfill the requirements specification and sends them to AWS, where the actual creation of the bucket, tagging, and versioning happens.

Terraform handles all the communication with cloud providers, ensuring that resources are created or updated according to the configuration file, without requiring direct interaction with cloud APIs. But what about developers who also need to work with cloud infrastructure?

Our current workflow generally leads us towards building an application first, then handling the infrastructure.

This means that developers have a few choices:

  • Create variables for all unknown configuration and throw the ball over the fence to an ops team
  • Work intimately with the ops team to detail resource names, configuration etc.
  • Do it themselves with tools they aren’t in love with

None of these options are particularly desirable as they rely on a lot of manual steps which often lead to communication breakdowns and runtime/provision time errors. We need a way of shifting the declaration of resources forward in the workflow without introducing additional complexity to our teams.

Declarative infrastructure for developers

I’m not suggesting that developers don’t need to know how storage buckets, databases or APIs work, they just don’t need to know the specifics of how they will be provisioned while they are writing their application code.

With Infrastructure from Code (IfC), developers can declaratively define and request cloud resources such as APIs, storage buckets, and queues directly within their application logic. This declarative approach allows developers to specify what they want without worrying about how they will be provisioned.

Here’s an example of how this might work, and, actually, this should look extremely familiar, the only addition a declaration of the developers intent - to allow reading and writing on the bucket and this information is the missing link to assign the right permissions for the resources to interact with each other.

import * as nitric from '@nitric/sdk'

// Define a bucket for storing images
const imagesBucket = nitric.bucket('images').allow('read', 'write')

// Define an API for serving images
const mainApi = nitric.api('main')
mainApi.get('/images/:key', async (ctx) => {
  // Your image-serving logic here
})

From this example it's simple enough to recognize that we need the following cloud resources:

  • bucket('images').allow('read', 'write'): Creates a cloud storage bucket named "images" and sets access permissions for reading and writing.
  • api('main'): Creates an API named "main" with a route to serve images. The developer can then define application logic for handling image requests.
  • OpenAPI specification: From the routes configured we can automatically create the configuration required for our API gateways.

We can automatically generate the requirements specification -

{
  "resources": [
    {
      "id": {
        "type": "Bucket",
        "name": "images"
      },
      "bucket": {}
    },
    {
      "id": {
        "name": "main"
      },
      "api": {
        "openapi": "{\"components\":{},\"info\":{\"title\":\"main\",\"version\":\"v1\"},\"openapi\":\"3.0.1\",\"paths\":{\"/images/{key}\":{\"get\":{\"operationId\":\"imageskeyget\",\"responses\":{\"default\":{\"description\":\"\"}},\"x-nitric-target\":{\"name\":\"api-testing_services-hello\",\"type\":\"function\"}},\"parameters\":[{\"in\":\"path\",\"name\":\"key\",\"required\":true,\"schema\":{\"type\":\"string\"}}]}}}"
      }
    }
  ]
}

Bridging Runtime and Provisioning Gaps

One of the major challenges developers face is ensuring that the resources their application depends on are correctly provisioned at runtime. The generated specification ensures that the correct resources (storage buckets, APIs, etc.) are provisioned with the appropriate settings (permissions, paths, etc.). This removes the potential for mismatches between what the application requires and what is provisioned, ensuring a smoother deployment process.

We can now use it to orchestrate the necessary IaC, like the Terraform module above, to provision the required resources. This approach minimizes runtime and provision-time errors, ensuring that resources are automatically provisioned in line with application requirements.

It also means that the same application can be deployed across different cloud providers, which means you can pivot at any time to take advantage of the latest technologies and disruptors like AI.

...

🔧 Bringing declarative infrastructure to developers


📈 45.44 Punkte
🔧 Programmierung

🔧 KCL + Crossplane: A Declarative Language for Deploying Complex Infrastructure on AWS with Kubernetes.


📈 26.86 Punkte
🔧 Programmierung

🔧 The issue of recursive module calls in declarative infrastructure-as-code


📈 26.86 Punkte
🔧 Programmierung

🔧 Declarative vs Imperative


📈 19.17 Punkte
🔧 Programmierung

🔧 Challenge: Design for declarative device management in your MDM solution


📈 19.17 Punkte
🔧 Programmierung

🔧 Noema – A Declarative AI Programming Library


📈 19.17 Punkte
🔧 Programmierung

🎥 Doodle break! summary of declarative agents


📈 19.17 Punkte
🎥 Video | Youtube

🔧 Is SQL a Declarative Language?


📈 19.17 Punkte
🔧 Programmierung

🔧 Day 27 Task: Jenkins Declarative Pipeline with Docker


📈 19.17 Punkte
🔧 Programmierung

🔧 New in Chrome 90: Overflow Clip, Permissions Policy, the Declarative Shadow DOM, and more!


📈 19.17 Punkte
🔧 Programmierung

🎥 Declarative Shadow DOM: Hello HTML


📈 19.17 Punkte
🎥 Video | Youtube

🔧 The World of HarmonyOS Programming: Declarative UI Programming and State Management in ArkUI


📈 19.17 Punkte
🔧 Programmierung

🔧 Is SQL a declarative language


📈 19.17 Punkte
🔧 Programmierung

🔧 Jenkins Declarative Pipeline - An Overview with example


📈 19.17 Punkte
🔧 Programmierung

🔧 Using Rust and Leptos to build beautiful, declarative UIs


📈 19.17 Punkte
🔧 Programmierung

🔧 Declarative Multi-Engine Data Stack with Ibis


📈 19.17 Punkte
🔧 Programmierung

🕵️ Pipeline Declarative Plugin up to 1.3.3 Sandbox Converter.groovy Remote Code Execution


📈 19.17 Punkte
🕵️ Sicherheitslücken

🔧 Authorization needs to be dynamic, declarative, and decoupled


📈 19.17 Punkte
🔧 Programmierung

🔧 Customizable and re-usable embedded views using NgTemplateOutlet in Angular (Declarative way)


📈 19.17 Punkte
🔧 Programmierung

💾 vSphere 7 with Kubernetes – Declarative GitOps Continuous Delivery for Tanzu Kubernetes clusters


📈 19.17 Punkte
💾 Downloads

🔧 The Declarative Revolution: React, SwiftUI, and Jetpack Compose


📈 19.17 Punkte
🔧 Programmierung

🔧 Astro Markdoc: Readable, Declarative MDX Alternative


📈 19.17 Punkte
🔧 Programmierung

🔧 Understanding Declarative Programming in React


📈 19.17 Punkte
🔧 Programmierung

🔧 Web Request and Declarative Net Request: Explaining the impact on Extensions in Manifest V3


📈 19.17 Punkte
🔧 Programmierung

🔧 The declarative approach in Vue 3, think twice before using `watch` or mutating your state


📈 19.17 Punkte
🔧 Programmierung

🔧 Nucleoid: Neuro-Symbolic AI with Declarative Logic


📈 19.17 Punkte
🔧 Programmierung

🔧 Declarative Programming in Rust


📈 19.17 Punkte
🔧 Programmierung

🎥 Introducing Declarative Agents


📈 19.17 Punkte
🎥 Video | Youtube

🔧 The declarative approach in Vue 3, think twice before using `watch` or mutating your state


📈 19.17 Punkte
🔧 Programmierung

📰 heise+ | Optimierte Geräteverwaltung: Declarative Device Management für Apple-Geräte


📈 19.17 Punkte
📰 IT Nachrichten

📰 Decker - Declarative Penetration Testing Orchestration Framework


📈 19.17 Punkte
📰 IT Security Nachrichten

matomo