SlideShare une entreprise Scribd logo
1  sur  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.

Contenu connexe

Tendances

Tendances (20)

(ARC307) Infrastructure as Code
(ARC307) Infrastructure as Code(ARC307) Infrastructure as Code
(ARC307) Infrastructure as Code
 
AWS Black Belt Online Seminar - Amazon Lightsail
AWS Black Belt Online Seminar - Amazon Lightsail AWS Black Belt Online Seminar - Amazon Lightsail
AWS Black Belt Online Seminar - Amazon Lightsail
 
AWSからのメール送信
AWSからのメール送信AWSからのメール送信
AWSからのメール送信
 
Automating AWS security and compliance
Automating AWS security and compliance Automating AWS security and compliance
Automating AWS security and compliance
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
 
Amazon SageMaker 모델 빌딩 파이프라인 소개::이유동, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스...
Amazon SageMaker 모델 빌딩 파이프라인 소개::이유동, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스...Amazon SageMaker 모델 빌딩 파이프라인 소개::이유동, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스...
Amazon SageMaker 모델 빌딩 파이프라인 소개::이유동, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스...
 
[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...
[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...
[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...
 
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for Kubernetes
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep dive
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
CI/CD on AWS
CI/CD on AWSCI/CD on AWS
CI/CD on AWS
 
AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018
AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018
AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018
 
Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David Gouldin
 
AWS Black Belt Techシリーズ AWS Directory Service
AWS Black Belt Techシリーズ AWS Directory ServiceAWS Black Belt Techシリーズ AWS Directory Service
AWS Black Belt Techシリーズ AWS Directory Service
 
Amazon VPC VPN接続設定 参考資料
Amazon VPC VPN接続設定 参考資料Amazon VPC VPN接続設定 参考資料
Amazon VPC VPN接続設定 参考資料
 
【de:code 2020】 Azure Red hat OpenShift (ARO) によるシステムアーキテクチャ構築の実践
【de:code 2020】 Azure Red hat OpenShift (ARO) によるシステムアーキテクチャ構築の実践【de:code 2020】 Azure Red hat OpenShift (ARO) によるシステムアーキテクチャ構築の実践
【de:code 2020】 Azure Red hat OpenShift (ARO) によるシステムアーキテクチャ構築の実践
 
Terraform
TerraformTerraform
Terraform
 
CAF presentation 09 16-2020
CAF presentation 09 16-2020CAF presentation 09 16-2020
CAF presentation 09 16-2020
 
Deploy 22 microservices from scratch in 30 mins with GitOps
Deploy 22 microservices from scratch in 30 mins with GitOpsDeploy 22 microservices from scratch in 30 mins with GitOps
Deploy 22 microservices from scratch in 30 mins with GitOps
 

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

Similaire à 深探-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 continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
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...
 
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)
 

Plus de Amazon 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 AWS
Amazon 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 Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon 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
 

Plus 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.