{
"AWSTemplateFormatVersion" : "2010-09-09",
"Parameters" : {
"BastionHostKeyName" : {
"Type" : "String",
"Description" : "The name of the private key file to use for SSH/RDP access to the bastion host."
},
"BastionSecurityCIDR" : {
"Type" : "String",
"Description" : "The CIDR range to use to lock down security on the bastion host.",
"Default" : "0.0.0.0/0"
},
"BastionInstanceType" : {
"Type" : "String",
"Description" : "The size of the instance to use for the bastion host."
}
},
"Mappings" : {
"AmazonLinuxAMI": {
"us-east-1": {
"AMI": "ami-1ecae776"
},
"us-west-1": {
"AMI": "ami-d114f295"
},
"us-west-2": {
"AMI": "ami-e7527ed7"
},
"eu-west-1": {
"AMI": "ami-a10897d6"
},
"eu-central-1": {
"AMI": "ami-a8221fb5"
},
"sa-east-1": {
"AMI": "ami-b52890a8"
},
"ap-southeast-1": {
"AMI": "ami-68d8e93a"
},
"ap-southeast-2": {
"AMI": "ami-fd9cecc7"
},
"ap-northeast-1": {
"AMI": "ami-cbf90ecb"
}
}
},
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "10.1.0.0/16",
"EnableDnsSupport" : "true",
"EnableDnsHostnames" : "true",
"Tags" : [{
"Key" : "Name",
"Value" : "Lab VPC"
}
]
}
},
"InternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"DependsOn" : "VPC"
},
"AttachGateway" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"DependsOn" : ["VPC", "InternetGateway"],
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"InternetGatewayId" : {
"Ref" : "InternetGateway"
}
}
},
"PublicSubnet1" : {
"Type" : "AWS::EC2::Subnet",
"DependsOn" : "AttachGateway",
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"CidrBlock" : "10.1.10.0/24",
"MapPublicIpOnLaunch" : "true",
"AvailabilityZone" : {
"Fn::Select" : [
"0", {
"Fn::GetAZs" : ""
}
]
},
"Tags" : [{
"Key" : "Name",
"Value" : "Public Subnet 1"
}
]
}
},
"PrivateSubnet1" : {
"Type" : "AWS::EC2::Subnet",
"DependsOn" : "AttachGateway",
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"CidrBlock" : "10.1.50.0/24",
"AvailabilityZone" : {
"Fn::Select" : [
"0", {
"Fn::GetAZs" : ""
}
]
},
"Tags" : [{
"Key" : "Name",
"Value" : "Private Subnet 1"
}
]
}
},
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"DependsOn" : ["VPC", "AttachGateway"],
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"Tags" : [{
"Key" : "Name",
"Value" : "Public"
}
]
}
},
"PublicRoute" : {
"Type" : "AWS::EC2::Route",
"DependsOn" : ["PublicRouteTable", "AttachGateway"],
"Properties" : {
"RouteTableId" : {
"Ref" : "PublicRouteTable"
},
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : {
"Ref" : "InternetGateway"
}
}
},
"PublicSubnet1RouteTableAssociation" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"DependsOn" : ["PublicRouteTable", "PublicSubnet1", "AttachGateway"],
"Properties" : {
"SubnetId" : {
"Ref" : "PublicSubnet1"
},
"RouteTableId" : {
"Ref" : "PublicRouteTable"
}
}
},
"PrivateRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"DependsOn" : "AttachGateway",
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"Tags" : [{
"Key" : "Name",
"Value" : "Private"
}
]
}
},
"PrivateSubnet1RouteTableAssociation" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"DependsOn" : ["PublicRouteTable", "PrivateSubnet1", "AttachGateway"],
"Properties" : {
"SubnetId" : {
"Ref" : "PrivateSubnet1"
},
"RouteTableId" : {
"Ref" : "PrivateRouteTable"
}
}
},
"PrivateNetworkAcl" : {
"Type" : "AWS::EC2::NetworkAcl",
"DependsOn" : "AttachGateway",
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"Tags" : [{
"Key" : "Network",
"Value" : "Private"
}
]
}
},
"NATInstance" : {
"Type" : "AWS::EC2::Instance",
"DependsOn" : ["AttachGateway", "PublicRoute", "PublicSubnet1"],
"Properties" : {
"ImageId" : {
"Fn::FindInMap" : [
"AmazonLinuxAMI", {
"Ref" : "AWS::Region"
},
"AMI"
]
},
"InstanceType" : "t2.small",
"NetworkInterfaces" : [{
"DeviceIndex" : "0",
"AssociatePublicIpAddress" : "true",
"SubnetId" : {
"Ref" : "PublicSubnet1"
},
"GroupSet" : [{
"Ref" : "NATSecurityGroup"
}
]
}
],
"SourceDestCheck" : "false",
"Tags" : [{
"Key" : "Name",
"Value" : "NAT"
}
],
"UserData" : {
"Fn::Base64" : {
"Fn::Join" : [
"\n",
[
"#!/bin/bash",
"yum -y update",
"echo 1 > /proc/sys/net/ipv4/ip_forward",
"echo 0 > /proc/sys/net/ipv4/conf/eth0/send_redirects",
"/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 0.0.0.0/0 -j MASQUERADE",
"/sbin/iptables-save > /etc/sysconfig/iptables",
"mkdir -p /etc/sysctl.d/",
"cat <<EOF > /etc/sysctl.d/nat.conf",
"net.ipv4.ip_forward = 1",
"net.ipv4.conf.eth0.send_redirects = 0",
"EOF \n"
]
]
}
}
}
},
"NATSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"DependsOn" : "AttachGateway",
"Properties" : {
"GroupDescription" : "Enable internal access to the NAT device",
"VpcId" : {
"Ref" : "VPC"
},
"SecurityGroupIngress" : [{
"IpProtocol" : "tcp",
"FromPort" : "0",
"ToPort" : "1024",
"CidrIp" : "10.1.50.0/24"
}, {
"IpProtocol" : "udp",
"FromPort" : "0",
"ToPort" : "1024",
"CidrIp" : "10.1.50.0/24"
}
],
"SecurityGroupEgress" : [{
"IpProtocol" : "tcp",
"FromPort" : "0",
"ToPort" : "65535",
"CidrIp" : "0.0.0.0/0"
}, {
"IpProtocol" : "udp",
"FromPort" : "0",
"ToPort" : "65535",
"CidrIp" : "0.0.0.0/0"
}
]
}
},
"PrivateRoute" : {
"Type" : "AWS::EC2::Route",
"DependsOn" : ["NATInstance", "PrivateRouteTable"],
"Properties" : {
"RouteTableId" : {
"Ref" : "PrivateRouteTable"
},
"DestinationCidrBlock" : "0.0.0.0/0",
"InstanceId" : {
"Ref" : "NATInstance"
}
}
},
"BastionServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"DependsOn" : "AttachGateway",
"Properties" : {
"GroupDescription" : "Security Group for bastion server",
"VpcId" : {
"Ref" : "VPC"
},
"Tags" : [{
"Key" : "Name",
"Value" : "BastionServerSecurityGroup"
}, {
"Key" : "ResourceGroup",
"Value" : "CloudFormationResource"
}
],
"SecurityGroupIngress" : [{
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : {
"Ref" : "BastionSecurityCIDR"
}
}
]
}
},
"BastionServer" : {
"Type" : "AWS::EC2::Instance",
"DependsOn" : ["NATInstance"],
"Properties" : {
"ImageId" : {
"Fn::FindInMap" : [
"AmazonLinuxAMI", {
"Ref" : "AWS::Region"
},
"AMI"
]
},
"InstanceType" : {
"Ref" : "BastionInstanceType"
},
"KeyName" : {
"Ref" : "BastionHostKeyName"
},
"NetworkInterfaces" : [{
"DeviceIndex" : "0",
"AssociatePublicIpAddress" : "true",
"SubnetId" : {
"Ref" : "PrivateSubnet1"
},
"GroupSet" : [{
"Ref" : "BastionServerSecurityGroup"
}
]
}
],
"Tags" : [{
"Key" : "Name",
"Value" : "BastionServer"
}
],
"UserData" : {
"Fn::Base64" : {
"Fn::Join" : [
"",
[
"#!/bin/bash -ex \n",
"yum -y update \n"
]
]
}
}
}
}
}
}

  

