mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
Merge 50f5078608db94d55fa1b79a4e3eec03bb8c710d into 20720ca4f9175373ee8075fc18ce823707350534
This commit is contained in:
commit
57fdf4f219
92
multipleenvt.yml
Normal file
92
multipleenvt.yml
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
AWSTemplateFormatVersion:
|
||||||
|
'2010-09-09'
|
||||||
|
Description: AWS CloudFormation Template for Dev,Stage,Prod Enviornments
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
Enviornment:
|
||||||
|
Description: The enviornment to deploy(dev,stage.prod)
|
||||||
|
Type: String
|
||||||
|
AllowedValues:
|
||||||
|
:dev
|
||||||
|
:stage
|
||||||
|
:prod
|
||||||
|
Default:dev
|
||||||
|
|
||||||
|
Resources:
|
||||||
|
MyVPC:
|
||||||
|
Type: AWS::EC2::VPC
|
||||||
|
Properties:
|
||||||
|
CidrBlock:!If
|
||||||
|
:lsProd
|
||||||
|
:10.0.0.0/16
|
||||||
|
:!If
|
||||||
|
:lsStage
|
||||||
|
:10.1.0.0/16
|
||||||
|
:10.2.0.0/16
|
||||||
|
EnableDnsSupport:true
|
||||||
|
EnableDnsHostnames:true
|
||||||
|
Tags:
|
||||||
|
Key:Name
|
||||||
|
Value:!Sub"${Enviornment}-vpc"
|
||||||
|
MyInternetGateway:
|
||||||
|
Type: AWS::EC2::InternetGateway
|
||||||
|
AttachGateway:
|
||||||
|
Type:
|
||||||
|
AWS::EC2::VPCGatewayAttachment
|
||||||
|
Properties:
|
||||||
|
VpcId:!Ref MyVPC
|
||||||
|
InternetGatewayId:!Ref MyInternetGateway
|
||||||
|
PublicSubnet:
|
||||||
|
Type: AWS::EC2::Subnet
|
||||||
|
Properties:
|
||||||
|
VpcId: !Ref MyVPC
|
||||||
|
CidrBlock:!If
|
||||||
|
:lsProd
|
||||||
|
:10.0.1.0/24
|
||||||
|
:!If
|
||||||
|
:lsStage
|
||||||
|
:10.1.1.0/24
|
||||||
|
:10.2.1.0/24
|
||||||
|
MapPublicIpOnLaunch:true
|
||||||
|
AvailabilityZone:!Select[0,!GETAZs"]
|
||||||
|
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 MyInternetGateway
|
||||||
|
PublicSubnetRouteTableAssociation:
|
||||||
|
Type: AWS::EC2::SubnetRouteTableAssociation
|
||||||
|
Properties:
|
||||||
|
SubnetId:!Ref PublicSubnet
|
||||||
|
RouteTableId: !Ref PublicRouteTable
|
||||||
|
MyEC2Instance:
|
||||||
|
Type: AWS::EC2::Instance
|
||||||
|
Properties:
|
||||||
|
InstanceType:t2.micro
|
||||||
|
ImageId:ami-
|
||||||
|
SubnetId:!Ref PublicSubnet
|
||||||
|
KeyName:my-key
|
||||||
|
Tags:
|
||||||
|
Key:Name
|
||||||
|
Value:!Sub"${Enviornment}-instance"
|
||||||
|
Conditions:
|
||||||
|
lsProd:!Equals[!Ref Enviornment,prod]
|
||||||
|
lsStage:!Equals[!Ref Envionment,stage]
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
VPCId:
|
||||||
|
Description:VPC Id
|
||||||
|
Value:!Ref MyVPC
|
||||||
|
SubnetId:
|
||||||
|
Description:PublicSubnetId
|
||||||
|
Value:!Ref PublicSubnet
|
||||||
|
InstanceId:
|
||||||
|
Description:EC2InstanceId
|
||||||
|
Value:!Ref MyEC2Instance
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user