├── .gitignore ├── amazon-s3 ├── .DS_Store ├── fruit-images.zip └── index.html ├── aws-cloudformation ├── .DS_Store ├── 1-ec2-template.yml ├── 2-ec2-template.yml ├── 3-ec2-template.yml └── vpc-with-cloudformation.yml ├── amazon-ec2 ├── generate-load-on-alb.md └── user-data-web-server.sh ├── aws-iam └── sts-assume-role.json ├── amazon-vpc ├── user-data-simple-website.sh └── custom-vpc.md ├── serverless-app ├── ProcessOrderFunction.py ├── SubmitOrderFunction.py ├── index.html └── serverless-app-instructions.md ├── amazon-eventbridge └── stop-instance-not-t2-micro.py ├── amazon-ebs ├── user-data-custom-ami.sh └── amazon-ebs-volumes.md ├── aws-ml-and-ai └── process-analyze-images.md ├── amazon-efs └── working-with-efs.md ├── README.md ├── aws-lambda └── working-with-lambda.md └── amazon-dynamodb ├── create-table-add-data.md └── batch-write.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /amazon-s3/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ushev-s/aws_course/main/amazon-s3/.DS_Store -------------------------------------------------------------------------------- /amazon-s3/fruit-images.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ushev-s/aws_course/main/amazon-s3/fruit-images.zip -------------------------------------------------------------------------------- /aws-cloudformation/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ushev-s/aws_course/main/aws-cloudformation/.DS_Store -------------------------------------------------------------------------------- /amazon-ec2/generate-load-on-alb.md: -------------------------------------------------------------------------------- 1 | # Command to generate load on the ALB 2 | 3 | ***replace with your alb dns name*** 4 | ```for i in {1..200}; do curl http://your-alb-address.com & done; wait``` 5 | -------------------------------------------------------------------------------- /aws-iam/sts-assume-role.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": { 4 | "Effect": "Allow", 5 | "Action": "sts:AssumeRole", 6 | "Resource": "arn:aws:iam::975050181034:role/ec2-role" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /amazon-vpc/user-data-simple-website.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update the system and install necessary packages 4 | yum update -y 5 | yum install -y httpd 6 | 7 | # Start the Apache server 8 | systemctl start httpd 9 | systemctl enable httpd -------------------------------------------------------------------------------- /aws-cloudformation/1-ec2-template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Description: Create an EC2 instance with a security group for SSH access 3 | Resources: 4 | InstanceSecurityGroup: 5 | Type: AWS::EC2::SecurityGroup 6 | Properties: 7 | GroupDescription: Enable SSH access 8 | SecurityGroupIngress: 9 | - IpProtocol: tcp 10 | FromPort: 22 11 | ToPort: 22 12 | CidrIp: 0.0.0.0/0 13 | MyInstance: 14 | Type: AWS::EC2::Instance 15 | Properties: 16 | ImageId: ami-0440d3b780d96b29d 17 | InstanceType: t2.micro 18 | SecurityGroups: 19 | - !Ref InstanceSecurityGroup -------------------------------------------------------------------------------- /serverless-app/ProcessOrderFunction.py: -------------------------------------------------------------------------------- 1 | import json 2 | import boto3 3 | from datetime import datetime 4 | 5 | dynamodb = boto3.resource('dynamodb') 6 | table_name = 'YOUR_DYNAMODB_TABLE_NAME' 7 | table = dynamodb.Table(table_name) 8 | 9 | def lambda_handler(event, context): 10 | for record in event['Records']: 11 | message_body = json.loads(record['body']) 12 | item = {'orderId': record['messageId'], 'productName': message_body['productName'], 'quantity': message_body['quantity'], 'orderDate': datetime.now().isoformat()} 13 | table.put_item(Item=item) 14 | return {'statusCode': 200, 'body': json.dumps({'message': 'Orders processed successfully'})} 15 | -------------------------------------------------------------------------------- /amazon-vpc/custom-vpc.md: -------------------------------------------------------------------------------- 1 | # Create VPC 2 | Name: MyVPC 3 | IPv4 CIDR Block: 10.0.0.0/16 4 | 5 | # Create Public and Private Subnets 6 | 7 | Name: Public-1A 8 | Availability Zone: us-east-1a 9 | IPv4 CIDR Block: 10.0.1.0/24 10 | 11 | Name: Public-1B 12 | Availability Zone: us-east-1b 13 | IPv4 CIDR Block: 10.0.2.0/24 14 | 15 | Name: Private-1A 16 | Availability Zone: us-east-1a 17 | IPv4 CIDR Block: 10.0.3.0/24 18 | 19 | Name: Private-1B 20 | Availability Zone: us-east-1b 21 | IPv4 CIDR Block: 10.0.4.0/24 22 | 23 | # Create private route table 24 | 25 | Name: Private-RT 26 | VPC: MyVPC 27 | Subnet associations: Private-1A, Private-1B 28 | 29 | # Create Internet Gateway 30 | 31 | Name: MyIGW 32 | VPC: MyVPC -------------------------------------------------------------------------------- /serverless-app/SubmitOrderFunction.py: -------------------------------------------------------------------------------- 1 | import json 2 | import boto3 3 | 4 | sqs = boto3.client('sqs') 5 | queue_url = 'YOUR_SQS_QUEUE_URL' 6 | 7 | def lambda_handler(event, context): 8 | try: 9 | order_details = json.loads(event['body']) 10 | response = sqs.send_message(QueueUrl=queue_url, MessageBody=json.dumps(order_details)) 11 | return {'statusCode': 200, 'headers': {'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Allow-Methods': 'OPTIONS,POST'}, 'body': json.dumps({'message': 'Order submitted to queue successfully'})} 12 | except Exception as e: 13 | return {'statusCode': 400, 'body': json.dumps({'error': str(e)})} 14 | -------------------------------------------------------------------------------- /amazon-eventbridge/stop-instance-not-t2-micro.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | import json 3 | 4 | def lambda_handler(event, context): 5 | ec2 = boto3.client('ec2') 6 | sns = boto3.client('sns') 7 | 8 | # Extract the instance ID from the event 9 | instance_id = event['detail']['instance-id'] 10 | instance_type = ec2.describe_instances(InstanceIds=[instance_id])['Reservations'][0]['Instances'][0]['InstanceType'] 11 | 12 | if instance_type != 't2.micro': 13 | # Stop the instance 14 | ec2.stop_instances(InstanceIds=[instance_id]) 15 | print(f"Instance {instance_id} stopped because it is not a t2.micro.") 16 | 17 | else: 18 | print(f"Instance {instance_id} is a t2.micro. No action taken.") 19 | 20 | return { 21 | 'statusCode': 200, 22 | 'body': json.dumps('Lambda function execution completed.') 23 | } 24 | -------------------------------------------------------------------------------- /aws-cloudformation/2-ec2-template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Description: Attach an EBS volume to the EC2 instance, retaining original resources 3 | Resources: 4 | InstanceSecurityGroup: 5 | Type: AWS::EC2::SecurityGroup 6 | Properties: 7 | GroupDescription: Enable SSH access 8 | SecurityGroupIngress: 9 | - IpProtocol: tcp 10 | FromPort: 22 11 | ToPort: 22 12 | CidrIp: 0.0.0.0/0 13 | MyInstance: 14 | Type: AWS::EC2::Instance 15 | Properties: 16 | ImageId: ami-0440d3b780d96b29d 17 | InstanceType: t2.micro 18 | SecurityGroups: 19 | - !Ref InstanceSecurityGroup 20 | MyVolume: 21 | Type: AWS::EC2::Volume 22 | Properties: 23 | AvailabilityZone: !GetAtt MyInstance.AvailabilityZone 24 | Size: 10 25 | MyVolumeAttachment: 26 | Type: AWS::EC2::VolumeAttachment 27 | Properties: 28 | InstanceId: !Ref MyInstance 29 | VolumeId: !Ref MyVolume 30 | Device: /dev/sdf -------------------------------------------------------------------------------- /aws-cloudformation/3-ec2-template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Description: Add an Amazon S3 bucket to the setup, retaining all previous resources 3 | 4 | Resources: 5 | InstanceSecurityGroup: 6 | Type: AWS::EC2::SecurityGroup 7 | Properties: 8 | GroupDescription: Enable SSH access 9 | SecurityGroupIngress: 10 | - IpProtocol: tcp 11 | FromPort: 22 12 | ToPort: 22 13 | CidrIp: 0.0.0.0/0 14 | 15 | MyInstance: 16 | Type: AWS::EC2::Instance 17 | Properties: 18 | ImageId: ami-0440d3b780d96b29d # Ensure this AMI ID is valid for your region 19 | InstanceType: t2.micro 20 | SecurityGroups: 21 | - !Ref InstanceSecurityGroup 22 | 23 | MyVolume: 24 | Type: AWS::EC2::Volume 25 | Properties: 26 | AvailabilityZone: !GetAtt MyInstance.AvailabilityZone 27 | Size: 10 28 | 29 | MyVolumeAttachment: 30 | Type: AWS::EC2::VolumeAttachment 31 | Properties: 32 | InstanceId: !Ref MyInstance 33 | VolumeId: !Ref MyVolume 34 | Device: /dev/sdf 35 | 36 | MyS3Bucket: 37 | Type: AWS::S3::Bucket 38 | Properties: 39 | BucketName: my-unique-bucket-name-4rw3dda34 # Ensure this is globally unique -------------------------------------------------------------------------------- /amazon-ebs/user-data-custom-ami.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update the system and install Apache web server 4 | yum update -y 5 | yum install -y httpd 6 | 7 | # Start and enable Apache to run on boot 8 | systemctl start httpd 9 | systemctl enable httpd 10 | 11 | # Create an index.html file with CSS animations for background color changing 12 | cat > /var/www/html/index.html <<'EOF' 13 | 14 | 15 |
16 | 17 |