AWS CloudFormation Template的更多相关文章

  1. Lab_7_Automating_v2.5

    System Operations - Lab 7: Automating Deployments with CloudFormation - 2.5 ======================== ...

  2. 【译】OpenStack Heat基础介绍

    原文:http://blog.scottlowe.org/2014/05/01/an-introduction-to-openstack-heat/ 本文将简要地介绍OpenStack Heat. H ...

  3. OpenStack 初探(一) -- All-In-One模式部署(初学OpenStack必备)

    OpenStack 初探(一) -- All-In-One模式部署(初学OpenStack必备) 一.操作前需了解:     1. OpenStack提供IaaS(基础设施即服务)服务,它是开源的云计 ...

  4. System Operations on AWS - Lab 7 - CloudFormation

    CloudFormation模板:创建一个VPC(包含Public子网,Private子网,分别在不同的AZ),创建NAT,Bastion Server在Public子网. 1. 修改并运行AWS C ...

  5. DevOps on AWS之Cloudformation实践篇

    cloudformation入门实践 AWS cloudformation通过模板对AWS云资源进行编排和调用.并且可以通过模板代码层面的修改就可以对现有环境进行升级改造,云端业务的灵活便捷特点展现无 ...

  6. DevOps on AWS之Cloudformation概念介绍篇

    Cloudformation的相关概念 AWS cloudformation是一项典型的(IAC)基础架构即代码服务..通过编写模板对亚马逊云服务的资源进行调用和编排.借助cloudformation ...

  7. 亚马逊云服务之CloudFormation

    亚马逊的Web Service其实包含了一套云服务.云服务主要分为三种: IaaS: Infrastructure as a service,基础设施即服务. PaaS: Platform as a ...

  8. CloudFormation

    亚马逊云服务之CloudFormation   亚马逊的Web Service其实包含了一套云服务.云服务主要分为三种: IaaS: Infrastructure as a service,基础设施即 ...

  9. OpenStack-Heat中的AWS::WaitCondition的使用

    在heat中.一个instance的创建成功信号是在这个instance状态成为active之后发出的,这时候user-data可能还没有运行.可是heat已经觉得这个resource创建成功了,開始 ...

