SlideShare una empresa de Scribd logo
1 de 33
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
Deep Dive into IaC on AWS
Pahud Hsieh
Specialist SA, Serverless
Amazon Web Services
smalltown
Senior Site Reliability Engineer
Maicoin
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
Our infrastructure management journey
Manual
� Easy to get started
� Not reproducible
� Error prone
� Time consuming
Scripted
� What happens if an API call fails?
� How do I make updates?
� How do I know a resource is ready?
� How do I roll back?
Resource Provisioning Engines
AWS CloudFormation
template
(JSON/YAML)
HashiCorp
Configuration Language
(HCL)
Desired state configuration
� Easy to automate
� Reproducible
� Configuration syntax
� No abstraction, lots of details
Challenges
• Automated deployment and rollback
• Cross account management
• Cooperative development
• Integration with existing testing frameworks
• Integration with key management system
• Integration with Kubernetes or Amazon EKS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
Introducing smalltown
Hello!
I am smalltown
MaiCoin Site Reliability Engineer
Taipei HashiCorp User Group Organizer
AWS User Group Taiwan Staff
Angeda
IaC Introduction
Multiple Accounts Infrastructure
Testing IaC
EKS Example
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
IaC Introduction
Infrastructure as Code in 201X...
YA! I can write code to
manage cloud resource
resource "aws_s3_bucket" "b" {
bucket = "my_tf_test_bucket"
acl = "private"
tags { Name = "My bucket" }
}
Infrastructure as Code in 201X...
• Record your cloud resource with infrastructure as code
tool, not document
Document:
- Easy Out of Date
- Hard to Maintain
AWS
CloudFormation
Terraform Overview
Allow 1 person manage
the same resource
Store the managed
resource state
Create, Modify,
Destroy Resource
The Benefit After Adopt IaC
• Automate your deployment and recovery process
• Rollback with the same tested processes
• Don’t repair, redeploy
• Focus on mean time to recovery
• Use testing tools to verify your infrastructure
• Hook your tests into your monitoring system
Problems Emerged After a While...
• Permission control problem
• Don’t follow DRY
• How to well testing
• How to collaborate within a team
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
Multiple Accounts Infrastructure
Why Multiple AWS Accounts ?
• Why there are dev, alpha, beta, staging, production
environment for the application?
• Application need to be well tested, but not impact the real
users
• Production infrastructure don’t allow access at will
• Infrastructure becomes code now, hence, it need to be
treated as the same way
Multiple Accounts Infrastructure
Multiple Accounts Infrastructure
• IAM user can be central managed
• Permission separate as read,
write and robot roles in different
accounts
• The robot role is for Terraform
usage
Multiple Accounts Infrastructure
• The write role is for human
usage if necessary
• Production write and robot role
only can be permitted through
change management process
How to Manage Multiple Accounts
• About assume role, don’t
forget to enable MFA, and
setup expired time
• Recommend to use aws-
vault to manage multiple
roles in multiple accounts
[profile central]
output = json
region = us-east-1
mfa_serial =
arn:aws:iam::${CENTRAL_ACCOUNT_ID}:mfa/${IAM_USER}
[profile central_read]
role_arn =
arn:aws:iam::${CENTRAL_ACCOUNT_ID}:role/read
mfa_serial =
arn:aws:iam::${CENTRAL_ACCOUNT_ID}:mfa/${IAM_USER}
source_profile = central
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
Testing IaC
How to Achieve IaC CI/CD
What is Terratest?
• Terratest is a Go library that makes it easier to write
automated tests for your infrastructure code
• It provides a variety of helper functions and patterns for
common infrastructure testing tasks
How to Test IaC By Terratest
Setup
- Compose configuration
- Create resource
- Wait resource ready
Verification
- Leverage helper
function
- Write Golang
directly
Teardown
- Destroy resource
- Generate report
Rich Helper Function
• Testing Terraform code
• Testing Packer templates
• Testing Docker images
• Executing commands on servers over SSH
• Working with Cloud Provider APIs, e.g. AWS
• Working with Kubernetes APIs
• Testing Helm Charts
• Making HTTP requests
• Running shell commands
IaC Testing Tools Comparison
• XXX-Spec ←→ Terratest ←→ Pure programming language
• Learning curve is between XXX-Spec and Pure programming
language
• Not only check server properties, but also the service
functionality
• Testing scope include entire systems
Terraform Module Structure W/ Testing
tf-aws-iam
├── examples
│ ├── iam-roles
│ └── iam-users
├── modules
│ ├── roles
│ └── users
└── test
├── iam_roles_test.go
└── iam_users_test.go
• Modules: The Terraform to
create cloud resource
• Examples: Illustrate how to use
the module
• Test: Test the module by
executing examples
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT
EKS Example - Vishwakarma
Vishwakarma
• Vishwakarma can be used to create a Kubernetes cluster in
AWS by leveraging HashiCorp Terraform and CoreOS
Terratest in Vishwakarma
• Create a EKS cluster with two worker groups (on-demand,
spot)
• Once the cluster is ready (node, core-dns), deploy Nginx
service
• Make a HTTP request to the Nginx service
• Destroy EKS cluster
Demo
Thank you!
SUMMIT © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Más contenido relacionado

