Ansible,Terraform,AWS,Azure IaC tools
a simple scenario of provisioning an AWS EC2 Instance

Ansible,Terraform,AWS,Azure IaC tools

terraform {
required_providers {
aws = {
source  = "hashicorp/aws"
version = "~> 3.27"
}
}
}
provider "aws" {
access_key = "aws_access_key"
secret_key = "aws_secret_key"
// shared_credentials_file = "/Users/.aws/creds"
region = "us-west-1"
}
resource "aws_instance" "web_server" {
ami                    = "ami-0123456"
instance_type          = "t3.small"
subnet_id              = "subnet-a000111x"
vpc_security_group_ids = "sg-dfdd00011"
key_name               = "web_server_test_key"
tags = {
Name = "Web_Server"
}
}        

Terraform

Terraform by HashiCorp is the leading IaC tool specialized in managing infrastructure across various platforms from AWS Azure GCP?to Oracle Cloud, Alibaba Cloud, and even platforms like Kubernetes?and Heroku.

As a platform-agnostic tool, Terraform can be used to facilitate any infrastructure provisioning and management use cases across different platforms and providers while ensuring the desired state across the configurations.



Ansible

Ansible is not a dedicated Infrastructure management tool but more of an open-source configuration management tool with IaC capabilities. Ansible supports both cloud and on-prem environments and can act through SSH or WinRM as an agentless tool. Ansible excels at configuration management and infrastructure provisioning yet is limited when it comes to managing said infrastructure.

ANSIBLE / AWS CloudFormation example:

- hosts: localhost
gather_facts: False
vars_files:
- credentials.yml
tasks:
- name: Provision EC2 Instance
ec2:
aws_access_key: "{{aws_access_key}}"
aws_secret_key: "{{aws_secret_key}}"
key_name: web_server_test_key
group: test
instance_type: t3.small
image: "ami-0123456"
wait: true
count: 1
region: us-west-1
instance_tags:
Name: Web_Server
register: ec2

CloudFormation:
AWSTemplateFormatVersion: "2010-09-09"
Resources:
WebInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t3.small
ImageId: ami-0123456
KeyName: web_server_test_key
SecurityGroupIds:
- sg-dfdd00011
SubnetId: subnet-a000111x
Tags:
-
Key: Name
Value: Web_Server        

AWS CloudFormation

AWS CloudFormation is the AWS proprietary platform specific IaC tool to manage AWS infrastructure. CloudFormation has deep integration with all AWS services and can facilitate any AWS configuration as a first-party solution.


Azure Resource Templates

Microsoft Azure uses JSON-based?Azure Resource Templates to facilitate IaC practices within the Azure platform. These resource templates ensure consistency of the infrastructure and can be used for any type of resource configuration.



In addition to the above, there are specialized tools aimed at specific infrastructure and configuration management tasks such as:

  • Packer, EC2 Image Builder, and Azure Image Builder create deployable custom os images.
  • Cloud-Init is the industry-standard cross-platform cloud instance initialization tool. It enables users to execute the script when provisioning resources (servers).
  • (R)?ex is a fully featured infrastucture automation framework.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了