Change the dbinstance to F19
The current template is based on F17 which is eol. Closes-Bug #1215797 Change-Id: I888fba67dc8412c8b57243d76b45494a6beb91c4
This commit is contained in:
parent
13b7f54ad8
commit
3734484056
|
@ -34,37 +34,71 @@ Mappings:
|
|||
db.m2.4xlarge: {Instance: m2.4xlarge}
|
||||
|
||||
Resources:
|
||||
ServerSecurityGroup:
|
||||
Type: AWS::EC2::SecurityGroup
|
||||
Properties:
|
||||
GroupDescription: 'Enable SSH access'
|
||||
SecurityGroupIngress:
|
||||
- IpProtocol: icmp
|
||||
FromPort: '-1'
|
||||
ToPort: '-1'
|
||||
CidrIp: '0.0.0.0/0'
|
||||
- IpProtocol: tcp
|
||||
FromPort: '22'
|
||||
ToPort : '22'
|
||||
CidrIp : '0.0.0.0/0'
|
||||
- IpProtocol: tcp
|
||||
FromPort: {Ref: Port}
|
||||
ToPort : {Ref: Port}
|
||||
CidrIp : '0.0.0.0/0'
|
||||
DatabaseInstance:
|
||||
Type: AWS::EC2::Instance
|
||||
Metadata:
|
||||
AWS::CloudFormation::Init:
|
||||
config:
|
||||
files:
|
||||
/tmp/db_setup.sql:
|
||||
content:
|
||||
'Fn::Replace':
|
||||
- DBName: {Ref: DBName}
|
||||
MasterUserPassword: {Ref: MasterUserPassword}
|
||||
MasterUsername: {Ref: MasterUsername}
|
||||
- |
|
||||
CREATE DATABASE DBName;
|
||||
GRANT ALL PRIVILEGES ON DBName.* TO "MasterUsername"@"%"
|
||||
IDENTIFIED BY "MasterUserPassword";
|
||||
FLUSH PRIVILEGES;
|
||||
EXIT
|
||||
mode: '000644'
|
||||
owner: root
|
||||
group: root
|
||||
packages:
|
||||
yum:
|
||||
mysql : []
|
||||
mysql-server : []
|
||||
mariadb: []
|
||||
mariadb-server: []
|
||||
services:
|
||||
systemd:
|
||||
mysqld:
|
||||
enabled: true
|
||||
ensureRunning: true
|
||||
Properties:
|
||||
ImageId: F17-x86_64-cfntools
|
||||
ImageId: F19-x86_64-cfntools
|
||||
InstanceType: {'Fn::FindInMap': [DBInstanceToInstance,
|
||||
{Ref: DBInstanceClass}, Instance]}
|
||||
KeyName: {Ref: KeyName}
|
||||
|
||||
SecurityGroups: [{"Ref" : "ServerSecurityGroup"}]
|
||||
UserData:
|
||||
Fn::Base64:
|
||||
Fn::Replace:
|
||||
- 'AWS::StackName': {Ref: 'AWS::StackName'}
|
||||
'AWS::Region': {Ref: 'AWS::Region'}
|
||||
MasterUsername: {Ref: MasterUsername}
|
||||
MasterUserPassword: {Ref: MasterUserPassword}
|
||||
DBName: {Ref: DBName}
|
||||
WaitHandle: {Ref: WaitHandle}
|
||||
- |
|
||||
#!/bin/bash -v
|
||||
#
|
||||
iptables -F
|
||||
|
||||
# Helper function
|
||||
function error_exit
|
||||
{
|
||||
|
@ -74,13 +108,8 @@ Resources:
|
|||
/opt/aws/bin/cfn-init -s AWS::StackName -r DatabaseInstance --region AWS::Region || error_exit 'Failed to run cfn-init'
|
||||
# Setup MySQL root password and create a user
|
||||
mysqladmin -u root password 'MasterUserPassword'
|
||||
cat << EOF | mysql -u root --password='MasterUserPassword'
|
||||
CREATE DATABASE DBName;
|
||||
GRANT ALL PRIVILEGES ON DBName.* TO "MasterUsername"@"%"
|
||||
IDENTIFIED BY "MasterUserPassword";
|
||||
FLUSH PRIVILEGES;
|
||||
EXIT
|
||||
EOF
|
||||
mysql -u root --password='MasterUserPassword' < /tmp/db_setup.sql || error_exit 'Failed to setup mysql'
|
||||
|
||||
# Database setup completed, signal success
|
||||
/opt/aws/bin/cfn-signal -e 0 -r "MySQL server setup complete" 'WaitHandle'
|
||||
|
||||
|
|
Loading…
Reference in New Issue