La actualidad más candente

Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeMartin Schütte
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform TrainingYevgeniy Brikman
 
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...Amazon Web Services
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformKnoldus Inc.
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & IntroductionLee Trout
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemSreenivas Makam
 
CI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelAmazon Web Services
 
Kubernetes
KubernetesKubernetes
KubernetesHenry He
 
Getting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeGetting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeWinWire Technologies Inc
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) Amazon Web Services Korea
 
Autoscaling Kubernetes
Autoscaling KubernetesAutoscaling Kubernetes
Autoscaling Kubernetescraigbox
 
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...SlideTeam
 

La actualidad más candente (20)

Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
(BAC404) Deploying High Availability and Disaster Recovery Architectures with...
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using Terraform
 
Introduction to Amazon EKS
Introduction to Amazon EKSIntroduction to Amazon EKS
Introduction to Amazon EKS
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystem
 
Terraform
TerraformTerraform
Terraform
 
CI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day Israel
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Getting Started with Infrastructure as Code
Getting Started with Infrastructure as CodeGetting Started with Infrastructure as Code
Getting Started with Infrastructure as Code
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
 
Autoscaling Kubernetes
Autoscaling KubernetesAutoscaling Kubernetes
Autoscaling Kubernetes
 
Terraform Basics
Terraform BasicsTerraform Basics
Terraform Basics
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
What Is Helm
 What Is Helm What Is Helm
What Is Helm
 
Terraform
TerraformTerraform
Terraform
 
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
 

Similar a 深探-IaC-(Infrastructure as Code-基礎設施即程式碼-)-在-AWS-上的應用

Rodney Lester: Well-Architected - Reliability Instructor Led Lab.pdf
Rodney Lester: Well-Architected - Reliability Instructor Led Lab.pdfRodney Lester: Well-Architected - Reliability Instructor Led Lab.pdf
Rodney Lester: Well-Architected - Reliability Instructor Led Lab.pdfAmazon Web Services
 
Application Delivery Patterns for Developers - Technical 401
Application Delivery Patterns for Developers - Technical 401Application Delivery Patterns for Developers - Technical 401
Application Delivery Patterns for Developers - Technical 401Amazon Web Services
 
Groovy & Grails - From Scratch to Production
Groovy & Grails - From Scratch to Production Groovy & Grails - From Scratch to Production
Groovy & Grails - From Scratch to Production Tal Maayani
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOpsEklove Mohan
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud ComputingITviec
 
Configuration Management in the Cloud | AWS Public Sector Summit 2017
Configuration Management in the Cloud | AWS Public Sector Summit 2017Configuration Management in the Cloud | AWS Public Sector Summit 2017
Configuration Management in the Cloud | AWS Public Sector Summit 2017Amazon Web Services
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples Yochay Kiriaty
 
PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...
PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...
PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...Puppet
 
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...MongoDB
 
NetflixOSS for Triangle Devops Oct 2013
NetflixOSS for Triangle Devops Oct 2013NetflixOSS for Triangle Devops Oct 2013
NetflixOSS for Triangle Devops Oct 2013aspyker
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...Amazon Web Services
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Emerson Eduardo Rodrigues Von Staffen
 
Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...
Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...
Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...Amazon Web Services
 
Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)
Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)
Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)VMware Tanzu
 

Similar a 深探-IaC-(Infrastructure as Code-基礎設施即程式碼-)-在-AWS-上的應用 (20)

Managing Your Cloud Assets
Managing Your Cloud AssetsManaging Your Cloud Assets
Managing Your Cloud Assets
 
Rodney Lester: Well-Architected - Reliability Instructor Led Lab.pdf
Rodney Lester: Well-Architected - Reliability Instructor Led Lab.pdfRodney Lester: Well-Architected - Reliability Instructor Led Lab.pdf
Rodney Lester: Well-Architected - Reliability Instructor Led Lab.pdf
 
Meetup callback
Meetup callbackMeetup callback
Meetup callback
 
What is Serverless Computing?
What is Serverless Computing?What is Serverless Computing?
What is Serverless Computing?
 
Application Delivery Patterns for Developers - Technical 401
Application Delivery Patterns for Developers - Technical 401Application Delivery Patterns for Developers - Technical 401
Application Delivery Patterns for Developers - Technical 401
 
Groovy & Grails - From Scratch to Production
Groovy & Grails - From Scratch to Production Groovy & Grails - From Scratch to Production
Groovy & Grails - From Scratch to Production
 
Application Delivery Patterns
Application Delivery PatternsApplication Delivery Patterns
Application Delivery Patterns
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud Computing
 
Configuration Management in the Cloud | AWS Public Sector Summit 2017
Configuration Management in the Cloud | AWS Public Sector Summit 2017Configuration Management in the Cloud | AWS Public Sector Summit 2017
Configuration Management in the Cloud | AWS Public Sector Summit 2017
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...
PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...
PuppetConf 2017: Unlocking Azure with Puppet Enterprise- Keiran Sweet, Source...
 
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
 
NetflixOSS for Triangle Devops Oct 2013
NetflixOSS for Triangle Devops Oct 2013NetflixOSS for Triangle Devops Oct 2013
NetflixOSS for Triangle Devops Oct 2013
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
Azure App Service Deep Dive
Azure App Service Deep DiveAzure App Service Deep Dive
Azure App Service Deep Dive
 
Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...
Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...
Assembling an AWS CloudFormation Authoring Tool Chain (DEV368-R2) - AWS re:In...
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)
Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)
Cloud Foundry Compared With Other PaaSes (Cloud Foundry Summit 2014)
 

Más de Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

Más de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

深探-IaC-(Infrastructure as Code-基礎設施即程式碼-)-在-AWS-上的應用

  • 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT Deep Dive into IaC on AWS Pahud Hsieh Specialist SA, Serverless Amazon Web Services smalltown Senior Site Reliability Engineer Maicoin
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT Our infrastructure management journey
  • 3. Manual � Easy to get started � Not reproducible � Error prone � Time consuming
  • 4. Scripted � What happens if an API call fails? � How do I make updates? � How do I know a resource is ready? � How do I roll back?
  • 5. Resource Provisioning Engines AWS CloudFormation template (JSON/YAML) HashiCorp Configuration Language (HCL) Desired state configuration � Easy to automate � Reproducible � Configuration syntax � No abstraction, lots of details
  • 6. Challenges • Automated deployment and rollback • Cross account management • Cooperative development • Integration with existing testing frameworks • Integration with key management system • Integration with Kubernetes or Amazon EKS
  • 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT Introducing smalltown
  • 8. Hello! I am smalltown MaiCoin Site Reliability Engineer Taipei HashiCorp User Group Organizer AWS User Group Taiwan Staff
  • 9. Angeda IaC Introduction Multiple Accounts Infrastructure Testing IaC EKS Example
  • 10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT IaC Introduction
  • 11. Infrastructure as Code in 201X... YA! I can write code to manage cloud resource resource "aws_s3_bucket" "b" { bucket = "my_tf_test_bucket" acl = "private" tags { Name = "My bucket" } }
  • 12. Infrastructure as Code in 201X... • Record your cloud resource with infrastructure as code tool, not document Document: - Easy Out of Date - Hard to Maintain AWS CloudFormation
  • 13. Terraform Overview Allow 1 person manage the same resource Store the managed resource state Create, Modify, Destroy Resource
  • 14. The Benefit After Adopt IaC • Automate your deployment and recovery process • Rollback with the same tested processes • Don’t repair, redeploy • Focus on mean time to recovery • Use testing tools to verify your infrastructure • Hook your tests into your monitoring system
  • 15. Problems Emerged After a While... • Permission control problem • Don’t follow DRY • How to well testing • How to collaborate within a team
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT Multiple Accounts Infrastructure
  • 17. Why Multiple AWS Accounts ? • Why there are dev, alpha, beta, staging, production environment for the application? • Application need to be well tested, but not impact the real users • Production infrastructure don’t allow access at will • Infrastructure becomes code now, hence, it need to be treated as the same way
  • 19. Multiple Accounts Infrastructure • IAM user can be central managed • Permission separate as read, write and robot roles in different accounts • The robot role is for Terraform usage
  • 20. Multiple Accounts Infrastructure • The write role is for human usage if necessary • Production write and robot role only can be permitted through change management process
  • 21. How to Manage Multiple Accounts • About assume role, don’t forget to enable MFA, and setup expired time • Recommend to use aws- vault to manage multiple roles in multiple accounts [profile central] output = json region = us-east-1 mfa_serial = arn:aws:iam::${CENTRAL_ACCOUNT_ID}:mfa/${IAM_USER} [profile central_read] role_arn = arn:aws:iam::${CENTRAL_ACCOUNT_ID}:role/read mfa_serial = arn:aws:iam::${CENTRAL_ACCOUNT_ID}:mfa/${IAM_USER} source_profile = central
  • 22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT Testing IaC
  • 23. How to Achieve IaC CI/CD
  • 24. What is Terratest? • Terratest is a Go library that makes it easier to write automated tests for your infrastructure code • It provides a variety of helper functions and patterns for common infrastructure testing tasks
  • 25. How to Test IaC By Terratest Setup - Compose configuration - Create resource - Wait resource ready Verification - Leverage helper function - Write Golang directly Teardown - Destroy resource - Generate report
  • 26. Rich Helper Function • Testing Terraform code • Testing Packer templates • Testing Docker images • Executing commands on servers over SSH • Working with Cloud Provider APIs, e.g. AWS • Working with Kubernetes APIs • Testing Helm Charts • Making HTTP requests • Running shell commands
  • 27. IaC Testing Tools Comparison • XXX-Spec ←→ Terratest ←→ Pure programming language • Learning curve is between XXX-Spec and Pure programming language • Not only check server properties, but also the service functionality • Testing scope include entire systems
  • 28. Terraform Module Structure W/ Testing tf-aws-iam ├── examples │ ├── iam-roles │ └── iam-users ├── modules │ ├── roles │ └── users └── test ├── iam_roles_test.go └── iam_users_test.go • Modules: The Terraform to create cloud resource • Examples: Illustrate how to use the module • Test: Test the module by executing examples
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.SUMMIT EKS Example - Vishwakarma
  • 30. Vishwakarma • Vishwakarma can be used to create a Kubernetes cluster in AWS by leveraging HashiCorp Terraform and CoreOS
  • 31. Terratest in Vishwakarma • Create a EKS cluster with two worker groups (on-demand, spot) • Once the cluster is ready (node, core-dns), deploy Nginx service • Make a HTTP request to the Nginx service • Destroy EKS cluster
  • 32. Demo
  • 33. Thank you! SUMMIT © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.