August 2019
M T W T F S S
« Jul    
 1234
567891011
12131415161718
19202122232425
262728293031  

Categories

WordPress Quotes

Instead of worrying about what people say of you, why not spend time trying to accomplish something they will admire.
Dale Carnegie
August 2019
M T W T F S S
« Jul    
 1234
567891011
12131415161718
19202122232425
262728293031  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (40)
Ansibile (19)
Apache (135)
Asterisk (2)
cassandra (2)
Centos (211)
Centos RHEL 7 (268)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (30)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
health (1)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (7)
Ldap (5)
Linux (188)
Linux Commands (166)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (35)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (35)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (62)
Uncategorized (30)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

23 visitors online now
2 guests, 21 bots, 0 members

Hit Counter provided by dental implants orange county

Adding SMS Notifications to Your Bash Scripts

Cost Note: The first 100 text messages / month are free. After that, you may start incurring charges.

Step 1: Create an Appropriate AWS User

Start by creating a new User or Group in AWS with the appropriate privileges. You do NOT want to use your root account in production, for security reasons. I would suggest creating a group here, and adding your user to that group, so you can easily expand privileges  if you want to do more things via AWS CLI.

  • Visit the IAM home, in the AWS console: https://console.aws.amazon.com/iam/
  • Click on “Users”, then “Add User”.
  • Enter a User name, and then check “Programmatic Access”
  • On the “Permissions” Screen, you can either assign the user to a group with these permissions, or assign directly. You need a minimum of AmazonSNSFullAccess permission here.
  • Review, then create your user.
  • Important : Write down or download the CSV for the access and secret key. You CANNOT get these again, without regenerating and changing them.

 

Create a new folder in your HOME directory (~/ on Linux/Mac or C:\Users\USERNAME\ on Windows) called .aws and then create a text file in that folder called credentials without any extension. Now add the following text to that file:

[sns-reminders]
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY

 

For a bit of extra security you can lock down the credentials file’s permissions to 600:

$ chmod 600 credentials

Now you’ll want to head over to your IAM console and in the users tab, click “Create New Users”, add a user called “sns-reminders”, make sure that “Generate an access key for each user” is checked and then click “Create”.

You should then be brought to a screen that looks like this:

Step 2: Install and configure AWS CLI

There are many ways to install the AWS CLI. If your platform supports it, I strongly suggest installing with PIP: sudo pip install awscli

If you cannot or wish not to use PIP, see the official guide here for installing AWS CLI.

To configure, first enter: aws configure This will prompt you for the following, which you should have noted from the step above.

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: ENTER

The access key and secret key should have been generated in step 1. The region can be any of the AWS regions, but if you choose one that does not support SMS, you will have to force that region in the command in step 3.

Step 3: Test It Out!

Try the following code in terminal, to test and make sure everything works. Be sure to substitute your phone number with the placeholder.

aws sns publish --phone-number=1-555-555-5555 --message "Your Message Here"


aws sns publish --topic-arn arn:aws:sns::sms-ack --message "website is up"

If your default region does not support SMS, you can add this tag to force it to one that does: --region us-west-2 .

--message can also take a file name as an argument, with --message file://file.txt, instead of a string, and send the contents of that file.

Wrapping Up

That’s it! Feel free to add the line above to any of your bash scripts or cron jobs, to alert you when something occurs. For example, I have a weekly backup in addition to my nightly, so I have it text me when that has been completed.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam