SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Cobus Bernard
Sr Developer Advocate
Amazon Web Services
GettingStartedAWS:
Infrastructure asCode
@cobusbernard
cobusbernard
cobusbernard
CobusCloud
© 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Agenda
What is Infrastructure as Code
AWS CloudFormation
AWS Serverless Application Model (SAM)
AWS CDK
HashiCorp Terraform
Q & A
© 2020, Amazon Web Services, Inc. or its Affiliates.
Agenda for today
• What is Infrastructure as Code
• AWS CloudFormation
• AWS Serverless Application Model (SAM)
• AWS Cloud Development Kit (CDK)
• OtherTools out there
• Some Best Practices
• Wrap up
© 2020, Amazon Web Services, Inc. or its Affiliates.
What is Infrastructure as Code?
© 2020, Amazon Web Services, Inc. or its Affiliates.
© 2020, Amazon Web Services, Inc. or its Affiliates.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Infrastructure as code
✓
Make infrastructure
changes repeatable and
predictable
✓
Release infrastructure
changes using the same
tools as code changes
✓
Replicate production in a
staging environment to
enable continuous testing
© 2020, Amazon Web Services, Inc. or its Affiliates.
Infrastructure as code
Declarative
I tell you
what I need
I tell you
what to do
Imperative
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CloudFormation
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CloudFormation
• Infrastructure as code (IaC)
• Provides a common language for you to
describe and provision all the infrastructure
resources in your cloud environment
• Build and rebuild your infrastructure and
applications, without having to perform manual
actions or write custom scripts
https://aws.amazon.com/cloudformation/
© 2020, Amazon Web Services, Inc. or its Affiliates.
SampleAWSCloudFormationcode
• Code is written in files
called templates
• A stack is generated from
a template
• Templates primarily define
resources for an application
• AWS CloudFormation can create
over 490 types of resources
• Each resource is configured
based on its available properties
• Dependencies can be explicitly
declared or implicitly discovered
AWSTemplateFormatVersion: "2010-09-09"
Description: A CodeCommit Repo and Cloud9 Environment
Resources:
MyRepo:
Type: "AWS::CodeCommit::Repository"
Properties:
RepositoryName: MyRepo
RepositoryDescription: Sample Repository for Demo
MyC9Environment:
Type: "AWS::Cloud9::EnvironmentEC2"
Properties:
Repositories:
- PathComponent: /cfn
RepositoryUrl: !GetAtt MyRepo.CloneUrlHttp
InstanceType: t2.micro
© 2020, Amazon Web Services, Inc. or its Affiliates.
AnatomyofanAWSCloudFormationtemplate
• Resources
• Parameters and Mappings
• Conditions
• Outputs
© 2020, Amazon Web Services, Inc. or its Affiliates.
Testingviapipelines
• As you would with other application code, templates should be version
controlled and tested via CI/CD pipelines
• The linter can be run in an AWS CodeBuild step to ensure that teams comply
with rules and standards
• Additional tools, like taskcat (available on GitHub), allow tests across regions
Git push
Templates
AWS
CodeCommit
AWS
CodePipeline
AWS
CodeBuild
AWS
CloudFormation
Region
AWS
CodeDeploy
© 2020, Amazon Web Services, Inc. or its Affiliates.
What about other infrastructure?
© 2020, Amazon Web Services, Inc. or its Affiliates.
CloudFormation
registry
Open
CLI
Open
providers
AWS CloudFormation registry
An open approach to managing external resources
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWSCloudFormationregistryandCLI
• Allows AWS CloudFormation to
support native and
non-AWS resources while inheriting
many core benefits like rollbacks
• Use the AWS CloudFormation CLI
tool to create resource providers
using JSON schema-driven
development, generating many of the
code assets for you
• Use third-party resource providers as
you would use native AWS resource
types
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Serverless Application Model
(SAM)
© 2020, Amazon Web Services, Inc. or its Affiliates.
Model function environments with AWS Serverless
Application Model (SAM)
• Open source framework for building serverless
applications on AWS
• Shorthand syntax to express functions, APIs,
databases, and event source mappings
• Transforms and expands SAM syntax into AWS
CloudFormation syntax on deployment
• Supports all AWS CloudFormation resource types
https://aws.amazon.com/serverless/sam/
© 2020, Amazon Web Services, Inc. or its Affiliates.
SAM template
AWSTemplateFormatVersion: '2010-09-09’
Transform: AWS::Serverless-2016-10-31
Resources:
MySimpleTableFunction:
Type: AWS::Serverless::Function
Properties:
Handler: mySimpleTableFunction.handler
Runtime: nodejs12.x
CodeUri: ./functions
Policies:
- DynamoDBReadPolicy:
TableName: !Ref MySimpleTable
Events:
MySimpleFunctionApi:
Type: Api
Properties:
Path: /simpleTable
Method: GET
MySimpleTable:
Type: AWS::Serverless::SimpleTable
Just 20 lines to create:
• Lambda function
• IAM role
• API Gateway
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS SAM CLI
• Create, build, test, and deploy
AWS SAM applications
• Step-through debugging and IDE
support
• Open source!
• https://github.com/awslabs/aws-
sam-cli
© 2020, Amazon Web Services, Inc. or its Affiliates.
Use SAM CLI to package and deploy SAM templates
pip install --user aws-sam-cli # Or even better use native installers
sam init --name my-app --runtime python
cd my-app/
sam local ... # generate-event/invoke/start-api/start-lambda
sam validate # The SAM template
sam build # Depending on the runtime
sam package --s3-bucket my-packages-bucket 
--output-template-file packaged.yaml
sam deploy --template-file packaged.yaml 
--stack-name my-stack-prod
sam logs -n MyFunction --stack-name my-stack-prod -t # Tail
sam publish # To the Serverless Application Repository
CodePipeline
Use CloudFormation
deployment actions
with any SAM
application
Jenkins
Use SAM CLI plugin
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Cloud Development Kit (CDK)
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWSCloudDevelopmentKit(AWSCDK)
A multi-language development framework for modeling infrastructure as reusable components
© 2020, Amazon Web Services, Inc. or its Affiliates.
Fromconstructstothecloud
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CDK Constructs
© 2020, Amazon Web Services, Inc. or its Affiliates.
HashiCorpTerraform
© 2020, Amazon Web Services, Inc. or its Affiliates.
HashiCorp Configuration Language (HCL)
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
tags = {
Name = "🚀 Terraforming AWS 🚀"
}
}
© 2020, Amazon Web Services, Inc. or its Affiliates.
Terraform Statefile
{
"version": 3,
"serial": 1,
"lineage": "f0548872-7819-974d-5df7-34653dacd3a1",
"backend": {
"type": "s3",
"config": {
"access_key": null,
"acl": null,
"assume_role_policy": null,
© 2020, Amazon Web Services, Inc. or its Affiliates.
Terraform Modules
# Using the module from https://github.com/terraform-
aws-modules/terraform-aws-vpc
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "AWS SSA Webinar"
cidr = var.vpc_cidr
azs = var.azs
private_subnets = var.private_subnets
public_subnets = var.public_subnets
}
© 2020, Amazon Web Services, Inc. or its Affiliates.
Takeaways!
• Start with something small, but try to start as early as possible
• Treat it like your code: PRs, CI/CD,Version controlled
• Try more than one tool to find the one that fits your need / style
• Split your infrastructure into smaller blocks to reduce blast radius
© 2020, Amazon Web Services, Inc. or its Affiliates.
Thank you!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Cobus Bernard
Sr Developer Advocate
Amazon Web Services
@cobusbernard
cobusbernard
cobusbernard
CobusCloud

Weitere ähnliche Inhalte

Was ist angesagt?

SharePoint 2010 Virtualisation - SharePoint Saturday UK
SharePoint 2010 Virtualisation - SharePoint Saturday UKSharePoint 2010 Virtualisation - SharePoint Saturday UK
SharePoint 2010 Virtualisation - SharePoint Saturday UK
Michael Noel
 

Was ist angesagt? (20)

20200422 AWS Black Belt Online Seminar Amazon Elastic Container Service (Amaz...
20200422 AWS Black Belt Online Seminar Amazon Elastic Container Service (Amaz...20200422 AWS Black Belt Online Seminar Amazon Elastic Container Service (Amaz...
20200422 AWS Black Belt Online Seminar Amazon Elastic Container Service (Amaz...
 
SharePoint 2010 Virtualisation - SharePoint Saturday UK
SharePoint 2010 Virtualisation - SharePoint Saturday UKSharePoint 2010 Virtualisation - SharePoint Saturday UK
SharePoint 2010 Virtualisation - SharePoint Saturday UK
 
AWSome Day Brasil - Junho 2020
AWSome Day Brasil - Junho 2020AWSome Day Brasil - Junho 2020
AWSome Day Brasil - Junho 2020
 
CON209_Interstella 8888 Learn How to Use Docker on AWS
CON209_Interstella 8888 Learn How to Use Docker on AWSCON209_Interstella 8888 Learn How to Use Docker on AWS
CON209_Interstella 8888 Learn How to Use Docker on AWS
 
AWS Lake Formation Deep Dive
AWS Lake Formation Deep DiveAWS Lake Formation Deep Dive
AWS Lake Formation Deep Dive
 
Stack Mastery: Create and Optimize Advanced AWS CloudFormation Templates - DE...
Stack Mastery: Create and Optimize Advanced AWS CloudFormation Templates - DE...Stack Mastery: Create and Optimize Advanced AWS CloudFormation Templates - DE...
Stack Mastery: Create and Optimize Advanced AWS CloudFormation Templates - DE...
 
RDS and DynamoDB - Module 3 Part 2 - AWSome Day 2017
RDS and DynamoDB - Module 3 Part 2 - AWSome Day 2017RDS and DynamoDB - Module 3 Part 2 - AWSome Day 2017
RDS and DynamoDB - Module 3 Part 2 - AWSome Day 2017
 
Serverless Applications at Global Scale with Multi-Regional Deployments - AWS...
Serverless Applications at Global Scale with Multi-Regional Deployments - AWS...Serverless Applications at Global Scale with Multi-Regional Deployments - AWS...
Serverless Applications at Global Scale with Multi-Regional Deployments - AWS...
 
DEV205_Developing Applications on AWS in the JVM
DEV205_Developing Applications on AWS in the JVMDEV205_Developing Applications on AWS in the JVM
DEV205_Developing Applications on AWS in the JVM
 
AWS SSA Webinar 18 - Getting Started with Multi-Region Architecture: Data
AWS SSA Webinar 18 - Getting Started with Multi-Region Architecture: DataAWS SSA Webinar 18 - Getting Started with Multi-Region Architecture: Data
AWS SSA Webinar 18 - Getting Started with Multi-Region Architecture: Data
 
20191218 AWS Black Belt Online Seminar AWSのマネジメント&ガバナンス サービスアップデート
20191218 AWS Black Belt Online Seminar AWSのマネジメント&ガバナンス サービスアップデート20191218 AWS Black Belt Online Seminar AWSのマネジメント&ガバナンス サービスアップデート
20191218 AWS Black Belt Online Seminar AWSのマネジメント&ガバナンス サービスアップデート
 
Aws
AwsAws
Aws
 
Module 2: AWS Infrastructure – Compute, Storage and Networking - AWSome Day O...
Module 2: AWS Infrastructure – Compute, Storage and Networking - AWSome Day O...Module 2: AWS Infrastructure – Compute, Storage and Networking - AWSome Day O...
Module 2: AWS Infrastructure – Compute, Storage and Networking - AWSome Day O...
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Containers & Microservices
IVS CTO Night And Day 2018 Winter - [re:Cap] Containers & MicroservicesIVS CTO Night And Day 2018 Winter - [re:Cap] Containers & Microservices
IVS CTO Night And Day 2018 Winter - [re:Cap] Containers & Microservices
 
AWSome Day Glasgow | Technical Track
AWSome Day Glasgow | Technical TrackAWSome Day Glasgow | Technical Track
AWSome Day Glasgow | Technical Track
 
AWS SSA Webinar 19 - Getting Started with Multi-Region Architecture: Services
AWS SSA Webinar 19 - Getting Started with Multi-Region Architecture: ServicesAWS SSA Webinar 19 - Getting Started with Multi-Region Architecture: Services
AWS SSA Webinar 19 - Getting Started with Multi-Region Architecture: Services
 
AWSome Day Digital LATAM
AWSome Day Digital LATAMAWSome Day Digital LATAM
AWSome Day Digital LATAM
 
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
 
[AWS Builders] Effective AWS Glue
[AWS Builders] Effective AWS Glue[AWS Builders] Effective AWS Glue
[AWS Builders] Effective AWS Glue
 
AWS SSA Webinar 9 - Getting Started on AWS: Storage
AWS SSA Webinar 9 - Getting Started on AWS: StorageAWS SSA Webinar 9 - Getting Started on AWS: Storage
AWS SSA Webinar 9 - Getting Started on AWS: Storage
 

Ähnlich wie AWS SSA Webinar 28 - Getting Started with AWS - Infrastructure as Code

Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Amazon Web Services
 

Ähnlich wie AWS SSA Webinar 28 - Getting Started with AWS - Infrastructure as Code (20)

saa3_wk5.pdf
saa3_wk5.pdfsaa3_wk5.pdf
saa3_wk5.pdf
 
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...
 
Devops on serverless
Devops on serverlessDevops on serverless
Devops on serverless
 
Integrate Your Favourite Microsoft DevOps Tools with AWS - AWS Summit Sydney
Integrate Your Favourite Microsoft DevOps Tools with AWS - AWS Summit SydneyIntegrate Your Favourite Microsoft DevOps Tools with AWS - AWS Summit Sydney
Integrate Your Favourite Microsoft DevOps Tools with AWS - AWS Summit Sydney
 
20200803 - Serverless with AWS @ HELTECH
20200803 - Serverless with AWS @ HELTECH20200803 - Serverless with AWS @ HELTECH
20200803 - Serverless with AWS @ HELTECH
 
Serverless Functions Deep Dive
Serverless Functions Deep DiveServerless Functions Deep Dive
Serverless Functions Deep Dive
 
Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...
Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...
Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...
 
AWS DevDay Cologne - Automating building blocks choices you will face with co...
AWS DevDay Cologne - Automating building blocks choices you will face with co...AWS DevDay Cologne - Automating building blocks choices you will face with co...
AWS DevDay Cologne - Automating building blocks choices you will face with co...
 
An Intro to Building and Optimizing a Hybrid Cloud on AWS
An Intro to Building and Optimizing a Hybrid Cloud on AWSAn Intro to Building and Optimizing a Hybrid Cloud on AWS
An Intro to Building and Optimizing a Hybrid Cloud on AWS
 
20200826 AWS Black Belt Online Seminar AWS CloudFormation
20200826 AWS Black Belt Online Seminar AWS CloudFormation 20200826 AWS Black Belt Online Seminar AWS CloudFormation
20200826 AWS Black Belt Online Seminar AWS CloudFormation
 
AWS Serverless Development
AWS Serverless DevelopmentAWS Serverless Development
AWS Serverless Development
 
Infrastructure is code with the AWS cloud development kit
Infrastructure is code with the AWS cloud development kitInfrastructure is code with the AWS cloud development kit
Infrastructure is code with the AWS cloud development kit
 
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
Track 4 Session 4_ MAD02 MAD 04 如何藉由 CICD 流程管理容器化和無伺服器應用
 
SRV313 Introduction to Building Web Apps on AWS
 SRV313 Introduction to Building Web Apps on AWS SRV313 Introduction to Building Web Apps on AWS
SRV313 Introduction to Building Web Apps on AWS
 
Control for Your Cloud Environment Using AWS Management Tools (ENT226-R1) - A...
Control for Your Cloud Environment Using AWS Management Tools (ENT226-R1) - A...Control for Your Cloud Environment Using AWS Management Tools (ENT226-R1) - A...
Control for Your Cloud Environment Using AWS Management Tools (ENT226-R1) - A...
 
From Docker Straight to AWS
From Docker Straight to AWSFrom Docker Straight to AWS
From Docker Straight to AWS
 
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
 
Hands-On with Advanced AWS CloudFormation Techniques and New Features (DEV335...
Hands-On with Advanced AWS CloudFormation Techniques and New Features (DEV335...Hands-On with Advanced AWS CloudFormation Techniques and New Features (DEV335...
Hands-On with Advanced AWS CloudFormation Techniques and New Features (DEV335...
 
Amazon ECS Deep Dive
Amazon ECS Deep DiveAmazon ECS Deep Dive
Amazon ECS Deep Dive
 
Amazon Amazon Elastic Container Service (Amazon ECS)
Amazon Amazon Elastic Container Service (Amazon ECS)Amazon Amazon Elastic Container Service (Amazon ECS)
Amazon Amazon Elastic Container Service (Amazon ECS)
 

Mehr von Cobus Bernard

Mehr von Cobus Bernard (20)

London Microservices Meetup: Lessons learnt adopting microservices
London Microservices  Meetup: Lessons learnt adopting microservicesLondon Microservices  Meetup: Lessons learnt adopting microservices
London Microservices Meetup: Lessons learnt adopting microservices
 
AWS SSA Webinar 21 - Getting Started with Data lakes on AWS
AWS SSA Webinar 21 - Getting Started with Data lakes on AWSAWS SSA Webinar 21 - Getting Started with Data lakes on AWS
AWS SSA Webinar 21 - Getting Started with Data lakes on AWS
 
AWS SSA Webinar 20 - Getting Started with Data Warehouses on AWS
AWS SSA Webinar 20 - Getting Started with Data Warehouses on AWSAWS SSA Webinar 20 - Getting Started with Data Warehouses on AWS
AWS SSA Webinar 20 - Getting Started with Data Warehouses on AWS
 
AWS EMEA Online Summit - Live coding with containers
AWS EMEA Online Summit - Live coding with containersAWS EMEA Online Summit - Live coding with containers
AWS EMEA Online Summit - Live coding with containers
 
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
 
AWS SSA Webinar 17 - Getting Started on AWS with Amazon RDS
AWS SSA Webinar 17 - Getting Started on AWS with Amazon RDSAWS SSA Webinar 17 - Getting Started on AWS with Amazon RDS
AWS SSA Webinar 17 - Getting Started on AWS with Amazon RDS
 
AWS SSA Webinar 16 - Getting Started on AWS with Amazon EC2
AWS SSA Webinar 16 - Getting Started on AWS with Amazon EC2AWS SSA Webinar 16 - Getting Started on AWS with Amazon EC2
AWS SSA Webinar 16 - Getting Started on AWS with Amazon EC2
 
AWS SSA Webinar 15 - Getting started on AWS with Containers: Amazon EKS
AWS SSA Webinar 15 - Getting started on AWS with Containers: Amazon EKSAWS SSA Webinar 15 - Getting started on AWS with Containers: Amazon EKS
AWS SSA Webinar 15 - Getting started on AWS with Containers: Amazon EKS
 
AWS SSA Webinar 13 - Getting started on AWS with Containers: Amazon ECS
AWS SSA Webinar 13 - Getting started on AWS with Containers: Amazon ECSAWS SSA Webinar 13 - Getting started on AWS with Containers: Amazon ECS
AWS SSA Webinar 13 - Getting started on AWS with Containers: Amazon ECS
 
AWS SSA Webinar 11 - Getting started on AWS: Security
AWS SSA Webinar 11 - Getting started on AWS: SecurityAWS SSA Webinar 11 - Getting started on AWS: Security
AWS SSA Webinar 11 - Getting started on AWS: Security
 
AWS SSA Webinar 12 - Getting started on AWS with Containers
AWS SSA Webinar 12 - Getting started on AWS with ContainersAWS SSA Webinar 12 - Getting started on AWS with Containers
AWS SSA Webinar 12 - Getting started on AWS with Containers
 
HashiTalks Africa - Going multi-account on AWS with Terraform
HashiTalks Africa - Going multi-account on AWS with TerraformHashiTalks Africa - Going multi-account on AWS with Terraform
HashiTalks Africa - Going multi-account on AWS with Terraform
 
AWS SSA Webinar 10 - Getting Started on AWS: Networking
AWS SSA Webinar 10 - Getting Started on AWS: NetworkingAWS SSA Webinar 10 - Getting Started on AWS: Networking
AWS SSA Webinar 10 - Getting Started on AWS: Networking
 
AWS SSA Webinar 9 - Getting Started on AWS: Storage
AWS SSA Webinar 9 - Getting Started on AWS: StorageAWS SSA Webinar 9 - Getting Started on AWS: Storage
AWS SSA Webinar 9 - Getting Started on AWS: Storage
 
AWS SSA Webinar 8 - Getting Started on AWS: Compute
AWS SSA Webinar 8 - Getting Started on AWS: ComputeAWS SSA Webinar 8 - Getting Started on AWS: Compute
AWS SSA Webinar 8 - Getting Started on AWS: Compute
 
AWS SSA Webinar 7 - Getting Started on AWS
AWS SSA Webinar 7 - Getting Started on AWSAWS SSA Webinar 7 - Getting Started on AWS
AWS SSA Webinar 7 - Getting Started on AWS
 
AWS SSA Webinar - Cost optimisation on AWS
AWS SSA Webinar - Cost optimisation on AWSAWS SSA Webinar - Cost optimisation on AWS
AWS SSA Webinar - Cost optimisation on AWS
 
DevConf 2020: Resiliency and availability design patterns for the cloud
DevConf 2020: Resiliency and availability design patterns for the cloudDevConf 2020: Resiliency and availability design patterns for the cloud
DevConf 2020: Resiliency and availability design patterns for the cloud
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocks
 
Getting started with AWS Machine Learning
Getting started with AWS Machine LearningGetting started with AWS Machine Learning
Getting started with AWS Machine Learning
 

Kürzlich hochgeladen

VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 

Kürzlich hochgeladen (20)

VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 

AWS SSA Webinar 28 - Getting Started with AWS - Infrastructure as Code

  • 1. Cobus Bernard Sr Developer Advocate Amazon Web Services GettingStartedAWS: Infrastructure asCode @cobusbernard cobusbernard cobusbernard CobusCloud
  • 2. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates. Agenda What is Infrastructure as Code AWS CloudFormation AWS Serverless Application Model (SAM) AWS CDK HashiCorp Terraform Q & A
  • 3. © 2020, Amazon Web Services, Inc. or its Affiliates. Agenda for today • What is Infrastructure as Code • AWS CloudFormation • AWS Serverless Application Model (SAM) • AWS Cloud Development Kit (CDK) • OtherTools out there • Some Best Practices • Wrap up
  • 4. © 2020, Amazon Web Services, Inc. or its Affiliates. What is Infrastructure as Code?
  • 5. © 2020, Amazon Web Services, Inc. or its Affiliates.
  • 6. © 2020, Amazon Web Services, Inc. or its Affiliates.
  • 7. © 2020, Amazon Web Services, Inc. or its Affiliates. Infrastructure as code ✓ Make infrastructure changes repeatable and predictable ✓ Release infrastructure changes using the same tools as code changes ✓ Replicate production in a staging environment to enable continuous testing
  • 8. © 2020, Amazon Web Services, Inc. or its Affiliates. Infrastructure as code Declarative I tell you what I need I tell you what to do Imperative
  • 9. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CloudFormation
  • 10. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CloudFormation • Infrastructure as code (IaC) • Provides a common language for you to describe and provision all the infrastructure resources in your cloud environment • Build and rebuild your infrastructure and applications, without having to perform manual actions or write custom scripts https://aws.amazon.com/cloudformation/
  • 11. © 2020, Amazon Web Services, Inc. or its Affiliates. SampleAWSCloudFormationcode • Code is written in files called templates • A stack is generated from a template • Templates primarily define resources for an application • AWS CloudFormation can create over 490 types of resources • Each resource is configured based on its available properties • Dependencies can be explicitly declared or implicitly discovered AWSTemplateFormatVersion: "2010-09-09" Description: A CodeCommit Repo and Cloud9 Environment Resources: MyRepo: Type: "AWS::CodeCommit::Repository" Properties: RepositoryName: MyRepo RepositoryDescription: Sample Repository for Demo MyC9Environment: Type: "AWS::Cloud9::EnvironmentEC2" Properties: Repositories: - PathComponent: /cfn RepositoryUrl: !GetAtt MyRepo.CloneUrlHttp InstanceType: t2.micro
  • 12. © 2020, Amazon Web Services, Inc. or its Affiliates. AnatomyofanAWSCloudFormationtemplate • Resources • Parameters and Mappings • Conditions • Outputs
  • 13. © 2020, Amazon Web Services, Inc. or its Affiliates. Testingviapipelines • As you would with other application code, templates should be version controlled and tested via CI/CD pipelines • The linter can be run in an AWS CodeBuild step to ensure that teams comply with rules and standards • Additional tools, like taskcat (available on GitHub), allow tests across regions Git push Templates AWS CodeCommit AWS CodePipeline AWS CodeBuild AWS CloudFormation Region AWS CodeDeploy
  • 14. © 2020, Amazon Web Services, Inc. or its Affiliates. What about other infrastructure?
  • 15. © 2020, Amazon Web Services, Inc. or its Affiliates. CloudFormation registry Open CLI Open providers AWS CloudFormation registry An open approach to managing external resources
  • 16. © 2020, Amazon Web Services, Inc. or its Affiliates. AWSCloudFormationregistryandCLI • Allows AWS CloudFormation to support native and non-AWS resources while inheriting many core benefits like rollbacks • Use the AWS CloudFormation CLI tool to create resource providers using JSON schema-driven development, generating many of the code assets for you • Use third-party resource providers as you would use native AWS resource types
  • 17. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS Serverless Application Model (SAM)
  • 18. © 2020, Amazon Web Services, Inc. or its Affiliates. Model function environments with AWS Serverless Application Model (SAM) • Open source framework for building serverless applications on AWS • Shorthand syntax to express functions, APIs, databases, and event source mappings • Transforms and expands SAM syntax into AWS CloudFormation syntax on deployment • Supports all AWS CloudFormation resource types https://aws.amazon.com/serverless/sam/
  • 19. © 2020, Amazon Web Services, Inc. or its Affiliates. SAM template AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: MySimpleTableFunction: Type: AWS::Serverless::Function Properties: Handler: mySimpleTableFunction.handler Runtime: nodejs12.x CodeUri: ./functions Policies: - DynamoDBReadPolicy: TableName: !Ref MySimpleTable Events: MySimpleFunctionApi: Type: Api Properties: Path: /simpleTable Method: GET MySimpleTable: Type: AWS::Serverless::SimpleTable Just 20 lines to create: • Lambda function • IAM role • API Gateway
  • 20. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS SAM CLI • Create, build, test, and deploy AWS SAM applications • Step-through debugging and IDE support • Open source! • https://github.com/awslabs/aws- sam-cli
  • 21. © 2020, Amazon Web Services, Inc. or its Affiliates. Use SAM CLI to package and deploy SAM templates pip install --user aws-sam-cli # Or even better use native installers sam init --name my-app --runtime python cd my-app/ sam local ... # generate-event/invoke/start-api/start-lambda sam validate # The SAM template sam build # Depending on the runtime sam package --s3-bucket my-packages-bucket --output-template-file packaged.yaml sam deploy --template-file packaged.yaml --stack-name my-stack-prod sam logs -n MyFunction --stack-name my-stack-prod -t # Tail sam publish # To the Serverless Application Repository CodePipeline Use CloudFormation deployment actions with any SAM application Jenkins Use SAM CLI plugin
  • 22. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS Cloud Development Kit (CDK)
  • 23. © 2020, Amazon Web Services, Inc. or its Affiliates. AWSCloudDevelopmentKit(AWSCDK) A multi-language development framework for modeling infrastructure as reusable components
  • 24. © 2020, Amazon Web Services, Inc. or its Affiliates. Fromconstructstothecloud
  • 25. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CDK Constructs
  • 26. © 2020, Amazon Web Services, Inc. or its Affiliates. HashiCorpTerraform
  • 27. © 2020, Amazon Web Services, Inc. or its Affiliates. HashiCorp Configuration Language (HCL) provider "aws" { region = "eu-west-1" } resource "aws_instance" "web" { ami = data.aws_ami.ubuntu.id instance_type = "t2.micro" tags = { Name = "🚀 Terraforming AWS 🚀" } }
  • 28. © 2020, Amazon Web Services, Inc. or its Affiliates. Terraform Statefile { "version": 3, "serial": 1, "lineage": "f0548872-7819-974d-5df7-34653dacd3a1", "backend": { "type": "s3", "config": { "access_key": null, "acl": null, "assume_role_policy": null,
  • 29. © 2020, Amazon Web Services, Inc. or its Affiliates. Terraform Modules # Using the module from https://github.com/terraform- aws-modules/terraform-aws-vpc module "vpc" { source = "terraform-aws-modules/vpc/aws" name = "AWS SSA Webinar" cidr = var.vpc_cidr azs = var.azs private_subnets = var.private_subnets public_subnets = var.public_subnets }
  • 30. © 2020, Amazon Web Services, Inc. or its Affiliates. Takeaways! • Start with something small, but try to start as early as possible • Treat it like your code: PRs, CI/CD,Version controlled • Try more than one tool to find the one that fits your need / style • Split your infrastructure into smaller blocks to reduce blast radius
  • 31. © 2020, Amazon Web Services, Inc. or its Affiliates.
  • 32. Thank you! © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Cobus Bernard Sr Developer Advocate Amazon Web Services @cobusbernard cobusbernard cobusbernard CobusCloud

Hinweis der Redaktion

  1. Here is a few things we will be talking about today – I promise to make it more interesting than this slide! 
  2. So, the first question of today is - well what is Infrastructure as Code? Why Should you use it? Should you use it at all? Hmm … let’s just step back in time a bit … click
  3. Long gone are the times of racking and stacking – with the move towards the cloud, our speed and agility has increased. And the way to keep up with it to change our approach to provisioning infrastructure. (Story about provisioning from the past)
  4. And this is how it all looks now – wow – lot less cables and a lot less racking and stacking.
  5. You can use the same tools and processes as for software development: versioning & version control, reusability, automation, CI/CD, code reviews and automated testing.
  6. You can use the same tools and processes as for software development: versioning & version control, reusability, automation, CI/CD, code reviews and automated testing.
  7. So, the first question of today is - well what is Infrastructure as Code? Why Should you use it? Should you use it at all? Hmm … let’s just step back in time a bit … click
  8. Launched in 2011
  9. Here is how a CloudFormation code snipped looks like – and you have seen this before in one of my slides. In essence we write code into templates – it can be JSON (if you are a robot) or YAML if you like tab-spacing. Once that code is ”executed” we create these things called stacks – and it said stacks we have our resources. Those resources (of which cloudformation supports over 490) can be configured with a predefined set of properties (eg. An instance size for an EC2 instance), and CloudFormation takes care of dependancies for us – but we can also declare some for ourselves.
  10. The Resources section is the only mandatory section required in a template file Parameters and Mappings can help make a template reusable across environments, regions, and other use cases Conditions, as in other programs, can change the behavior of an operation from, for example, development to production environments Outputs can aid users to quickly access managed resources
  11. Last week, we announced and released Cloud Formation registry, a new open extensibility model for Cloud Formation. With the AWS CloudFormation Registry, you can develop and submit, discover, and manage custom or external resource providers. Once a resource provider is published in the AWS CloudFormation Registry, it can be used to manage third party resources in the same way as native AWS resource providers. It differentiates between Private and Public Resources. This new functionality will also work out of the box with services such as AWS Control Tower and AWS Service Catalog to help you with governance and resource compliance, and AWS CloudFormation StackSets for cross-account and cross-region management. You can develop your own resource providers using the AWS CloudFormation CLI, a new open source developer tool, ( documentation & CLI in GitHub as of November 14th ), and publish them to the Registry. The new CLI includes code generation and local testing capabilities to streamline your development process. To help you get started, you can also use the open sourced AWS Simple Email Service and CloudWatch Logs examples. But think about what technology partners can do with an open extensible model. This is the really exciting news here..
  12. So, the first question of today is - well what is Infrastructure as Code? Why Should you use it? Should you use it at all? Hmm … let’s just step back in time a bit … click
  13. So lets walk through a couple of different tools for iac, that are specific to serverless. One is the serverless application model for developers of serverless applications. This is a open source framework for build serverless applications on aws. You can think of this as a short hand syntax to express functions, apis, the databases that your functions are using and the event source mappings. So what happens when you deploy this sam template, it that it all gets expanded out into CloudFormation syntax. Because it is based on CloudFormation, it supports all the resource types out of the box automatically.
  14. This is an example of a sam template. It is a short hand syntax for your serverless application. I m expressing a serverless function and I am expressing the api that will trigger the function, the api gateway. But notice that I don’t need to specify that api gateway. And lower down you can see serverless simple table. These are less than 20 lines of yml that actually expand into a lambda function, all the necessary iam roles and policies, an api gateway that trigger the lambda and a table.
  15. So, the first question of today is - well what is Infrastructure as Code? Why Should you use it? Should you use it at all? Hmm … let’s just step back in time a bit … click
  16. So in essence CDK is a Multi language framework that allows you to model your infrastructure as … well … code ! We can use common languages to define our Infrastructure: JS/TS, Python Java C# Before going anywhere further – I need to talk about one of our customers on this topic!
  17. How it works is you write constructs – Apps, Stacks and resources – that gets synthesized by CDK CLI turned into CloudFormation anll the required Assets (like Lambda functions to S3) and the by usingCloudFormaton it gets deployed to the cloud.s
  18. CFN resource constructs – all resources in specification AWS Serbice constructs – higher-level abstractions with sensible defaults Design Patterns constructs – opinionated reference architectures and design patterns using multiple AWS services
  19. So, the first question of today is - well what is Infrastructure as Code? Why Should you use it? Should you use it at all? Hmm … let’s just step back in time a bit … click
  20. But … lets get to the main queston here … click
  21. Hmmm …