• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for February 2021

GCP List of SQL Instances

February 28, 2021

Here’s how to list SQL instances within your GCP project.

gcloud sql instances list --project your-project-id

gcloud sql instances list --project your-project-id

Output:

NAME             DATABASE_VERSION         LOCATION       TIER              PRIMARY_ADDRESS  PRIVATE_ADDRESS  STATUS
database1        SQLSERVER_2017_STANDARD  us-central1-a  db-n1-standard-1  -                10.10.10.11    RUNNABLE
database2        SQLSERVER_2017_STANDARD  us-central1-c  db-n1-standard-1  -                10.10.10.12    RUNNABLE

NAME DATABASE_VERSION LOCATION TIER PRIMARY_ADDRESS PRIVATE_ADDRESS STATUS database1 SQLSERVER_2017_STANDARD us-central1-a db-n1-standard-1 - 10.10.10.11 RUNNABLE database2 SQLSERVER_2017_STANDARD us-central1-c db-n1-standard-1 - 10.10.10.12 RUNNABLE

Filed Under: Cloud Tagged With: gcloud, gcp, instances, list, sql

GCP List of Projects

February 28, 2021

Here’s another way to list projects in a shared VPC.

gcloud compute shared-vpc list-associated-resources your-shared-host

gcloud compute shared-vpc list-associated-resources your-shared-host

Output:

project1  PROJECT
project2  PROJECT
project3  PROJECT
...

project1 PROJECT project2 PROJECT project3 PROJECT ...

Filed Under: Cloud Tagged With: gcp, list, projects

Disable Gutenberg

February 27, 2021

Two years ago, WordPress introduced Gutenberg block editor together with the release of WordPress version 5.0. Gutenberg essentially became the default editor starting with WordPress version 5.0. While many people love the Gutenberg editor, some people hate it. If you’re one of the many people who hate the Gutenberg editor, you can simply disable it by installing a plugin called Disable Gutenberg. This plugin will revert back to the classic editor.

Once installed, you should be able to see the Classic editor.

After working with Gutenberg for so long, I forgot the speed and agility of the classic editor. It’s much faster.

Filed Under: WP Tagged With: classic, disable, editor, gutenberg, wordpress

AWS List Machine Images

February 27, 2021

Here’s how to list AWS AMI (machine images) owned by yourself.

aws ec2 describe-images \
--query "Images[*].[Name,PlatformDetails]" \
--owners self \
--profile default \
--region us-east-1 \
--output text

aws ec2 describe-images \ --query "Images[*].[Name,PlatformDetails]" \ --owners self \ --profile default \ --region us-east-1 \ --output text

Output:

icecast-0.1     Linux/UNIX
jekyll-0.3      Linux/UNIX
docker-0.1      Linux/UNIX

icecast-0.1 Linux/UNIX jekyll-0.3 Linux/UNIX docker-0.1 Linux/UNIX

Specifying owners as self only display images owned by you.

Filed Under: Cloud Tagged With: aws, list, machine-image

Logging Commands

February 22, 2021

I decided to log my commands for good record keeping. Here’s my script.

#!/bin/bash
if [[ $# -eq 0 ]] ; then echo 'No arguments. Format: ./go.sh script.sh'; exit 0; fi
log=log.txt
echo '-------------------------------' >> $log
date >> $log
echo '---' >> $log
cat $1 >> $log
echo '---' >> $log
/bin/bash $1 2>&1 | tee -a $log

#!/bin/bash if [[ $# -eq 0 ]] ; then echo 'No arguments. Format: ./go.sh script.sh'; exit 0; fi log=log.txt echo '-------------------------------' >> $log date >> $log echo '---' >> $log cat $1 >> $log echo '---' >> $log /bin/bash $1 2>&1 | tee -a $log

To run.

./go.sh script.sh

./go.sh script.sh

Line by line explanation.

  1. Checks for script to run. Exits if there’s no argument.
  2. Sets the log file.
  3. Prints dashes.
  4. Prints the date.
  5. Print 3 dashes.
  6. Prints the commands to the log file.
  7. Print 3 dashes.
  8. Run the command. Send error and standard out to log file.

Filed Under: Linux Tagged With: bash, commands, log, tee

AWS S3 Bucket Permission

February 16, 2021

I was getting this error when downloading a file from a S3 bucket.

fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden

fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden

Turns out to be a permission issue. Use –acl bucket-owner-full-control.

# UPLOAD
aws s3 cp file.txt s3://bucket-name/dir/ --acl bucket-owner-full-control
upload: .\file.txt to s3://bucket-name/dir/fw.sh
# DOWNLOAD
aws s3 cp s3://bucket-name/dir/file.txt . --acl bucket-owner-full-control
download: s3://bucket-name/dir/file.txt to .\file.txt

# UPLOAD aws s3 cp file.txt s3://bucket-name/dir/ --acl bucket-owner-full-control upload: .\file.txt to s3://bucket-name/dir/fw.sh # DOWNLOAD aws s3 cp s3://bucket-name/dir/file.txt . --acl bucket-owner-full-control download: s3://bucket-name/dir/file.txt to .\file.txt

You need to do for both upload and download.

Filed Under: Cloud Tagged With: aws, bucket, permissions, s3

GCP Firewall Source Service Account

February 16, 2021

Here’s how to create a firewall from service account to service account.

gcloud compute firewall-rules create "firewall-name" \
--description="firewall-description" \
--priority "1000" \
--direction INGRESS \
--action allow \
--network "network-name" \
--source-service-accounts="service@account.net" \
--target-service-accounts="service@account.net" \
--rules tcp:9001

gcloud compute firewall-rules create "firewall-name" \ --description="firewall-description" \ --priority "1000" \ --direction INGRESS \ --action allow \ --network "network-name" \ --source-service-accounts="service@account.net" \ --target-service-accounts="service@account.net" \ --rules tcp:9001

Instead of source-range, it’s using source-service-accounts.

Filed Under: Cloud Tagged With: firewall, gcp, service account, source-service-accounts, target-service-accounts

Create A Swap File

February 16, 2021

How to create a swap file.

A 2GB swap file.

dd if=/dev/zero of=/swapfile bs=1k count=2048k

dd if=/dev/zero of=/swapfile bs=1k count=2048k

Activate.

mkswap /swapfile
chmod 0600 /swapfile
systemctl daemon-reload
swapon /swapfile

mkswap /swapfile chmod 0600 /swapfile systemctl daemon-reload swapon /swapfile

To make swap permanent, add to /etc/fstab.

/swapfile  swap   swap    defaults   0 0

/swapfile swap swap defaults 0 0

Check if swap is working.

cat /proc/swaps
free -h

cat /proc/swaps free -h

Filed Under: Linux Tagged With: activate, create, file, swap

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023