16
Terraform - Startup factory for your ideas David Mončka @ Tieto

David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Terraform - Startup factory for your ideasDavid Mončka @ Tieto

Page 2: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

$ whoami

• Software architect in Tieto DevOps Space

• Java developer – microservice 14 years• 2 years – ITIL• 12 years – telco

•DevOps – 7 years

•AWS – 3 years

Page 3: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Objective

Serverless startup example with everything in code (infra, app) to integrate app with external public API.

Few steps how to provision your fresh new AWS account using terraform.

Page 4: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Terminology #1

• Terraform - Infra as a code tool

• Serverless• Martin Fowler - Serverless architectures are application

designs that incorporate third-party “Backend as a Service” (BaaS) services.

• AWS - Serverless is the native architecture of the cloud that enables you to shift more of your operational responsibilities to AWS, increasing your agility and innovation. Serverless allows you to build and run applications and services without thinking about servers.

• Colleague's definition – Serverless architecture is finally something we don’t need to pay for :)

Page 5: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Terminology #2

•AWS account – Free tier services/resources• https://aws.amazon.com/free/• Lambda - 1M

•AWS IAM – terraform system user

•External API

Page 6: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Terraform.io

•Terraform CLI v0.12.9

•Provider AWS - credentials

•CLI Commands• init (working directory of .terraform config files)• plan (show changes of resources)• apply• (destroy)

Page 7: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

provider.aws

resource "aws_lambda_function" "my_lambda" { function_name = "${var.lambda_name}"

… other arguments...}

output "lambda_function_version" { value = "${aws_lambda_function.my_lambda.version}"}

variable "lambda_name" { default = "my-precious-lambda"}

Terraform - building blocks #1

Page 8: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

provider.aws

resource "aws_lambda_function" "my_lambda" { function_name = "${var.lambda_name}"

… other arguments...}

output "lambda_function_version" { value = "${aws_lambda_function.my_lambda.version}"}

variable "lambda_name" { default = "my-precious-lambda"}

Terraform - building blocks #2

Page 9: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

provider.aws

resource "aws_lambda_function" "my_lambda" { function_name = "${var.lambda_name}"

… other arguments...}

output "lambda_function_version" { value = "${aws_lambda_function.my_lambda.version}"}

variable "lambda_name" { default = "my-precious-lambda"}

Terraform - building blocks #3

Page 10: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

data "aws_iam_policy_document" "policy" { statement { … }}

resource "aws_iam_role_policy" "policy" { policy = "${data.aws_iam_policy_document.policy.json}"}

Terraform - building blocks #4

Page 11: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

module.dev.aws_lambda_function.lambda2module.dev.aws_lambda_function.lambda1

Terraform - building blocks #5

module.dev

Page 12: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Coding #1

•AWS IAM

•provider.tf - credentials

• variables.tf

•main.tf - dev module

Page 13: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Coding #2

•external API – https://zonky.docs.apiary.io/

• zonky-call.js

• zonky-lambda.tf

Page 14: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Future #1•Notification about interesting loans

Page 15: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

Future #2•Autoinvestment – can you invest 5760 times?

Page 16: David Mončka @ TietoObjective Serverless startup example with everything in code (infra, app) to integrate app with external public API. Few steps how to provision your freshTerminology

References

•https://console.aws.amazon.com/

•https://www.terraform.io/

•https://zonky.docs.apiary.io/

•https://github.com/monckdav/terraform-startup-factory