Infrastructure-as-code-as-Software

We ran a poll on Twitter

And on Reddit

Reasons

Ambition

Enough talk!

$ curl http://$api_gw_url/test/breakfast | jq{"breakfast": {"time": "9 AM", "menu": ["poha", "chai"]}}

Setup

0/8 🛹 Make it work

  ├── README.md
├── lambda.py
├── lambda.zip
└── main.tf

1/8 📒Readability

    ├── README.md
├── apigw.tf
├── init.tf
├── lambda.py
├── lambda.tf
├── lambda.zip
├── outputs.tf
└── variables.tf

2/8 🍴Separation of Concern

3/8 🔗Loose Coupling

  ├── README.md
├── apigw.tf
├── init.tf
├── lambda.tf
├── outputs.tf
└── variables.tf
  ├── README.md
├── create-bucket.sh
├── delete-bucket.sh
├── lambda.py
├── lambda.zip
├── package.sh
├── upload.sh
s3_bucket     = "test-tf-lambda-s3"
s3_key = "lambda.zip"

4/8 🤼 Conway’s law and Service Oriented Design

But before we move ahead, In a service-oriented design, it’s incredibly crucial to establish:1. The exchange contracts
2. The mode of communication.

5/8 📡Inter Layer Communication

  ├── 01-base
├── 02-app
└── 03-infra

⚽ Reading State the hard way.

terraform init -backend=true \\
-backend-config="bucket=test-tf-state-bucket-1" \\
-backend-config="key=app.tfstate" \\
-backend config="dynamodb_table=test-tf-state-lock-table-1"
data "aws_lambda_function" "test" {
function_name = var.lambda_name
}
function_name = data.aws_lambda_function.test.function_name
uri = data.aws_lambda_function.test.invoke_arn
uri = data.aws_lambda_function.test.invoke_arnfunction_name = data.aws_lambda_function.test.function_name
lambda_name = data.terraform_remote_state.app.outputs.lambda_function_namelambda_invoke_arn = data.terraform_remote_state.app.outputs.lambda_function_invoke_arn

6/8 ♻️Reusability and Abstraction

lambda_timeout = 60
lambda_memory_size = 128
lambda_timeout = 30
lambda_memory_size = 256

7/8 📄Static Code Checking

8/8 🔒 Dependency Locking

terraform {
required_version = ">= 0.12, < 0.13, < 1.0"
}
terraform {
required_version = "0.12.3"
required_providers {
aws = "2.62.0"
}
}

🏁 Conclusion and Secrets

CTO/Founder @last9inc | Startup magnate (2x fail, 1x exit) | English Breakfast Tea, Hot

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store