SlideShare a Scribd company logo
AWS CloudFormation
Michel Pereira
Solutions Architect
michelp@amazon.com
AWS CloudFormation
• AWS CloudFormation dá aos desenvolvedores e
administradores de sistemas uma maneira fácil de
criar e gerenciar recursos da AWS, provisionando
e atualizando a infra-estrutura de uma maneira
ordenada e previsível.
AWS CloudFormation

Templates para descrever os recursos da
AWS e qualquer dependência relacionada
ou parâmetros requiridos para executar a
sua aplicação
AWS CloudFormation

Você não precisa descobrir a ordem em
qual os serviços precisam ser
provisionados ou como fazer essas
dependências funcionarem.
AWS CloudFormation
Uma vez executado, você pode modificar
e atualizar os recursos de uma maneira
controlada e previsível, permitido você
versionar a sua infraestrutura do mesmo
jeito que você faz com o seu código
AWS CloudFormation

AWS CloudFormation é gratuito e você só
paga pelos recursos que serão utilizados
pelo seu aplicativo.
AWS CloudFormation
• Templates que descrevem os recursos da AWS

• Modifique e atualize os seus recursos AWS de uma
maneira controlada e previsível.
• Tenha controle de versão da sua infraestrutura na
AWS
AWS CloudFormation
Anatomia
de um template
JSON
Perfeito para
controle de
versão

Texto puro

JSON
Pode ser
validado
Linguagem
declarativa
{

"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template EC2InstanceSample: Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based on the region in which the stack is run. This example uses the default security group, so to
SSH to the new instance using the KeyPair you enter, you will need to have port 22 open in your default security group. **WARNING** This template an Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type" : "String"
}
},
"Mappings" : {
"RegionMap" : {
"us-east-1"
: { "AMI" : "ami-7f418316" },
"us-west-1"
: { "AMI" : "ami-951945d0" },
"us-west-2"
: { "AMI" : "ami-16fd7026" },
"eu-west-1"
: { "AMI" : "ami-24506250" },
"sa-east-1"
: { "AMI" : "ami-3e3be423" },
"ap-southeast-1" : { "AMI" : "ami-74dda626" },
"ap-northeast-1" : { "AMI" : "ami-dcfa4edd" }
}
},
"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"UserData" : { "Fn::Base64" : "80" }
}
}
},
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "Ec2Instance" }
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] }
},
…
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template EC2InstanceSample: Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based on the region in which the stack is run. This example uses the default security group, so to
SSH to the new instance using the KeyPair you enter, you will need to have port 22 open in your default security group. **WARNING** This template an Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type" : "String"
}
},
"Mappings" : {
"RegionMap" : {
"us-east-1"
: { "AMI" : "ami-7f418316" },
"us-west-1"
: { "AMI" : "ami-951945d0" },
"us-west-2"
: { "AMI" : "ami-16fd7026" },
"eu-west-1"
: { "AMI" : "ami-24506250" },
"sa-east-1"
: { "AMI" : "ami-3e3be423" },
"ap-southeast-1" : { "AMI" : "ami-74dda626" },
"ap-northeast-1" : { "AMI" : "ami-dcfa4edd" }
}
},

Parâmetros

Mapeamentos

"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"KeyName" : { "Ref" : "KeyName" },
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"UserData" : { "Fn::Base64" : "80" }
}
}
},
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "Ec2Instance" }
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] }
},
…..

Recursos

Saídas

Cabeçalho
Parâmetros
Configurações em tempo
de provisionamento
Programando sua infraestrutura com o AWS CloudFormation
Mapeamentos
Condições
Programando sua infraestrutura com o AWS CloudFormation
Programando sua infraestrutura com o AWS CloudFormation
Recursos
Programando sua infraestrutura com o AWS CloudFormation
Programando sua infraestrutura com o AWS CloudFormation
Programando sua infraestrutura com o AWS CloudFormation
“KeyName” : { “Ref” : “KeyName” },
Programando sua infraestrutura com o AWS CloudFormation
“ImageId” : {
“Fn::FindInMap” :
[ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ]
},
“ImageId” : {
“Fn::FindInMap” :
[ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ]
},
“ImageId” : {
“Fn::FindInMap” :
[ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ]
},
Saídas
Programando sua infraestrutura com o AWS CloudFormation
AWS CloudFormation
Recursos: Quase todos os serviços AWS
– O que está faltando (até agora)?
• Amazon Elastic MapReduce (EMR)
•
•
•
•
•

