Operations Playbook Template
Operations Playbook Template
Mike Stewart
IFT 562
Contents
How to connect to the Mom & Pop Cafe Test EC2 instance.......................................................4
How to make a modification to the lab policy using the AWS CLI............................................4
How to add a parameter to the parameter store for allowing cookies on the website..................4
How to create two subnets in a subnet group via the AWS CLI.................................................4
How to use the mysqldump tool to take a backup of a SQL database and restore it on another
SQL instance................................................................................................................................5
How to enable VPC Flow Logs via the command line interface.................................................5
How to synchronize files using the command line (aws s3api and aws s3)................................5
How to create a batch file to update the café website to change its colors..................................5
How to add a bastion host (Linux) to the public subnet of a VPC to connect to instances in the
private subnet...............................................................................................................................6
How to setup IAM so a user can assume an IAM role to access a resource................................6
How to add inbound rules to both security groups and network ACLs.......................................6
How to add a parameter to the parameter store for allowing cookies on the website
aws ssm put-parameter \ --name "/website/allowCookies" \ --value "true" \ --type "String" \ --overwrite
How to create two subnets in a subnet group via the AWS CLI
1. aws ec2 create-subnet \ --vpc-id <vpc-id> \ --cidr-block <subnet1-cidr-block> \ --availability-zone
<az1>
2. aws ec2 create-subnet \ --vpc-id <vpc-id> \ --cidr-block <subnet2-cidr-block> \ --availability-zone
<az2>
How to use the mysqldump tool to take a backup of a SQL database and restore it on another
SQL instance
Backup the database:
mysqldump -u <user> -p <database_name> > backup.sql
How to enable VPC Flow Logs via the command line interface
Steps:
Example Command
How to synchronize files using the command line (aws s3api and aws s3)
1. Enable versioning for your S3 bucket:
aws s3 ls s3://<S3-BUCKET-NAME>/<S3-PATH>/
Example Command:
aws s3 ls s3://mike-aws-bucket-2024/files/
This lists all files in the specified S3 path.
Command
Replace <bucket-name> with a unique name and <region> with the AWS region (e.g., us-east-
1).
Example
Replace <ARN of SNS topic> with your actual SNS Topic ARN.
3. Save and close the file. If using vi, you would press ESC and type :wq.
4. Associate the event notification with the S3 bucket using the following AWS CLI
command:
aws s3api put-bucket-notification-configuration --bucket <bucket-name> --
notification-configuration file://s3EventNotification.json
Replace <bucket-name> with your S3 bucket name.
5. Example
aws s3api put-bucket-notification-configuration --bucket my-unique-bucket-123 --
notification-configuration file://s3EventNotification.json
6. Check SNS for notifications: You should receive a notification whenever objects are
created or deleted in the specified folder within the bucket.
How to install the CloudWatch Agent
1. Log into AWS Management Console and navigate to Systems Manager under the
Services menu.
2. In the left navigation pane, select Run Command under Node Management.
3. Choose Run a Command and select the AWS-ConfigureAWSPackage command.
4. Configure the following:
Action: Install
Name: AmazonCloudWatchAgent
Version: latest
5. In the Targets section, manually select the instances (such as the Web Server).
6. Click Run and wait for the status to change to Success.
7. To confirm installation, view the output and check for the message: Successfully installed
arn:aws:ssm:::package/AmazonCloudWatchAgent.
How to create a CloudWatch Events/CloudWatch EventBridge notification rule
1. Log into AWS Management Console and navigate to CloudWatch.
2. In the left navigation pane, choose Rules under Events.
3. Choose Create rule.
4. Configure the following:
Event source: AWS services
AWS service: EC2
Event type: EC2 Instance State-change Notification
Select Specific state(s) and choose stopped and terminated.
5. Under Targets, select SNS topic and choose or create a topic.
6. Review the settings and choose Create rule.
7. Your rule will now send notifications when an EC2 instance is stopped or terminated.
How to use the prebuilt stopinator script to turn off instances with the tag value of your full name
Task 1: Using Tags to Manage Resources
1. Connect to Command Host (EC2) via SSH (use PuTTY for Windows or Terminal
for Mac/Linux).
2. Find EC2 Instances by Tag:
Run this AWS CLI command to find instances with a specific project tag:
aws ec2 describe-instances --filter "Name=tag:Project,Values=ERPSystem" --
query 'Reservations[*].Instances[*].
{ID:InstanceId,AZ:Placement.AvailabilityZone}'
3. Update Tags:
./change-resource-tags.sh
Go to the EC2 Management Console and remove the Environment tag from two
instances in the private subnet.
Run the terminate-instances.php script with the proper region and subnet:
2. Wait for the Instance to Stop: Check the instance state to ensure it is stopped.
3. Resize the EC2 Instance: Replace t2.micro with your desired instance type.
After the detection completes, the drift status for the stack will be displayed (e.g., IN_SYNC or DRIFTED).
Click on the stack to view details about which resources have drifted and how they differ from the
template.
1. In the AWS Management Console, search for and select the CloudTrail service.
4. Analyze the CREATE TABLE SQL generated statement to confirm the structure.
1. Use the AWS CLI to filter through CloudTrail logs with specific commands such as:
region=$(curl
http://169.254.169.254/latest/dynamic/instance-identity/document | grep
region | cut -d '"' -f4)
echo $sgId
@echo off
echo Updating Café website colors...
copy /Y "new-styles.css" "C:\path\to\website\styles.css"
echo Colors updated successfully.
pause
bash
Copy code
mkdir python
pip install requests -t python/
zip -r layer.zip python/
2. Create the Lambda Layer in AWS:
--runtime python3.9 \
--role <role-arn> \
--handler lambda_function.lambda_handler \
--zip-file fileb://function.zip
How to add a bastion host (Linux) to the public subnet of a VPC to connect to instances in the
private subnet
1. Launch an EC2 instance in the public subnet of your VPC.
2. Assign the instance a public IP address.
3. Install SSH and configure security groups to allow SSH access (port 22) from your IP.
How to setup IAM so a user can assume an IAM role to access a resource
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "<user-arn>"
},
"Action": "sts:AssumeRole"
}
]
}
Provide the user with the following CLI command to assume the role:
How to add inbound rules to both security groups and network ACLs
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::account-id:role/RoleName"
}
]
}
Replace account-id and RoleName.
The user can use the AWS CLI to assume the role with: