File size: 1,720 Bytes
1d97dbc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
EC2 Instance Configuration Templates
"""

# Instance configurations for different use cases
INSTANCE_CONFIGS = {
    'web_server': {
        'name': 'WebServer-Production',
        'ami_id': 'ami-0c55b159cbfafe1f0',  # Amazon Linux 2 AMI
        'instance_type': 't3.medium',
        'key_name': 'production-key',
        'security_groups': ['sg-0123456789abcdef0'],
        'environment': 'production'
    },
    
    'database': {
        'name': 'Database-MySQL',
        'ami_id': 'ami-0c55b159cbfafe1f0',
        'instance_type': 't3.large',
        'key_name': 'production-key',
        'security_groups': ['sg-0123456789abcdef1'],
        'environment': 'production'
    },
    
    'dev_server': {
        'name': 'DevServer-Testing',
        'ami_id': 'ami-0c55b159cbfafe1f0',
        'instance_type': 't3.small',
        'key_name': 'dev-key',
        'security_groups': ['sg-0123456789abcdef2'],
        'environment': 'development'
    },
    
    'worker': {
        'name': 'Worker-Node',
        'ami_id': 'ami-0c55b159cbfafe1f0',
        'instance_type': 't3.micro',
        'key_name': 'worker-key',
        'security_groups': ['sg-0123456789abcdef3'],
        'environment': 'production'
    }
}

# User data scripts for instance initialization
USER_DATA_SCRIPTS = {
    'web_server': """#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Web Server Running</h1>" > /var/www/html/index.html
""",
    
    'database': """#!/bin/bash
yum update -y
yum install -y mysql-server
systemctl start mysqld
systemctl enable mysqld
""",
    
    'worker': """#!/bin/bash
yum update -y
yum install -y python3 python3-pip
pip3 install boto3 celery redis
"""
}