How to Configure Create and Manage Application Infrastructure via Scripts Infrastructure As Code

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams create and manage application infrastructure via scripts infrastructure as code to control cloud systems with text files. You set this up safely by storing template files in source control and assigning narrow deploy roles. Manual setup in a web console leads to human errors and drift over time. Two engineers can click different boxes and build mismatched servers for the same app. When you write server rules in plain text, every change goes through a peer review first. How to create and

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams create and manage application infrastructure via scripts infrastructure as code to control cloud systems with text files. You set this up safely by storing template files in source control and assigning narrow deploy roles.

Manual setup in a web console leads to human errors and drift over time. Two engineers can click different boxes and build mismatched servers for the same app. When you write server rules in plain text, every change goes through a peer review first.

How to create and manage application infrastructure via scripts infrastructure as code

This pattern replaces manual clicks with versioned text files that define your desired cloud state. A build runner reads your text files and compares them to the live cloud setup. Then the runner calls the cloud provider API to add, change, or remove servers and databases.

This setup affects both human engineers and automated build pipelines across every team. In a safe setup, human users do not run deploy scripts from their own laptops. Instead, developers push code to a shared repo and open a pull request for review.

Safe defaults start with least privilege for the build runner role. Give the runner only the exact permissions it needs for that one app. Split your state files by app and stage so a test change never hits production.

Lock the state file during every run so two pipelines cannot clash at the same time. Store the state file in an encrypted bucket with strict role rules and version history turned on. Never put plain text keys, database passwords, or tokens inside your repo files or state store.

Scoping runner roles and isolating state files

A build runner needs strong permissions to create networks, roles, and databases on your behalf. If one runner holds admin rights for the whole cloud, a single bad script can wipe out production. You can reduce this blast radius by splitting each app and stage into its own account.

Give the test runner a role that only works inside the test account. Give the prod runner a separate role that only works inside the prod account. Require a human sign-off step before the prod runner can apply any plan to live systems.

Application-to-Application Password Management + Infrastructure as Code Security Scanning: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Use short-lived federated tokens for your build runners instead of static cloud keys. Static keys sitting in pipeline settings are a prime target for attackers who breach your code host. Federated tokens expire after a few minutes and link right to a single pipeline run.

Auditing script runs and live session gaps

You can verify your setup by running drift checks on a daily schedule. A drift check compares your repo files against the live cloud and alerts you to manual edits. You should also run policy checks on every plan file before the runner applies changes.

Policy checks block unsafe rules like open network ports or unencrypted disks before they go live. Cloud API logs record which runner role made each call and when the change happened. These logs help you trace when a server or database role changed.

Still, static code templates only set up the base server, network, and login role. Once an engineer or app logs into a live database or server, those templates do nothing. Static setup files cannot see or control what commands run inside an active session.

If a developer logs in to fix a bug, the template cannot block a bad query. It also cannot mask sensitive fields like emails, phone numbers, card numbers, or national IDs in query results. Controlling live queries and commands requires runtime checks on each command, not just build-time scripts.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why should teams avoid running deploy scripts from local laptops?

Local runs require broad cloud permissions on developer laptops and can bypass peer review. Running scripts only from a central pipeline ensures every change is reviewed and logged.

How do you handle secrets when setting up cloud servers with scripts?

Never store plain text passwords or keys in your code files or state files. Let your scripts create empty secret slots, or pull values from a dedicated secret store at run time.

What happens when someone changes a cloud setting outside the script?

Manual edits create drift between your code files and the live cloud state. The next pipeline run will either overwrite the manual change or fail until you fix the mismatch.

The query runs. The emails stay hidden.