Markdown Editor

Infrastructure Design Template (Infrastructure as Code)

Cloud infrastructure via IaC: environments, VPC/subnet CIDR plan, compute, storage, state, pipelines, IAM, tagging, DR, policy as code, cost

आर्किटेक्चर और सिस्टम डिज़ाइनपूर्णinfrastructuredesignmath
एडिटर में खोलें.md डाउनलोड करें

उपयोग कैसे करें: Use when designing or documenting the infrastructure for a workload built with Terraform, OpenTofu or similar tools. Fix environments, account layout and address ranges first, since they are expensive to change later. Main pitfall: hand-made resources and unrecorded exceptions that drift from the code; list them in 19.2.

प्रीव्यू

Infrastructure Design: [Platform or workload name]

Complete infrastructure design for a workload built and run with Infrastructure as Code: environments, network, compute, storage, managed services, repository and module conventions, state, CI/CD for infrastructure, secrets, identity and access, tagging and cost allocation, scaling, backup and disaster recovery, observability, security baselines with policy as code, change management and a cost estimate. Based on common industry practice for cloud infrastructure design. Replace every [bracketed] value and every row marked Example. Worked examples use a web application on a public cloud with Terraform or OpenTofu.

Document control

FieldValue
Document ID[INFRA-DES-WEBAPP-001]
Platform / workload[Customer portal]
Cloud provider(s)[Provider]
Accounts / subscriptions / projects[portal-dev, portal-stg, portal-prod, shared-network, security-logs]
Version[0.1]
Status[Draft / In review / Approved / Superseded]
Owner[@platform-lead]
Classification[Internal / Confidential]
Last updatedYYYY-MM-DD
Related[System design], [Security architecture], [IaC repository URL]

Approvals

