Posts in AWS

10 tools for cloud admins

As a cloud admin your work is broad and you need tools to improve your work and efficiency.

Here’s the best 10 tools in my opinion every cloud admin should have in their tool belt, or their laptop in our case.

This is my list and the best tools in my opinion.

Code

1. VS Code is one of the popular code editors and it is my preferred code editor, it has many plugins and you can customize it to your preferences

2. Python is the easiest and most robust coding tool for cloud admins, with plugin support to almost any cloud.
no need for introduction here

3. boto3 is specific for AWS but still worth mentioning if you’re using AWS as your cloud.
it have a very good documentation and does the job, it’s very important when you integrate automation with your projects.

Servers

4. Docker is by far the fastest way to install something, it’s just docker run image-name and the app is installed, although it’s not recommended for production it is suitable for IT servers, just remember to backup the volumes.

5. OpenVpn is a great tool to encrypt the connection to your servers, it can also save some public IP addresses since you connect to the server’s private IP addresses.

6. Sensu is great to know what’s up with your servers, get the metric you want to know and get alerts for something you need to know

7. Puppet is your preferred option if you don’t use Docker in your servers, it can configure your servers and maintain a state for your servers, easy to use and plenty of modules to choose from.

Misc

8. Zsh is better then the default terminal consoles and is can be used in your laptop and in your servers, install it on your servers as well to get the experience you get on your laptop.

9. Let’s Encrypt made it so easy to secure your public connections to your apps, there’s is really no reason why not to use it for your apps.

10. KeePass is a password manager that you need because you connect to many servers and services and it’s a great tool for this task, just remember to backup KeePass database.

What is a cloud administrator

these days it’s very easy to confuse job description especially when you just starting learning about an occupation that you’re interested in.

adding to the problem it’s very interesting how every company has different requirements for the “same” role, so now it’s more confusing.

So what a cloud administrator does?

take the following explanation with a pinch of salt, why? because each company wants different things and have different approach so don’t get into specific topics and technologies.

A Cloud Administrator is responsible for computing resources and SAAS accounts the company is using.

Example of Cloud Administrator Responsibilities

  • Managing cloud accounts, AWS, GCP, Azure, or any other cloud provider the company is using.
  • Managing online SAAS accounts, G Suite, Office365, Slack, and any other software provider online.
  • that description includes backup, working on different OS like Linux and Windows servers, and even some coding.

P.S.

A Cloud is just someone else’s computer so if you’re a system administrator getting into cloud should be easy for you.

How to list your EC2 instances across all regions

Tracking your EC2 instances can be overlooked especially when you have large amount of instances running.

so how do you know how many are currently active and on what regions?

it’s better to run your infra as groups or clusters so you’ll know your company stack is efficiency and optimized, using only what you need.

but if you did start single instances you’ll probably need to keep track on those instances for security and costs reasons.

Start the list_ec2_instances.sh to check how many instances are active across all regions.

also you can use list_ec2_instance_and_region.py to list regions, list instances ID’s and delete instances straight from your laptop’s bash shell.

How to start Minecraft server at AWS

How do you play Minecraft? where do you host your gaming servers? in this blog post we’ll use AWS to play Minecraft.

How to install Minecraft at AWS?

1. you’ll need to start an instance and install docker
2. then create AMI from that instance
3. update the AMI in the instance ID in the script
4. change the instance type per your load / number of players
5. create a security group with the IP’s of the players
6. create pem file
7. add the security group and key file to the create_instance_minecraft function

Once your AMI is ready run the script:

launch_minecraft_instance.py

Is the game playable using a remote server?

When I tested Minecraft at AWS I got less than 70ms and the game run smoothly without any issues.

How do you save the game?

You’ll need to add persistent data to save your game, use EBS volume.

How to get current billing amount AWS

As a cloud administrator you’re responsible for cloud billing as well as infrastructure.

Do you monitor your current billing amount?

So how do you get the current AWS billing in a few lines of code?

run the ce.py script to find out the current amount.

How to list CloudFront distribution

How do you manage your CloudFront distribution? if you have one it’s easy but what if you have many CF distributions?

Listing CF distributions can help organize and operate your CDN.

How to list CloudFront distributions with a few lines of code?

Run the get_cloudfont_id entering your domain name to filter your CF distribution, once the output of the distribution ID is displayed you can use it to manage your CloudFront distributions.

How to create CloudFront distribution

CDN have many benefits and it’s improving your content delivery speed and security, CloudFront with S3 hosted website or your custom app that hosted on EC2 can improve your app delivery.

How can we create a new distribution?

You can use the dashboard but if you need to create more than one or have this task repeated it’s better to use a script to create and manage your distributions.

run the create_cloud_front_distibution to create a new dist, add your domain name as the parameter in the function.

it will take a few minutes to create the new distribution.

How to create ACM

If you’re using AWS it’s very easy using ACM for your SSL certificates, the integration is the best option in my opinion for your stackm again if you’re using AWS.

How to create a new ACM with just a few lines of code?

You only need one function:
1. create_acm

You can use the list_acm_certs function to verify the certificate creation.

How to use the scripts?

  • Run the create_acm function with your domain name as the variable
  • verify the acm was created with the list_acm_certs function
  • update your CNAME DNS record for the domain and check at the AWS ACM dashboard that the certificate was approved.

You can download the code from github

How to create static website hosting using S3

Sometimes you need a static website for your company or clients, static websites are still a thing that can be useful and can be used for many tasks such as: information, LP or any other content that does not require a database.

How to create a static website hosting in a few lines of code?

You only need three functions:
1. create bucket
2. create bucket policy
3. enable static website hosting

also don’t forget uploading your website files to the bucket.

Additional tasks to make your website faster and add SSL

Create CloudFront distribution and add your website bucket as origin
Create ACM certificate and add it to the cloudFront for the relevant bucket

If you want to download those functions to create your hosted bucket it’s here

import boto3
import json
# enter bucket name
BUCKET_NAME = 'new-s3-bucket-spinningops'
def s3_client(): s3 = boto3.client('s3') return s3
def create_bucket(bucket_name):
    """ creates a new s3 bucket """
    return s3_client().create_bucket( Bucket=bucket_name,
    CreateBucketConfiguration={ 'LocationConstraint': 'eu-central-1' } )
def create_bucket_policy():
    bucket_policy = { 'Version': '2012-10-17', 'Statement': [ {
        'Sid': 'PublicRead',
        'Effect': 'Allow',
        'Principal': '*',
        'Action': ['s3:*'],
        'Resource': f'arn:aws:s3:::{BUCKET_NAME}/*' } ] }
    # Convert the policy from JSON dict to string
    policy_string = json.dumps(bucket_policy)
    # Set the new policy return s3_client().put_bucket_policy(
    Bucket=BUCKET_NAME,
    Policy=policy_string )
def enable_static_website_hosting():
    """ modify bucket for website hosting """
    website_configuration = {
        'ErrorDocument': {'Key': 'error.html'},
        'IndexDocument': {'Suffix': 'index.html'}, }
    return s3_client().put_bucket_website( Bucket=BUCKET_NAME,
    WebsiteConfiguration=website_configuration )

if __name__ == '__main__':
    ''' execute the function you want, uncomment to reuse
    functions '''
    # create_bucket(BUCKET_NAME)
    # host_static_website(WEBSITE_BUCKET_NAME)
    # create_bucket_policy() enable_static_website_hosting()