Amazon Simple Workflow Service (SWF)
Amazon Simple Email Service (SES)
Amazon Glacier
Amazon CloudSearch
Pequenas novidades de outros serviços ainda não
implementadas
AWS CloudFormation
Recursos – Amazon Elastic Compute Cloud (EC2):
{
"Type" : "AWS::EC2::Instance",
"Properties" : {
"AvailabilityZone" : String,
"DisableApiTermination" : Boolean,
"EbsOptimized" : Boolean,
"IamInstanceProfile" : String,
"ImageId" : String,
"InstanceType" : String,
AWS CloudFormation
Recursos – Amazon EC2:
–
–
–
–
–
–
–

– "KernelId" : String,
"KeyName" : String,
"Monitoring" : Boolean,
"PlacementGroupName" : String,
"PrivateIpAddress" : String,
"RamdiskId" : String,
"SecurityGroupIds" : [ String, ... ],
"SecurityGroups" : [ String, ... ],
AWS CloudFormation
Recursos – Amazon EC2:

"SourceDestCheck" : Boolean,
"SubnetId" : String,
"Tags" : [ EC2 Tag, ... ],
"Tenancy" : String,
"UserData" : String,
"Volumes" : [ EC2 MountPoint, ... ]
}
}
AWS CloudFormation

METADATA
AWS CloudFormation
Use AWS::CloudFormation::Init com cfn-init para ajudar a fazer o
“bootstrap” das instâncias:
"Metadata": {
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
},
"sources" : {
},
"commands" : {
},
"files" : {
},
"services" : {
},
"users" : {
},
"groups" : {
}
}
}
AWS CloudFormation
Instale pacotes com a ferramenta nativa de gerenciamento de pacotes:
“ServerHost" : {
"Type" : "AWS::EC2::Instance",
"Metadata" : {
"AWS:CloudFormation::Init" : {
"config" : {
"packages" : {
"yum" : {
"gcc" : [],
"gcc-c++" : [],
"make" : [],
"automake" : [],
AWS CloudFormation
Configure arquivos:

"/home/ec2-user/.s3cfg": {
"content": { "Fn::Join": [ "", [
"[default]","n",
"access_key = ", { "Ref": "CFNKeys"}, "n",
"secret_key = ", { "Fn::GetAtt": [ "CFNKeys", "SecretAccessKey"
]}, "n" ] ] },
"group": "ec2-user",
"mode": "000600",
"owner": "ec2-user"
},
AWS CloudFormation
Publique código de tar, tar+gzip, tar+bz2 and zip.
Até Github!:
"AWS::CloudFormation::Init" : {
"config" : {
"sources" : {
"/var/www/html" : "https://s3.amazonaws.com/cloudformationexamples/CloudFormationPHPSample.zip"
}
}
}
AWS CloudFormation
Ligue serviços dentro do host:
"services" : {
"sysvinit" : {
"nginx" : {
"enabled" : "true",
"ensureRunning" : "true",
"files" : ["/etc/nginx/nginx.conf"],
"sources" : ["/var/www/html"]
},
"sendmail" : {
"enabled" : "false",
"ensureRunning" : "false"
}
}
}
AWS CloudFormation
Recursos – Amazon RDS:
"MyDB" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"DBName" : { "Ref" : "DBName" },
"AllocatedStorage" : { "Ref" : "DBAllocatedStorage" },
"DBInstanceClass" : { "Ref" : "DBClass" },
"Engine" : "MySQL",
"EngineVersion" : "5.5",
"MasterUsername" : { "Ref" : "DBUsername" } ,
"MasterUserPassword" : { "Ref" : "DBPassword" },
"DBSubnetGroupName" : { "Ref" : "MyDBSubnetGroup" },
"DBSecurityGroups" : [ { "Ref" : "MyDBSecurityGroup" } ]
}
}
AWS CloudFormation
Recursos – Amazon RDS:
"Parameters" : {
"DBName": {
"Default": "MyDatabase",
"Description" : "The database name",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
},
"DBUsername": {
"Default": "admin",
"NoEcho": "true",
"Description" : "The database admin account username",
"Type": "String",
"MinLength": "1",
"MaxLength": "16",
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
},
AWS CloudFormation
Recursos – security groups:
"ControllerSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH access",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
}
]
}
}
In VPC? Add in: "VpcId" : { "Ref" : ”<your VPC>" },
AWS CloudFormation
Recursos – Amazon Virtual Private Cloud (VPC):
”MyVPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "192.168.0.0/16”
}
}
AWS CloudFormation
Recursos – Amazon VPC (continued):
"PublicSubnet" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : ”MyVPC" },
"CidrBlock" : "192.168.1.0/24"
}
},
AWS CloudFormation
Recursos – Amazon VPC (continued):
"InternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
}
},
"AttachGateway" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : { "Ref" : ”MyVPC" },
"InternetGatewayId" : { "Ref" : "InternetGateway" }
}
},
AWS CloudFormation
Recursos – Amazon VPC(continued):
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : {"Ref" : »MyVPC"},
}
},