随机推荐

  1. 数据结构《19》----String容器的三种实现

    一.序言 一个简单的string 容器到底是如何实现的? 本文给出了 String 的三种从易到难的实现,涉及了 reference counting, copy on write 的技术. 二.第一 ...

  2. mac下安装和配置mysql5.7.9

    我安装的是5.7.9版本的sql 一开始在网上看到的都是其他版本的安装,弄得自己卸载了好几次 mysql就只有一个dmg主文件,安装这一个就好了. 5.7以后安装的mysql不再使用旧版的默认密码:r ...

  3. B样条基函数(cubic spline basis)

    B样条基函数用作权重 reference http://blog.csdn.net/tuqu

  4. 类和对象 nil/Nil/NULL的区别

    iOS-----类和对象,nil/Nil/NULL的区别   iOS中类和对象,nil/Nil/NULL的区别 类与对象的概念 类是对同一类事物高度的抽象,类中定义了这一类对象所应具有的静态属性(属性 ...

  5. iOS学习之iOS沙盒(sandbox)机制和文件操作之NSFileManager(三)

    1.在Documents里创建目录 创建一个叫test的目录,先找到Documents的目录, NSArray *paths = NSSearchPathForDirectoriesInDomains ...

  6. thinkPHP CRUD操作

    数据访问 以 nation 表为例 方法一  => select() ①造模型对象 $naiton = D('Nation');   //也可以使用M()方法 ②查询所有 $a = $natio ...

  7. 蓝牙-HCI错误码列表

    错误码定义: /* Success code */ #define HCI_SUCCESS 0x00 /* Possible error codes */ #define HCI_UNKNOWN_HC ...

  8. Logistic回归分类算法原理分析与代码实现

    前言 本文将介绍机器学习分类算法中的Logistic回归分类算法并给出伪代码,Python代码实现. (说明:从本文开始,将接触到最优化算法相关的学习.旨在将这些最优化的算法用于训练出一个非线性的函数 ...

  9. Java方法调用中的别名处理

    将一个对象传递到方法内部时,也会产生别名现象.//: PassObject.java// Passing objects to methods can be a bit tricky62class L ...

  10. C++继承,多重继承,虚继承的构造函数以及析构函数的调用顺序问题

    #include <iostream> using namespace std; class A{ int data_a; public: A(){ data_a = ; cout < ...