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 PublicSubnet
- NetworkInterfaces:
- - NetworkInterfaceId:
- Ref: NetworkInterfaceAttachmentForPublicUbuntu
- DeviceIndex: '0'
- NetworkInterfaceAttachmentForPublicUbuntu:
- Type: AWS::EC2::NetworkInterfaceAttachment
- Properties:
- DeviceIndex: '0'
- InstanceId: !Ref MyPublicUbuntu
- NetworkInterfaceId:
- Ref: NetworkInterfaceForPublicUbuntu
- NetworkInterfaceForPublicUbuntu:
- Type: AWS::EC2::NetworkInterface
- Properties:
- Description: Public IP of Ubuntu instance
- SubnetId: !Ref PublicSubnet
- GroupSet:
- - !Ref SSHSecurityGroup
- - !Ref HTTPSecurityGroup
- SSHSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Enable SSH access via port 22
- VpcId: !Ref VPC
- SecurityGroupIngress:
- - CidrIp: 0.0.0.0/0
- FromPort: 22
- IpProtocol: tcp
- ToPort: 22
- HTTPSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Enable HTTP access via port 80
- VpcId: !Ref VPC
- SecurityGroupIngress:
- - CidrIp: 0.0.0.0/0
- FromPort: 80
- IpProtocol: tcp
- ToPort: 80
- PublicSubnet:
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref VPC
- AvailabilityZone: eu-central-1a
- CidrBlock: 10.0.1.0/24
- MapPublicIpOnLaunch: true
- Tags:
- - Key: Name
- Value: !Sub ${EnvironmentName} Public Subnet (AZ1)
- PrivateSubnet:
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref VPC
- AvailabilityZone: eu-central-1a
- CidrBlock: 10.0.2.0/24
- MapPublicIpOnLaunch: false
- Tags:
- - Key: Name
- Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
- InternetGateway:
- Type: AWS::EC2::InternetGateway
- Properties:
- Tags:
- - Key: Name
- Value: !Ref EnvironmentName
- InternetGatewayAttachment:
- Type: AWS::EC2::VPCGatewayAttachment
- Properties:
- InternetGatewayId: !Ref InternetGateway
- VpcId: !Ref VPC
- NatGatewayEIP:
- Type: AWS::EC2::EIP
- DependsOn: InternetGatewayAttachment
- Properties:
- Domain: vpc
- NatGateway:
- Type: AWS::EC2::NatGateway
- Properties:
- AllocationId: !GetAtt NatGatewayEIP.AllocationId
- SubnetId: !Ref PublicSubnet
- 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: 0.0.0.0/0
- GatewayId: !Ref InternetGateway
- PublicSubnetRouteTableAssociation:
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- RouteTableId: !Ref PublicRouteTable
- SubnetId: !Ref PublicSubnet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement