AWS CDK Commands

The AWS Cloud Development Kit (CDK) comes with a list of commands that you need to know: cdk list (ls) Lists the stacks in the app cdk synthesize (synth) Synthesizes and prints the CloudFormation template for the specified stack(s) cdk bootstrap Deploys the CDK Toolkit staging stack; see Bootstrapping cdk deploy Deploys the specified stack(s) cdk destroy Destroys the specified stack(s) cdk diff Compares the specified stack with the deployed stack or a local CloudFormation template cdk metadata Displays metadata about the specified stack cdk init Creates a new CDK project in the current directory from a specified template cdk context Manages cached context values cdk docs (doc) Opens the CDK API reference in your browser cdk doctor Checks your CDK project for potential problems You can learn more about the CDK here: https://docs.

How to Make a Java Jar File Executable

Let’s say you have a Java project as follows: 1 2 3 4 5 6 package ms.ao.something; public class MyProject { public static void main(String...args) throws Exception { System.out.println("Hello world!"); } } Now you want to build this and make it a self contained executable Jar. If you do a mvn clean install or mvn clean package, and try and run it as follows: 1 java -jar target/my-java-1.0-SNAPSHOT.jar You will get the following error:

How to List All Resources in an AWS Account

If you need to see a list of all the resources in your AWS Account, then you need to look into the Tag Editor. Step 1 – Tag Editor Search for Tag Editor in the navigation search at the top of the AWS Console. Select the Resource Groups & Tag Editor. Step 2 – Find Resources From the left hand menu, select Tag Editor Step 3 – Filter your Search Requirements From the Regions drop down, select All regions and then select All supported resource types from the Resource types drop down.

Fixed size left column and fluid right column both with 100% height in CSS

If you need two (2) columns and want the left column to be a fixed size, but the right column to automatically take the remaining size of the window, then you can use the following solution. Follow the steps below, which include some CSS and some HTML. The CSS for our solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 html, body { height: 100%; width: 100%; padding: 0; margin: 0; } .

How to Check if a Volume is Mounted in Bash

If you need to check if a volume is mounted in a Bash script, then you can do the following. How to Check Mounted Volumes First we need to determine the command that will be able to check. This can be done with the /proc/mounts path. How to Check if a Volume is Mounted in Bash 1 2 3 4 5 if grep -qs '/mnt/foo ' /proc/mounts; then echo "It's mounted.

How to Determine if a Bash Variable is Empty

If you need to check if a bash variable is empty, or unset, then you can use the following code: 1 if [ -z "${VAR}" ]; The above code will check if a variable called VAR is set, or empty. What does this mean? Unset means that the variable has not been set. Empty means that the variable is set with an empty value of "". What is the inverse of -z?

How to Order by File Size using the du command in Linux

If you use the du command to list all the file sizes on Linux: 1 2 3 du # or du -h # Human readable Then you would have noticed that they are not ordered by file size. Instead you can pass that result to the sort command as follows: 1 du -h | sort -h

How to Join Multiple MySQL Tables in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. Presenting the data let’s take two (2) tables as a demonstration for the code below. Users – Table 1 1 2 3 4 5 { id: 1, name: 'Carl', fav: 254}, { id: 2, name: 'Emma', fav: 254}, { id: 3, name: 'John', fav: 255}, { id: 4, name: 'Hayley', fav:}, { id: 5, name: 'Andrew', fav:} Products – Table 2

How to Limit a MySQL Query in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Limit the Result Returned from MySQL in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.

How to Update a MySQL Table in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Update a MySQL Table in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.cursor() sql = "UPDATE customers SET address = 'Stoneleigh Place' WHERE address = 'Abbey Road'" mycursor.

How to Drop a MySQL Table in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Delete/Drop a MySQL Table in Python 1 2 3 4 5 6 7 8 9 10 11 12 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.cursor() sql = "DROP TABLE customers" mycursor.

How to Delete MySQL Records in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Delete MySQL Records in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.cursor() sql = "DELETE FROM customers WHERE address = 'The Rockies'" mycursor.

How to ORDER BY a MySQL Query in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Sort the Result of a MySQL Query in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.

How to Filter WHERE MySQL Queries in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Select from MySQL with a Filter in Python You simply specify the WHERE clause in your SQL statement as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.

How to Select From MySQL in Python

First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python. How to Select From a MySQL Table in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.cursor() mycursor.

How to Insert into a MySQL Table in Python

If you need to insert data into a MySQL table using Python, then look no further. If you need to first learn about the mysql.connector and how to get this up and running, first take a look at the How to Install MySQL Driver in Python post before continuing. How do Insert into a MySQL Table in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import mysql.

How to Create a Primary Key for a MySQL Database in Python

You can create a Primary Key for your MySQL database in Python as follows. First, you need to know if the Primary Key already exists. Option 1 – The Primary Key does not Exist 1 2 3 4 5 6 7 8 9 10 11 12 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.cursor() mycursor.execute("CREATE TABLE customers (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), address VARCHAR(255))") Option 2 – The Primary Key already Exists 1 2 3 4 5 6 7 8 9 10 11 12 import mysql.

How to Create a MySQL Table in Python

If you need to create a table in a MySQL database using Python, then you can do the following. How to Create a MySQL Table in Python 1 2 3 4 5 6 7 8 9 10 11 12 import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "username", password = "YoUrPaSsWoRd", database = "your_database" ) mycursor = mydb.cursor() mycursor.execute("CREATE TABLE people (name VARCHAR(255), address VARCHAR(255))") How to Check if a MySQL Table Exists in Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import mysql.

How to Create a MySQL Database in Python

In order to create a MySQL database in Python, you first need to initiate a connection using the mysql.connector. You can learn about how to create a connection to MySQL here. How to Create a Database in Python Creating a database is simple. First, make sure you have an active connection to your database, and then set a cursor. Once you have this, issue the execute command to create your database.

How to Install MySQL Driver in Python

To begin using MySQL in Python, you need to do the following: Step 1 – Install the MySQL Connector Using pip, we can install the MySQL Connector package: 1 python -m pip install mysql-connector-python Step 2 – Test the MySQL Connector Create a Python file and import the new package: 1 import mysql.connector Step 3 – Create a Connection to the MySQL Database Now you can create a connection to your MySQL database.