{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "Simple Wordpress", | |
"Parameters": { | |
"VPC": { | |
"Description": "The default VPC", | |
"Type": "AWS::EC2::VPC::Id" | |
}, | |
"Subnets": { | |
"Description": "At least two public subnets from default VPC.", | |
"Type": "List<AWS::EC2::Subnet::Id>" | |
} | |
}, | |
"Mappings": { | |
"RegionMap": { | |
"eu-west-1": {"AMI": "ami-bff32ccc"}, | |
"ap-southeast-1": {"AMI": "ami-c9b572aa"}, | |
"ap-southeast-2": {"AMI": "ami-48d38c2b"}, | |
"eu-central-1": {"AMI": "ami-bc5b48d0"}, | |
"ap-northeast-2": {"AMI": "ami-249b554a"}, | |
"ap-northeast-1": {"AMI": "ami-383c1956"}, | |
"us-east-1": {"AMI": "ami-60b6c60a"}, | |
"sa-east-1": {"AMI": "ami-6817af04"}, | |
"us-west-1": {"AMI": "ami-d5ea86b5"}, | |
"us-west-2": {"AMI": "ami-f0091d91"}, | |
"ap-south-1": {"AMI": "ami-5b673c34"} | |
} | |
}, | |
"Resources": { | |
"EC2Instance": { | |
"Type": "AWS::EC2::Instance", | |
"Properties": { | |
"ImageId": {"Fn::FindInMap": ["RegionMap", {"Ref": "AWS::Region"}, "AMI"]}, | |
"InstanceType": "t2.nano", | |
"NetworkInterfaces": [{ | |
"AssociatePublicIpAddress": "true", | |
"DeviceIndex": "0", | |
"GroupSet": [{"Ref": "WebserverSecurityGroup"}], | |
"SubnetId": {"Fn::Select": ["0", {"Ref": "Subnets"}]} | |
}], | |
"Tags": [{ | |
"Key": "Name", | |
"Value": "simple-wordpress" | |
}], | |
"UserData": {"Fn::Base64": {"Fn::Join": ["", [ | |
"#!/bin/bash -ex\n", | |
"yum install -y php php-mysql mysql httpd\n", | |
"cd /var/www/html\n", | |
"curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar\n", | |
"php wp-cli.phar core download\n", | |
"php wp-cli.phar core config --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=", {"Fn::GetAtt": ["Database", "Endpoint.Address"]}, "\n", | |
"php wp-cli.phar core install --url=http://$(curl http://169.254.169.254/latest/meta-data/public-hostname) --title=DevOps School -Blog --admin_user=admin --admin_password=UBeDzefeX3jihRQUkrGwj2qYWnyBcp --admin_email=adam@globomatics.com --skip-email\n", | |
"rm wp-cli.phar\n", | |
"service httpd start\n" | |
]]}} | |
} | |
}, | |
"DBSubnetGroup": { | |
"Type": "AWS::RDS::DBSubnetGroup", | |
"Properties": { | |
"DBSubnetGroupDescription": "DB subnet group", | |
"SubnetIds": {"Ref": "Subnets"} | |
} | |
}, | |
"Database": { | |
"Type": "AWS::RDS::DBInstance", | |
"Properties": { | |
"AllocatedStorage": "5", | |
"DBInstanceClass": "db.t2.micro", | |
"DBInstanceIdentifier": "simple-wordpress", | |
"DBName": "wordpress", | |
"Engine": "MySQL", | |
"MasterUsername": "wordpress", | |
"MasterUserPassword": "wordpress", | |
"VPCSecurityGroups": [{"Fn::GetAtt": ["DatabaseSecurityGroup", "GroupId"]}], | |
"DBSubnetGroupName": {"Ref": "DBSubnetGroup"}, | |
"StorageType": "gp2" | |
} | |
}, | |
"WebserverSecurityGroup": { | |
"Type": "AWS::EC2::SecurityGroup", | |
"Properties": { | |
"GroupDescription": "simple-wordpress-webserver", | |
"VpcId": {"Ref": "VPC"}, | |
"SecurityGroupIngress": [{ | |
"CidrIp": "0.0.0.0/0", | |
"FromPort": 80, | |
"IpProtocol": "tcp", | |
"ToPort": 80 | |
}] | |
} | |
}, | |
"DatabaseSecurityGroup": { | |
"Type": "AWS::EC2::SecurityGroup", | |
"Properties": { | |
"GroupDescription": "simple-wordpress-database", | |
"VpcId": {"Ref": "VPC"}, | |
"SecurityGroupIngress": [{ | |
"IpProtocol": "tcp", | |
"FromPort": "3306", | |
"ToPort": "3306", | |
"SourceSecurityGroupId": {"Ref": "WebserverSecurityGroup"} | |
}] | |
} | |
} | |
}, | |
"Outputs": { | |
"WordpressURL": { | |
"Description": "The URL of the simple Wordpress environment.", | |
"Value": {"Fn::Join": ["", ["http://", {"Fn::GetAtt": ["EC2Instance", "PublicIp"]}]]} | |
} | |
} | |
} |









I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND