Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
80 lines (75 sloc) 2.26 KB
AWSTemplateFormatVersion: "2010-09-09"
Description: "Packet Capture: Test Web Server"
Parameters:
ParamAmi:
Type: String
ParamInstanceType:
Type: String
Default: "t2.micro"
ParamStackName:
Type: String
Description: "Name used in resource tags and names"
ParamKeyName:
Type: String
Description: "EC2 Key Pair name for CLI Commands over SSH"
Resources:
WebServerNetworkInterface:
Type: "AWS::EC2::NetworkInterface"
Properties:
Description: Web Server Network Interface
GroupSet:
- !ImportValue WebServerSecurityGroup
- !ImportValue S3CidrSecurityGroup
- !ImportValue SSHAdminSecurityGroup
SubnetId: !ImportValue WebServerSubnet
SourceDestCheck: false
Tags:
- Key: Name
Value: WebServerEni
- Key: Stack
Value: !Ref ParamStackName
WebServer:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !Ref ParamAmi
InstanceType: !Ref ParamInstanceType
KeyName: !Ref ParamKeyName
NetworkInterfaces:
- NetworkInterfaceId:
Ref: WebServerNetworkInterface
DeviceIndex: '0'
UserData:
Fn::Base64:
!Sub
- |
#!/bin/bash -xe
service ntpd stop
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
ntpsrv="amazon.pool.ntp.org"
sed -i "s/0.$ntpsrv/${fireboxmanagementip}/g" /etc/ntp.conf
sed -i "s/server 1.$ntpsrv iburst//g" /etc/ntp.conf
sed -i "s/server 2.$ntpsrv iburst//g" /etc/ntp.conf
sed -i "s/server 3.$ntpsrv iburst//g" /etc/ntp.conf
cat /etc/ntp.conf
service ntpd start
yum update
yum -y install httpd
service httpd start
ntpstat
-
fireboxmanagementip:
'Fn::ImportValue': 'FireboxPrimaryWebServerIpAddress'
Tags:
- Key: Name
Value: TestWebServer
- Key: Stack
Value: !Ref ParamStackName
Outputs:
WebServer:
Value: !Ref WebServer
Export:
Name: "WebServer"
WebServerIPAddress:
Value: !GetAtt WebServer.PrivateIp
Export:
Name: "WebServerIPAddress"