RoleNameDecisionDate
Platform lead[@name][Approved / Changes requested]YYYY-MM-DD
Application tech lead[@name][Decision]YYYY-MM-DD
Security[@name][Decision]YYYY-MM-DD
FinOps / budget owner[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft
0.2YYYY-MM-DD[@name]Example: Added second region for disaster recovery
1.0YYYY-MM-DD[@name]Example: Approved; implemented in IaC release v1.0.0

Contents

1. Introduction

1.1 Purpose and scope

[What this design covers. Example: "Infrastructure for the customer portal: networking, compute, data stores and supporting services in three environments, provisioned entirely from the infra-portal repository."]

1.2 Requirements driving the design

IDRequirementSourceDesign response
IR-01Example: 99.9% monthly availabilitySystem design NFR-02Three availability zones; managed database with standby
IR-02Example: RPO 15 min, RTO 4 hoursBusiness continuity planCross-region backups; scripted rebuild in DR region
IR-03Example: Personal data stays in the EUData protection assessmentEU regions only; policy blocks other regions
IR-04Example: Monthly run cost under EUR 12 000 in productionBudgetRight-sizing, commitments, non-production schedules
[IR-nn][Requirement][Source][Response]

1.3 Key decisions

IDDecisionAlternativesRationaleADR
ID-01Example: Terraform-compatible IaC (OpenTofu)Provider-native templates, PulumiTeam skills; multi-provider modules[ADR-012]
ID-02Example: Managed Kubernetes for servicesServerless containers, VMsExisting platform tooling[ADR-013]
[ID-nn][Decision][Alternatives][Rationale][Link]

2. Environments and account structure

EnvironmentAccount / projectRegion(s)PurposeDataParity with production
devportal-dev[eu-west-1]Feature development, ephemeral stacksSyntheticReduced sizes, single AZ
stagingportal-stg[eu-west-1]Pre-production tests, load testsMasked copySame topology, smaller sizes
productionportal-prod[eu-west-1] primary, [eu-central-1] DRLive serviceLiven/a
shared-networkshared-networkBothTransit gateway, DNS, egressNonen/a
security-logssecurity-logs[eu-west-1]Central immutable logsLogsn/a

Each environment is a separate account so that a mistake in one cannot change another. Ephemeral dev stacks are named dev-<branch> and destroyed after [72 hours] of inactivity.

3. Network design

3.1 Address plan

NetworkEnvironmentCIDRUsable addressesNotes
Corporate (reserved)n/a10.0.0.0/12n/aDo not use in cloud
VPC portal-prodproduction10.32.0.0/1665 536Primary region
VPC portal-prod-drproduction DR10.33.0.0/1665 536DR region
VPC portal-stgstaging10.34.0.0/1665 536
VPC portal-devdev10.35.0.0/1665 536
[VPC][Environment][CIDR][n][Notes]

3.2 Subnets (production primary region)

SubnetTierAZCIDRAddressesRoute to internet
public-aPublic (load balancers, NAT)a10.32.0.0/24256Internet gateway
public-bPublicb10.32.1.0/24256Internet gateway
public-cPublicc10.32.2.0/24256Internet gateway
app-aPrivate (compute)a10.32.16.0/204 096NAT in same AZ
app-bPrivateb10.32.32.0/204 096NAT in same AZ
app-cPrivatec10.32.48.0/204 096NAT in same AZ
data-aIsolated (databases)a10.32.64.0/24256None
data-bIsolatedb10.32.65.0/24256None
data-cIsolatedc10.32.66.0/24256None

Application subnets are sized for pod networking. With pp pods per node and nn nodes per zone at peak, each zone needs at least:

Naddr≥1.5×n×(p+1)N_{addr} \ge 1.5 \times n \times (p + 1)

For n=20n = 20 and p=58p = 58, Naddr≥1 770N_{addr} \ge 1\,770, so a /20 (4 096 addresses) leaves room for growth.

3.3 Topology and traffic flow

The diagram shows the production topology in one region.

3.4 Connectivity and controls

ControlDesign
IngressOnly through WAF and load balancer on 443
East-westSecurity groups by tier; Kubernetes network policies default deny
EgressNAT per AZ; DNS firewall allow-list for external domains
Private access to provider servicesPrivate endpoints for storage, secrets, registry, logs
HybridSite-to-site VPN [and dedicated link] via transit gateway
DNSPrivate hosted zone portal.internal; public zone portal.example.com

4. Compute

WorkloadPlatformInstance / sizeMin / maxImage / AMI sourcePatching
Web and API servicesManaged Kubernetes [version]Example: 4 vCPU / 16 GB, ARM6 / 60 nodesProvider-optimised node imageNode image rolled monthly
Background jobsSame cluster, separate node pool8 vCPU / 32 GB, spot0 / 20SameSame
Scheduled reportsServerless functions1 GB memoryn/aManaged runtimeProvider
[Workload][Platform][Size][Min / max][Image][Process]

5. Storage and data services

StoreServiceSize / classHAEncryptionLifecycle
Application databaseManaged PostgreSQL [version]Example: 8 vCPU / 32 GB, 500 GB gp3Multi-AZ standbyCustomer-managed keyPITR 14 days
CacheManaged Redis2 nodes, 13 GBReplica in second AZIn transit and at restn/a
User uploadsObject storage bucketStandard, then infrequent access after 30 daysRegionalCustomer-managed keyDelete after 2 years
Logs archiveObject storage, security-logs accountArchive class after 90 daysRegional, replicatedCustomer-managed key, object lockRetain 1 year
[Store][Service][Size][HA][Encryption][Lifecycle]

6. Managed and shared services

ServicePurposeOwned byShared with
Container registryImages, signedPlatform teamAll workloads
Secrets managerApplication secretsThis workloadnone
Key management serviceEncryption keysSecurity teamAll workloads
DNSPublic and private zonesPlatform teamAll workloads
Certificate managerTLS certificatesThis workloadnone
Email sending serviceTransactional emailThis workloadnone
[Service][Purpose][Owner][Sharing]

7. IaC repository structure and module conventions

7.1 Repository layout

Reusable modules are separated from the root modules that instantiate them per environment and layer:

infra-portal/
  modules/
    network/          # VPC, subnets, routes, endpoints
    eks-cluster/      # cluster, node pools, add-ons
    postgres/         # database, parameter group, alarms
    bucket/           # object storage with policy and lifecycle
  live/
    dev/
      network/        # root module: calls modules/network
      cluster/
      data/
    stg/
    prod/
    prod-dr/
  policies/           # policy-as-code rules (section 16)
  .ci/                # pipeline definitions

7.2 Conventions

TopicConvention
Tool and versionExample: OpenTofu [1.x], pinned in .tool-versions; provider versions pinned with lock file committed
Module sourcesInternal modules by Git tag (?ref=v1.4.2); public modules only from an approved list, pinned to exact versions
Root modulesOne per environment and layer (network, cluster, data); small blast radius
VariablesTyped, with descriptions and validation blocks; no defaults for environment-specific values
OutputsOnly what other layers need; read through remote state or parameter store
Naming<app>-<env>-<component>[-<az>], for example portal-prod-db
Formatting and lintingfmt, validate and a linter run in CI and pre-commit
DocumentationEach module has a README generated from variables and outputs
Module versioningSemantic versioning; breaking changes in a major version with upgrade notes

8. State management

TopicDesign
BackendExample: Object storage bucket per environment in a dedicated state account
LockingNative lock file or lock table
EncryptionBucket encryption with customer-managed key; TLS only
AccessPipeline role read and write; engineers read-only for plan in non-production only
VersioningObject versioning on; 90 days of history
Key layout<env>/<layer>/terraform.tfstate
Drift detectionScheduled plan every [6 hours]; drift raises a ticket
RecoveryRestore previous object version; documented in runbook

9. CI/CD for infrastructure

The pipeline below runs for every pull request and every merge to the main branch.

StageToolingGate
Static checks[fmt, validate, linter]Must pass
Security and policy[IaC scanner], policy engine (section 16)High findings block
PlanPipeline with read-only rolePlan attached to pull request
Cost diff[Cost estimation tool]Increases above [EUR 500 per month] need budget owner approval
Apply non-productionPipeline role per environmentAutomatic after merge
Apply productionPipeline role, OIDC federationApproval by platform lead; change window rules in section 17

10. Identity and access management

PrincipalAccessEnvironmentsMechanism
CI pipeline (plan)Read-onlyAllOIDC federation, short-lived role
CI pipeline (apply)Admin on workload resources, no IAM on organisationPer environmentOIDC, separate role per environment
Platform engineersRead-only console; write via pipelineAllSSO groups
Platform engineers (break-glass)Admin, time-limitedProductionJust-in-time elevation, approval and alert
Application workloadsLeast privilege per serviceAllWorkload identity (service account to cloud role)
[Principal][Access][Environments][Mechanism]

11. Secrets management

TopicDesign
StoreSecrets manager in each environment account
CreationIaC creates the secret container; values set by rotation function or by an operator, never in code
Delivery to workloadsCSI driver or external secrets operator; mounted as files
RotationDatabase credentials every [30 days] automatically; third-party keys every [90 days]
State hygieneUse data sources and generated passwords marked sensitive; state encrypted (section 8)
DetectionSecret scanning on the IaC repository in CI

12. Tagging and cost allocation

Tag keyRequiredAllowed valuesExampleUsed for
appYesRegistered application IDsportalCost allocation
envYesdev, stg, prod, prod-drprodCost, policy scope
ownerYesTeam handleteam-portalContact
cost-centreYesFinance codesCC-4120Chargeback
data-classYes for data storespublic, internal, confidential, personalpersonalSecurity policy
managed-byYesiac, manualiacDrift and exception reports
scheduleNooffice-hours, always-onoffice-hoursAutomated shutdown

Default tags are applied at provider level in every root module. Policy rejects resources missing required tags; shared costs (NAT, transit, logging) are allocated by [traffic share / fixed split] each month.

13. Scaling

TierMechanismSignalLimitsQuota to watch
PodsHorizontal autoscalerCPU 60%, requests per pod3 to 120 per servicen/a
NodesCluster autoscaler / node provisionerPending pods6 to 60 nodesvCPU quota per region
DatabaseVertical, planned; read replicasCPU above 70% for a weekLargest class [x]Storage max
CacheAdd shardMemory above 75%[n] shardsn/a
[Tier][Mechanism][Signal][Limits][Quota]

14. Backup and disaster recovery

ComponentBackup methodFrequencyRetentionCopy to DR regionRPORTO
PostgreSQLAutomated snapshots and PITRContinuous14 days PITR, 12 monthlyYes, every 15 min15 min2 hours
Object storageVersioning and cross-region replicationContinuous30 days of versionsYesMinutes1 hour
Kubernetes workloadsRebuilt from IaC and GitOps manifestsn/an/aImages replicated03 hours
IaC stateObject versioningEvery change90 daysYes030 min
[Component][Method][Frequency][Retention][Y / N][RPO][RTO]

DR strategy: [Example: "Pilot light. Network, cluster control plane and database replica exist in the DR region; node pools scale from zero during failover."] Last DR drill: YYYY-MM-DD, measured RTO [n] hours.

15. Observability

SignalSourceDestinationRetentionAlert example
MetricsCloud metrics, node exporter, cluster metrics[Monitoring system]13 monthsNode CPU above 85% for 15 min
LogsControl plane, load balancer, VPC flow logs, applicationCentral log store30 days hot, 1 year archiveSpike in 5xx at load balancer
AuditCloud audit trail, Kubernetes auditsecurity-logs account1 year, immutableIAM change outside pipeline
CostBilling exportCost dashboard24 monthsDaily spend above forecast by 20%
SyntheticExternal probes[Monitoring system]13 monthsLogin page down from 2 locations

16. Security baselines and policy as code

IDBaseline controlEnforced byStage
PC-01No public object storage bucketsPolicy engine rule; account-level public access blockPlan and runtime
PC-02All storage and databases encrypted with customer-managed keysPolicy rulePlan
PC-03No security group allows 0.0.0.0/0 except on load balancers port 443Policy rulePlan
PC-04Required tags present (section 12)Policy rulePlan
PC-05Only approved regionsOrganisation-level guardrailRuntime
PC-06Audit logging cannot be disabledOrganisation-level guardrailRuntime
PC-07Container images signed and scannedAdmission controllerDeploy
PC-08Benchmark compliance (for example CIS) monitoredCloud security posture toolRuntime
[PC-nn][Control][Mechanism][Stage]

Policy rules live in policies/, are versioned with the IaC and have unit tests. Exceptions require an entry in 19.2 with an expiry date.

17. Change management

Change typeExamplesApprovalWindowRollback
StandardScaling limits, tags, new alarmsPull request reviewAny timeRevert commit and apply
NormalNew data store, network rule changePull request plus platform leadBusiness hours, not Friday afternoonDocumented in pull request
High riskDatabase major version, CIDR change, cluster upgradeChange advisory reviewAgreed window with on-call presentTested rollback plan
EmergencyFix for active incidentIncident commanderAny timeRetrospective review within 2 days

Freeze periods: [peak trading weeks, financial year end].

18. Cost estimate

Prices as of YYYY-MM-DD, [region], on-demand unless stated.

ItemUnitUnit price (EUR)QuantityMonthly cost (EUR)
Kubernetes control planecluster-month[70]1[70]
Worker nodes (4 vCPU / 16 GB, ARM)node-hour[0.15]12 nodes x 730 h[1 314]
Managed PostgreSQL, multi-AZinstance-month[1 100]1[1 100]
Database storageGB-month[0.25]500[125]
Managed Redisnode-month[180]2[360]
NAT gatewaysgateway-hour plus data[0.05 + 0.05/GB]3 x 730 h, 2 TB[210]
Load balancerhour plus capacity units[0.03]730 h[40]
Object storageGB-month[0.023]3 000[69]
Logs and metricsGB ingested[0.60]800[480]
DR region pilot lightvarious[600]
Non-production environmentsvarious[1 400]
Total before discounts[5 768]
Commitment discount on baseline compute and database[30%][-725]
Estimated total[5 043]

Monthly cost for a node pool is C=N×h×pC = N \times h \times p, where NN is nodes, hh hours per month (730) and pp the hourly price.

19. Appendices

19.1 Glossary

TermMeaning
IaCInfrastructure as Code: infrastructure defined in versioned files and applied by tools
Root moduleDirectory where plan and apply run, combining modules for one environment and layer
StateRecord the IaC tool keeps of the resources it manages
DriftDifference between the real infrastructure and the code
Pilot lightDR approach with minimal standby resources scaled up during failover
[Term][Meaning]

19.2 Exceptions and manual resources

IDResource or ruleReasonCompensating controlOwnerExpires
EXC-01Example: DNS zone created manuallyCreated before IaC adoptionImport planned in sprint [n][@name]YYYY-MM-DD
[EXC-nn][Item][Reason][Control][@name]YYYY-MM-DD

19.3 References

ReferenceUse
[Cloud provider documentation]Service limits and configuration
[IaC tool documentation]State, modules and providers
[Organisation cloud landing zone standard]Account structure and guardrails
[Security architecture document]Controls referenced in section 16

Standard and licence note

Based on common industry practice for cloud infrastructure design and Infrastructure as Code. Original text written for this collection; prices, sizes and ranges are illustrative and must be checked against your provider's current offering. Template licence: MIT.

संबंधित टेम्पलेट