"PublicRoute" : {
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "PublicRouteTable" },
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : { "Ref" : "InternetGateway" }
}
},

"PublicSubnetRouteTableAssociation" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PublicSubnet" },
"RouteTableId" : { "Ref" : "PublicRouteTable" }
}
AWS CloudFormation
Recursos – Amazon Simple Storage Service (S3):
"S3Bucket" : {
"Type" : "AWS::S3::Bucket",
"Properties" : {
"AccessControl" : "PublicRead",
"WebsiteConfiguration" : {
"IndexDocument" : "index.html",
"ErrorDocument" : "error.html"
}
},
"DeletionPolicy" : "Retain"
}
}
AWS CloudFormation

Versionamento!
Você tem um repositório de código, certo?

Se não, por favor crie um logo após o Webinar 
AWS CloudFormation
Versionamento!
• Você rastreia as atualizações no seu código
• Mesma coisa com a infraestrutura:
–
–
–
–

O que está sendo mudado?
Quem fez a atualização?
Quando foi feita?
Porquê?(atrelada a um ticket/bug/sistema de projetos?)
AWS CloudFormation
Testando:
–

Validação via API/linha de comando
$ aws --region=us-east-1 cloudformation validate-template --template-body file://$PWD/Lab1-nat_stack.template
{
"ResponseMetadata": {
"RequestId": "174228cc-2c59-11e3-a4b8-8d0a0ca6c09c"
},
"Description": "Builds a NAT host. **WARNING** This template creates Amazon EC2 instance(s). You will be billed for the
AWS resources used if you create a stack from this template.",
"Parameters": [
{
"NoEcho": false,
"Description": "SubnetId of an existing Public facing subnet in your Virtual Private Cloud (VPC)",
"ParameterKey": "SubnetId"
},
……..
],
"Capabilities": []
AWS CloudFormation
Publicação e atualização via console ou API/linha
de comando:
– Alguns cliques
OU
– aws cloudformation create-stack --stack-name myteststack
--template-body
file:////home//local//test//sampletemplate.json --parameters
ParameterKey=string,ParameterValue=string
Demo!
AWS CloudFormation
Como aprender mais:
– RTFM!
• http://aws.amazon.com/cloudformation/
• http://aws.amazon.com/documentation/cloudformati
on/
• https://aws.amazon.com/cloudformation/awscloudformation-templates/
michelp@amazon.com
Michel Pereira
Solutions Architect

More Related Content

Similar to Programando sua infraestrutura com o AWS CloudFormation (20)

PDF
Scalable and Fault-Tolerant Apps with AWS
Fernando Rodriguez
 
PDF
Making web stack tasty using Cloudformation
Nicola Salvo
 
PPTX
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
Chef
 
PDF
Dev & Test on AWS - Journey Through the Cloud
Ian Massingham
 
PDF
CloudFormation vs. Elastic Beanstalk & Use cases
Wayland Zhang
 
PDF
Infrastructure as Code: Manage your Architecture with Git
Danilo Poccia
 
PPTX
Dev & Test on AWS - Hebrew Webinar
Boaz Ziniman
 
PDF
Infrastructure as Code: Manage your Architecture with Git
Danilo Poccia
 
PDF
Przemysław Iwanek - ABC AWS, budowanie infrastruktury przy pomocy Terraform
jzielinski_pl
 
PDF
5 things you don't know about Amazon Web Services
Simone Brunozzi
 
PDF
AWS Study Group - Chapter 03 - Elasticity and Scalability Concepts [Solution ...
QCloudMentor
 
PDF
2013 05-openstack-israel-heat
Alex Heneveld
 
PDF
Managing Infrastructure as Code
Allan Shone
 
PPTX
AWS CloudFormation Session
Kamal Maiti
 
PDF
AWS Las Vegas meetup 5-31-16 building &scaling web apps - slide deck & labs
HATech LLC
 
PDF
Running Open Source Platforms on AWS (November 2016)
Julien SIMON
 
PPTX
CLI.pptx
Ganesh Bhosale
 
PDF
AWS CloudFormation (February 2016)
Julien SIMON
 
PPTX
AWS Fundamentals @Back2School by CloudZone
Idan Tohami
 
PPTX
Scaling horizontally on AWS
Bozhidar Bozhanov
 
Scalable and Fault-Tolerant Apps with AWS
Fernando Rodriguez
 
Making web stack tasty using Cloudformation
Nicola Salvo
 
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
Chef
 
Dev & Test on AWS - Journey Through the Cloud
Ian Massingham
 
CloudFormation vs. Elastic Beanstalk & Use cases
Wayland Zhang
 
Infrastructure as Code: Manage your Architecture with Git
Danilo Poccia
 
Dev & Test on AWS - Hebrew Webinar
Boaz Ziniman
 
Infrastructure as Code: Manage your Architecture with Git
Danilo Poccia
 
Przemysław Iwanek - ABC AWS, budowanie infrastruktury przy pomocy Terraform
jzielinski_pl
 
5 things you don't know about Amazon Web Services
Simone Brunozzi
 
AWS Study Group - Chapter 03 - Elasticity and Scalability Concepts [Solution ...
QCloudMentor
 
2013 05-openstack-israel-heat
Alex Heneveld
 
Managing Infrastructure as Code
Allan Shone
 
AWS CloudFormation Session
Kamal Maiti
 
AWS Las Vegas meetup 5-31-16 building &scaling web apps - slide deck & labs
HATech LLC
 
Running Open Source Platforms on AWS (November 2016)
Julien SIMON
 
CLI.pptx
Ganesh Bhosale
 
AWS CloudFormation (February 2016)
Julien SIMON
 
AWS Fundamentals @Back2School by CloudZone
Idan Tohami
 
Scaling horizontally on AWS
Bozhidar Bozhanov
 

More from Amazon Web Services LATAM (20)

PPTX
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
PPTX
Automatice el proceso de entrega con CI/CD en AWS
Amazon Web Services LATAM
 
PPTX
Automatize seu processo de entrega de software com CI/CD na AWS
Amazon Web Services LATAM
 
PPTX
Cómo empezar con Amazon EKS
Amazon Web Services LATAM
 
PPTX
Como começar com Amazon EKS
Amazon Web Services LATAM
 
PPTX
Ransomware: como recuperar os seus dados na nuvem AWS
Amazon Web Services LATAM
 
PPTX
Ransomware: cómo recuperar sus datos en la nube de AWS
Amazon Web Services LATAM
 
PPTX
Ransomware: Estratégias de Mitigação
Amazon Web Services LATAM
 
PPTX
Ransomware: Estratégias de Mitigación
Amazon Web Services LATAM
 
PPTX
Aprenda a migrar y transferir datos al usar la nube de AWS
Amazon Web Services LATAM
 
PPTX
Aprenda como migrar e transferir dados ao utilizar a nuvem da AWS
Amazon Web Services LATAM
 
PPTX
Cómo mover a un almacenamiento de archivos administrados
Amazon Web Services LATAM
 
PPTX
Simplifique su BI con AWS
Amazon Web Services LATAM
 
PPTX
Simplifique o seu BI com a AWS
Amazon Web Services LATAM
 
PPTX
Os benefícios de migrar seus workloads de Big Data para a AWS
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
Automatice el proceso de entrega con CI/CD en AWS
Amazon Web Services LATAM
 
Automatize seu processo de entrega de software com CI/CD na AWS
Amazon Web Services LATAM
 
Cómo empezar con Amazon EKS
Amazon Web Services LATAM
 
Como começar com Amazon EKS
Amazon Web Services LATAM
 
Ransomware: como recuperar os seus dados na nuvem AWS
Amazon Web Services LATAM
 
Ransomware: cómo recuperar sus datos en la nube de AWS
Amazon Web Services LATAM
 
Ransomware: Estratégias de Mitigação
Amazon Web Services LATAM
 
Ransomware: Estratégias de Mitigación
Amazon Web Services LATAM
 
Aprenda a migrar y transferir datos al usar la nube de AWS
Amazon Web Services LATAM
 
Aprenda como migrar e transferir dados ao utilizar a nuvem da AWS
Amazon Web Services LATAM
 
Cómo mover a un almacenamiento de archivos administrados
Amazon Web Services LATAM
 
Simplifique su BI con AWS
Amazon Web Services LATAM
 
Simplifique o seu BI com a AWS
Amazon Web Services LATAM
 
Os benefícios de migrar seus workloads de Big Data para a AWS
Amazon Web Services LATAM
 
Ad

Recently uploaded (20)

PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Français Patch Tuesday - Juillet
Ivanti
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
July Patch Tuesday
Ivanti
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Français Patch Tuesday - Juillet
Ivanti
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
July Patch Tuesday
Ivanti
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Ad

Programando sua infraestrutura com o AWS CloudFormation

  • 2. AWS CloudFormation • AWS CloudFormation dá aos desenvolvedores e administradores de sistemas uma maneira fácil de criar e gerenciar recursos da AWS, provisionando e atualizando a infra-estrutura de uma maneira ordenada e previsível.
  • 3. AWS CloudFormation Templates para descrever os recursos da AWS e qualquer dependência relacionada ou parâmetros requiridos para executar a sua aplicação
  • 4. AWS CloudFormation Você não precisa descobrir a ordem em qual os serviços precisam ser provisionados ou como fazer essas dependências funcionarem.
  • 5. AWS CloudFormation Uma vez executado, você pode modificar e atualizar os recursos de uma maneira controlada e previsível, permitido você versionar a sua infraestrutura do mesmo jeito que você faz com o seu código
  • 6. AWS CloudFormation AWS CloudFormation é gratuito e você só paga pelos recursos que serão utilizados pelo seu aplicativo.
  • 7. AWS CloudFormation • Templates que descrevem os recursos da AWS • Modifique e atualize os seus recursos AWS de uma maneira controlada e previsível. • Tenha controle de versão da sua infraestrutura na AWS
  • 10. JSON
  • 11. Perfeito para controle de versão Texto puro JSON Pode ser validado
  • 13. { "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation Sample Template EC2InstanceSample: Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based on the region in which the stack is run. This example uses the default security group, so to SSH to the new instance using the KeyPair you enter, you will need to have port 22 open in your default security group. **WARNING** This template an Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters" : { "KeyName" : { "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", "Type" : "String" } }, "Mappings" : { "RegionMap" : { "us-east-1" : { "AMI" : "ami-7f418316" }, "us-west-1" : { "AMI" : "ami-951945d0" }, "us-west-2" : { "AMI" : "ami-16fd7026" }, "eu-west-1" : { "AMI" : "ami-24506250" }, "sa-east-1" : { "AMI" : "ami-3e3be423" }, "ap-southeast-1" : { "AMI" : "ami-74dda626" }, "ap-northeast-1" : { "AMI" : "ami-dcfa4edd" } } }, "Resources" : { "Ec2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, "UserData" : { "Fn::Base64" : "80" } } } }, "Outputs" : { "InstanceId" : { "Description" : "InstanceId of the newly created EC2 instance", "Value" : { "Ref" : "Ec2Instance" } }, "AZ" : { "Description" : "Availability Zone of the newly created EC2 instance", "Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] } }, …
  • 14. "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation Sample Template EC2InstanceSample: Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based on the region in which the stack is run. This example uses the default security group, so to SSH to the new instance using the KeyPair you enter, you will need to have port 22 open in your default security group. **WARNING** This template an Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters" : { "KeyName" : { "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", "Type" : "String" } }, "Mappings" : { "RegionMap" : { "us-east-1" : { "AMI" : "ami-7f418316" }, "us-west-1" : { "AMI" : "ami-951945d0" }, "us-west-2" : { "AMI" : "ami-16fd7026" }, "eu-west-1" : { "AMI" : "ami-24506250" }, "sa-east-1" : { "AMI" : "ami-3e3be423" }, "ap-southeast-1" : { "AMI" : "ami-74dda626" }, "ap-northeast-1" : { "AMI" : "ami-dcfa4edd" } } }, Parâmetros Mapeamentos "Resources" : { "Ec2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, "UserData" : { "Fn::Base64" : "80" } } } }, "Outputs" : { "InstanceId" : { "Description" : "InstanceId of the newly created EC2 instance", "Value" : { "Ref" : "Ec2Instance" } }, "AZ" : { "Description" : "Availability Zone of the newly created EC2 instance", "Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] } }, ….. Recursos Saídas Cabeçalho
  • 24. “KeyName” : { “Ref” : “KeyName” },
  • 26. “ImageId” : { “Fn::FindInMap” : [ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ] },
  • 27. “ImageId” : { “Fn::FindInMap” : [ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ] },
  • 28. “ImageId” : { “Fn::FindInMap” : [ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ] },
  • 31. AWS CloudFormation Recursos: Quase todos os serviços AWS – O que está faltando (até agora)? • Amazon Elastic MapReduce (EMR) • • • • • Amazon Simple Workflow Service (SWF) Amazon Simple Email Service (SES) Amazon Glacier Amazon CloudSearch Pequenas novidades de outros serviços ainda não implementadas
  • 32. AWS CloudFormation Recursos – Amazon Elastic Compute Cloud (EC2): { "Type" : "AWS::EC2::Instance", "Properties" : { "AvailabilityZone" : String, "DisableApiTermination" : Boolean, "EbsOptimized" : Boolean, "IamInstanceProfile" : String, "ImageId" : String, "InstanceType" : String,
  • 33. AWS CloudFormation Recursos – Amazon EC2: – – – – – – – – "KernelId" : String, "KeyName" : String, "Monitoring" : Boolean, "PlacementGroupName" : String, "PrivateIpAddress" : String, "RamdiskId" : String, "SecurityGroupIds" : [ String, ... ], "SecurityGroups" : [ String, ... ],
  • 34. AWS CloudFormation Recursos – Amazon EC2: "SourceDestCheck" : Boolean, "SubnetId" : String, "Tags" : [ EC2 Tag, ... ], "Tenancy" : String, "UserData" : String, "Volumes" : [ EC2 MountPoint, ... ] } }
  • 36. AWS CloudFormation Use AWS::CloudFormation::Init com cfn-init para ajudar a fazer o “bootstrap” das instâncias: "Metadata": { "AWS::CloudFormation::Init" : { "config" : { "packages" : { }, "sources" : { }, "commands" : { }, "files" : { }, "services" : { }, "users" : { }, "groups" : { } } }
  • 37. AWS CloudFormation Instale pacotes com a ferramenta nativa de gerenciamento de pacotes: “ServerHost" : { "Type" : "AWS::EC2::Instance", "Metadata" : { "AWS:CloudFormation::Init" : { "config" : { "packages" : { "yum" : { "gcc" : [], "gcc-c++" : [], "make" : [], "automake" : [],
  • 38. AWS CloudFormation Configure arquivos: "/home/ec2-user/.s3cfg": { "content": { "Fn::Join": [ "", [ "[default]","n", "access_key = ", { "Ref": "CFNKeys"}, "n", "secret_key = ", { "Fn::GetAtt": [ "CFNKeys", "SecretAccessKey" ]}, "n" ] ] }, "group": "ec2-user", "mode": "000600", "owner": "ec2-user" },
  • 39. AWS CloudFormation Publique código de tar, tar+gzip, tar+bz2 and zip. Até Github!: "AWS::CloudFormation::Init" : { "config" : { "sources" : { "/var/www/html" : "https://s3.amazonaws.com/cloudformationexamples/CloudFormationPHPSample.zip" } } }
  • 40. AWS CloudFormation Ligue serviços dentro do host: "services" : { "sysvinit" : { "nginx" : { "enabled" : "true", "ensureRunning" : "true", "files" : ["/etc/nginx/nginx.conf"], "sources" : ["/var/www/html"] }, "sendmail" : { "enabled" : "false", "ensureRunning" : "false" } } }
  • 41. AWS CloudFormation Recursos – Amazon RDS: "MyDB" : { "Type" : "AWS::RDS::DBInstance", "Properties" : { "DBName" : { "Ref" : "DBName" }, "AllocatedStorage" : { "Ref" : "DBAllocatedStorage" }, "DBInstanceClass" : { "Ref" : "DBClass" }, "Engine" : "MySQL", "EngineVersion" : "5.5", "MasterUsername" : { "Ref" : "DBUsername" } , "MasterUserPassword" : { "Ref" : "DBPassword" }, "DBSubnetGroupName" : { "Ref" : "MyDBSubnetGroup" }, "DBSecurityGroups" : [ { "Ref" : "MyDBSecurityGroup" } ] } }
  • 42. AWS CloudFormation Recursos – Amazon RDS: "Parameters" : { "DBName": { "Default": "MyDatabase", "Description" : "The database name", "Type": "String", "MinLength": "1", "MaxLength": "64", "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." }, "DBUsername": { "Default": "admin", "NoEcho": "true", "Description" : "The database admin account username", "Type": "String", "MinLength": "1", "MaxLength": "16", "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." },
  • 43. AWS CloudFormation Recursos – security groups: "ControllerSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "Enable SSH access", "SecurityGroupIngress": [ { "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "0.0.0.0/0" } ] } } In VPC? Add in: "VpcId" : { "Ref" : ”<your VPC>" },
  • 44. AWS CloudFormation Recursos – Amazon Virtual Private Cloud (VPC): ”MyVPC" : { "Type" : "AWS::EC2::VPC", "Properties" : { "CidrBlock" : "192.168.0.0/16” } }
  • 45. AWS CloudFormation Recursos – Amazon VPC (continued): "PublicSubnet" : { "Type" : "AWS::EC2::Subnet", "Properties" : { "VpcId" : { "Ref" : ”MyVPC" }, "CidrBlock" : "192.168.1.0/24" } },
  • 46. AWS CloudFormation Recursos – Amazon VPC (continued): "InternetGateway" : { "Type" : "AWS::EC2::InternetGateway", "Properties" : { } }, "AttachGateway" : { "Type" : "AWS::EC2::VPCGatewayAttachment", "Properties" : { "VpcId" : { "Ref" : ”MyVPC" }, "InternetGatewayId" : { "Ref" : "InternetGateway" } } },
  • 47. AWS CloudFormation Recursos – Amazon VPC(continued): "PublicRouteTable" : { "Type" : "AWS::EC2::RouteTable", "Properties" : { "VpcId" : {"Ref" : »MyVPC"}, } }, "PublicRoute" : { "Type" : "AWS::EC2::Route", "Properties" : { "RouteTableId" : { "Ref" : "PublicRouteTable" }, "DestinationCidrBlock" : "0.0.0.0/0", "GatewayId" : { "Ref" : "InternetGateway" } } }, "PublicSubnetRouteTableAssociation" : { "Type" : "AWS::EC2::SubnetRouteTableAssociation", "Properties" : { "SubnetId" : { "Ref" : "PublicSubnet" }, "RouteTableId" : { "Ref" : "PublicRouteTable" } }
  • 48. AWS CloudFormation Recursos – Amazon Simple Storage Service (S3): "S3Bucket" : { "Type" : "AWS::S3::Bucket", "Properties" : { "AccessControl" : "PublicRead", "WebsiteConfiguration" : { "IndexDocument" : "index.html", "ErrorDocument" : "error.html" } }, "DeletionPolicy" : "Retain" } }
  • 49. AWS CloudFormation Versionamento! Você tem um repositório de código, certo? Se não, por favor crie um logo após o Webinar 
  • 50. AWS CloudFormation Versionamento! • Você rastreia as atualizações no seu código • Mesma coisa com a infraestrutura: – – – – O que está sendo mudado? Quem fez a atualização? Quando foi feita? Porquê?(atrelada a um ticket/bug/sistema de projetos?)
  • 51. AWS CloudFormation Testando: – Validação via API/linha de comando $ aws --region=us-east-1 cloudformation validate-template --template-body file://$PWD/Lab1-nat_stack.template { "ResponseMetadata": { "RequestId": "174228cc-2c59-11e3-a4b8-8d0a0ca6c09c" }, "Description": "Builds a NAT host. **WARNING** This template creates Amazon EC2 instance(s). You will be billed for the AWS resources used if you create a stack from this template.", "Parameters": [ { "NoEcho": false, "Description": "SubnetId of an existing Public facing subnet in your Virtual Private Cloud (VPC)", "ParameterKey": "SubnetId" }, …….. ], "Capabilities": []
  • 52. AWS CloudFormation Publicação e atualização via console ou API/linha de comando: – Alguns cliques OU – aws cloudformation create-stack --stack-name myteststack --template-body file:////home//local//test//sampletemplate.json --parameters ParameterKey=string,ParameterValue=string
  • 53. Demo!
  • 54. AWS CloudFormation Como aprender mais: – RTFM! • http://aws.amazon.com/cloudformation/ • http://aws.amazon.com/documentation/cloudformati on/ • https://aws.amazon.com/cloudformation/awscloudformation-templates/

Editor's Notes

  • #9: ----- Meeting Notes (11/19/12 10:02) -----give more personal story around this.
  • #13: In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow.[1] Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than describing how to go about accomplishing it[2] (the how is left up to the language&apos;s implementation). This is in contrast with imperative programming, which in algorithms are implemented in terms of explicit steps.Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming has become of particular interest recently, as it may greatly simplify writing parallel programs.[3]Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming, and functional programming.http://en.wikipedia.org/wiki/Declarative_programming
  • #25: “KeyName” : { “Ref” : “KeyName” },
  • #27: “ImageId” : { “Fn::FindInMap” : [ “RegionMap”, { “Ref” : “AWS::Region” }, “AMI” ]},
  • #29: Referência de propriedade declarada
  • #35: ----- Meeting Notes (11/5/12 19:58) -----iceberg #1 next
  • #41: ----- Meeting Notes (10/9/12 17:50) -----End of Metadata, next up RDS
  • #44: ----- Meeting Notes (10/9/12 17:50) -----Speaking of VPC
  • #48: ----- Meeting Notes (10/9/12 17:52) -----You now have a fully functioning virtual private cloud that can receive instances/other services, and be internet facing if need be.