manishawsdevops / aws-devops-learning

This repository consists of training material and examples related for AWS DevOps and python.
Apache License 2.0
0 stars 0 forks source link

AWS Services - EC2, S3 and so on #6

Open manishawsdevops opened 1 year ago

manishawsdevops commented 1 year ago

UserData:

#!/bin/bash
yum install httpd -y
systemctl start httpd
systemctl enable httpd
systemctl status httpd
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id)
echo "<h1>$instanceId</h1>" > /var/www/html/index.html

Simple HTML File

<!DOCTYPE html>
<html>
<head>
    <title>Hello, World!</title>
</head>
<body>
    <h1>Hello, World!</h1>
</body>
</html>

Bucket Policy for granting S3 bucket webhosting access.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::Bucket-Name/*"
            ]
        }
    ]
}