A Novel Building Infrastructure As Code
Kimi
2017/10/06
Outline
• Configuration Management
• Infrastructure As Code
• Terraform
• Serverless framework
• Hands On
• Conclusion
• Q&A
Configuration Management
Tools
• Ansible
• Chef
• Puppet
• AWS OpsWork
Tools overview
Ansible Chef Puppet AWS OpsWork
Engine Python Ruby Ruby Python
Agent X V V X
Difficulty Easy Medium Hard Easy
Age 3 2 1 4
* Large number means younger.
How it works?
Ansible Playbook
Short Demo
Infrastructure As Code
• Automate
• Less manual work and human mistake
• Re-useable
• DevOps CI/CD
• Effectively
Cross Region Building Infa.
Infrastructure As Code
Legacy
• Web GUI
• CLI command
Tools
• AWS CloudFormation
• GCP Deployment Manager
• Azure Resource Manager
• Terraform
• Serverless farmwork
How it works?
AWS CloudFormation
Short Demo
Terraform
Terraform Benefit
• Compatibility with all of the most popular cloud
platform
• Fixable
• Modulize
• Easily readable
Terraform Keyword
• Provider
• Variable
• Resource
• Data
• Module
• Output
• Destroy
• Plan
• Apply
• Graph
Terraform Example
variable "access_key" {
  description = "access key for subaccount"
}
variable "secret_key" {
  description = "secret key for subaccount"
}
provider "aws" {
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
  region      = "ap-northeast-1"
}
resource "aws_iam_policy" "test_policy" {
name         = "TibaMe-Tiptop-S3"
description = "TibaMe Tiptop S3 Access Permission"
policy       = "${file("s3_policy.json")}"
}
output “Role-Name” {
value = “${aws_iam_policy.test_policy.name}”
}
Terrafrom Demo
Serverless framework
• Building Serverless related Infrastructure
• Deploy
• Plugin
• AWS Lambda, Azure Functions, Google
CloudFunctions
• YAML-formatted templates
Serverless example
# Tiptop serverless YAML template
service: TibameLambda
provider:
name: aws
runtime: nodejs6.10
stage: Stage
region: ap-northeast-1
versionFunctions: false
functions:
Picture-Resize:
handler: index.handler
memorySize: 512
timeout: 30
description: Tibame Lambda Picture Resize
#Lambda role must created first
role: arn:aws:iam::271681955745:role/LambdaResizeRole
Serverless Demo
Conclusion
• Git control
• Manual work as less as possible
• Templete >>> Document
• Build infrastructure as code
• Control configuration via CM tools
• CI/CD
Q & A
One more thing…
Let’s talk about
DevOps Evolution
Enjoy Vacation

A novel building infrastructure as code