Skip to content

Instantly share code, notes, and snippets.

@tomstorms
Last active December 27, 2021 03:46
Show Gist options
  • Save tomstorms/286f027ccacac62b8228a31a3a2f955d to your computer and use it in GitHub Desktop.
Save tomstorms/286f027ccacac62b8228a31a3a2f955d to your computer and use it in GitHub Desktop.
#-----------------------------------------------------
# Terminology:
EC2 = Server instances
EC2 Security Groups = Controls SSH access
WAF = Website Application Firewall - controls wp-admin access
#-----------------------------------------------------
# If restricted by IP check these places:
- Go to EC2 > Load Balancers > Search for "AWS WAF Web ACL" and follow link > IP Addresses > ClubPlusWafRestrictedAreaWhitelistedIPSet and add your IP
- Network & Security > Find the Security Group > Inbound Tab > Edit to add/update your IP address
#-----------------------------------------------------
# To clone an EC2 instance:
- EC2 > Actions > Image and templates > Create image
- Enter an 'Image name' and 'create image' - can leave all default settings
- Click the link in the green banner that confirms the image was created and click through to view the cloning process
- Once the image is ready, click Launch Instance and select the same image instance
- Double check the Security Groups to make sure the server is accessible
#-----------------------------------------------------
# Setup Elastic IP
- Use an Elastic IP to create a static IP address for your EC2 instance (recommended)
- 'Allocate Elastic IP address' then 'Allocate' - this will create the IP address
- Go to EC2 and find the server instance
- Actions > Networking > Associate Elastic IP address
#-----------------------------------------------------
# Setup sub domain
- Route 53 > create a record
- Record name = sub domain
- Set the value to be the elastic IP address of your instance
- Set TTL to 60
#-----------------------------------------------------
# Commands to sync files with a bucket
aws s3 ls s3://my-website.com
aws s3 cp test_file s3://my-website.com
aws s3api get-object --bucket my-website.com --key test_file test_file_got
aws s3 rm s3://my-website.com/test_file
#-----------------------------------------------------
# Increase disk space (Elastic Block Storage):
#
# See: https://aws.amazon.com/premiumsupport/knowledge-center/ebs-volume-size-increase/
#
- Log into the AWS console
- "Modify Volume" under AWS Elastic Block Store to increase the disk space size
- Wait for optimization to complete
- lsblk - this will verify the assigned size is available
[email protected]:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 100G 0 disk
└─xvda1 202:1 0 30G 0 part /
- growpart /dev/xvda 1
[email protected]:~# growpart /dev/xvda 1
CHANGED: partition=1 start=16065 old: size=62898462 end=62914527 new: size=209699102,end=209715167
- resize2fs /dev/xvda1
[email protected]:~# resize2fs /dev/xvda1
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 7
The filesystem on /dev/xvda1 is now 26212387 (4k) blocks long.
- df -h
[email protected]:~# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/xvda1 99G 26G 69G 27% /
New disk size should be reflected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment