Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parameters:
- EnvironmentName:
- Description: KaspersEnvironment
- Type: String
- Resources:
- VPC:
- Type: AWS::EC2::VPC
- Properties:
- CidrBlock: 10.0.0.0/16
- EnableDnsSupport: false
- EnableDnsHostnames: false
- Tags:
- - Key: Name
- Value: !Ref EnvironmentName
- MyPublicUbuntu:
- Type: AWS::EC2::Instance
- Properties:
- AvailabilityZone: eu-central-1a # Frankfurt
- ImageId: "ami-0ac05733838eabc06" # Free Tier Ubuntu
- InstanceType: t2.micro
- SubnetID: !Ref PublicSubnet1
- SSHSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Enable SSH access via port 22
- VpcId: !Ref VPC
- SecurityGroupIngress:
- - CidrIp: 10.0.0.0/16
- FromPort: 22
- IpProtocol: tcp
- ToPort: 22
- HTTPSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Enable HTTP access via port 80
- VpcId: !Ref VPC
- SecurityGroupIngress:
- - CidrIp: 10.0.0.0/16
- FromPort: 80
- IpProtocol: tcp
- ToPort: 80
- InternetGateway:
- Type: AWS::EC2::InternetGateway
- Properties:
- Tags:
- - Key: Name
- Value: !Ref EnvironmentName
- InternetGatewayAttachment:
- Type: AWS::EC2::VPCGatewayAttachment
- Properties:
- InternetGatewayId: !Ref InternetGateway
- VpcId: !Ref VPC
- PublicSubnet1:
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref VPC
- AvailabilityZone: !Select [0, !GetAZs ""]
- CidrBlock: 10.0.1.0/24
- MapPublicIpOnLaunch: true
- Tags:
- - Key: Name
- Value: !Sub ${EnvironmentName} Public Subnet (AZ1)
- PrivateSubnet1:
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref VPC
- AvailabilityZone: !Select [0, !GetAZs ""]
- CidrBlock: 10.0.2.0/24
- MapPublicIpOnLaunch: false
- Tags:
- - Key: Name
- Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
- InternetGatewayAttachment:
- Type: AWS::EC2::VPCGatewayAttachment
- Properties:
- InternetGatewayId: !Ref InternetGateway
- VpcId: !Ref VPC
- NatGateway1EIP:
- Type: AWS::EC2::EIP
- DependsOn: InternetGatewayAttachment
- Properties:
- Domain: vpc
- NatGateway1:
- Type: AWS::EC2::NatGateway
- Properties:
- AllocationId: !GetAtt NatGateway1EIP.AllocationId
- SubnetId: !Ref PublicSubnet1
- PublicRouteTable:
- Type: AWS::EC2::RouteTable
- Properties:
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub ${EnvironmentName} Public Routes
- DefaultPublicRoute:
- Type: AWS::EC2::Route
- DependsOn: InternetGatewayAttachment
- Properties:
- RouteTableId: !Ref PublicRouteTable
- DestinationCidrBlock: 10.0.1.0/0
- GatewayId: !Ref InternetGateway
- PublicSubnet1RouteTableAssociation:
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- RouteTableId: !Ref PublicRouteTable
- SubnetId: !Ref PublicSubnet1
- PrivateRouteTable1:
- Type: AWS::EC2::RouteTable
- Properties:
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub ${EnvironmentName} Private Routes (AZ1)
- DefaultPrivateRoute1:
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref PrivateRouteTable1
- DestinationCidrBlock: 10.0.2.0/0
- NatGatewayId: !Ref NatGateway1
- PrivateSubnet1RouteTableAssociation:
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- RouteTableId: !Ref PrivateRouteTable1
- SubnetId: !Ref PrivateSubnet1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement