Currently i am trying to achive that a user sign up on my website after that Enter their AWS Access Key and Secret key.
After AWS Key verification, there is a form for asking the user Select Region > Select Number of Visitors, Enter Domain Name, SSL Checkbox & done.
After this i am trying to Launch EC2 Instance on selected region, and instance family is depend on the Number of visitors.
and for myself, i am using BOTO3 to automate this.
How can we do this for user because we need to change AWS Access & Secret keys
Do we need to save keys with different profile name?
One more thing, How can i add Domain name because currently my bash script is installing wordpress on the public IP, Can we also change Domain name?
#!/bin/bash
# Update the package index
apt update
# Install Apache
apt install -y apache2
# Pre-configure MySQL root password and install MySQL in a non-interactive mode
export DEBIAN_FRONTEND=noninteractive
echo "mysql-server mysql-server/root_password password Password@" | debconf-set-selections
echo "mysql-server mysql-server/root_password_again password Password@" | debconf-set-selections
apt install -y mysql-server
# Verify MySQL installation and set the root password if needed
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password@'; FLUSH PRIVILEGES;" || true
# Install PHP and required modules
apt install -y php libapache2-mod-php php-mysql php-curl php-json php-cgi
# Download WordPress
wget -c http://wordpress.org/latest.tar.gz
# Extract WordPress
tar -xzvf latest.tar.gz
# Move WordPress files to the Apache root directory
rsync -av wordpress/* /var/www/html/
# Remove default Apache index.html page
rm /var/www/html/index.html
# Set permissions
chown -R www-data:www-data /var/www/html/
chmod -R 755 /var/www/html/
# Create WordPress configuration file
cd /var/www/html/
cp wp-config-sample.php wp-config.php
# Configure WordPress to connect to the database
sed -i "s/database_name_here/wordpress_db/" wp-config.php
sed -i "s/username_here/wordpress_user/" wp-config.php
sed -i "s/password_here/Password@/" wp-config.php
# Restart Apache to apply changes
systemctl restart apache2
# Create the WordPress database and user
mysql -u root -Password@ -e "CREATE DATABASE wordpress_db;"
mysql -u root -Password@ -e "CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'Mouse54321@';"
mysql -u root -Password@ -e "GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';"
mysql -u root -Password@ -e "FLUSH PRIVILEGES;"
# Clean up
rm -rf wordpress latest.tar.gz
and i saved this script under UserData while launching EC2 Instance.
Trying to install WordPress on EC2 and also launch Ec2 instance same time on my user AWS account (After Authenticate AWS account from their Access key and Secret Key.