CloudExceptions::CloudException – 400: VPCIdNotSpecified: No default VPC for this user

When you launch a new EC2 instance in the AWS cloud from the command line or with other cloud management platforms, you may get the error message:

CloudExceptions::CloudException – 400: VPCIdNotSpecified: No default VPC for this user (RequestID: …)

This can happen when the specified Subnet Id is not a valid subnet in the selected availability zone (datacenter).

Start a new Spring MVC Java Web application development in NetBeans

When you create your first Spring MVC Java web application in the base installation of NetBeans follow the steps below

Create a project

  1. In the File menu select New Project
  2. Select the Java Web category, select the Web Application project, and click Next,
  3. Enter the name of the project and click Next,
  4. If this is the first Java web application you create in NetBeans, most likely there is no web server for Java is installed on your workstation. If this is the case, click the Add… button,
  5. Keep the GlassFish Server selected and click Next,
  6. Select the I have read… checkbox and click the Download Now… button,
  7. Keep the latest version selected and click OK,
  8. Make sure the I have read… checkbox is still selected, and click Next,
  9. Click Finish to register the domain on your workstation,
  10. The Context Path shows the address for your application. Click Finish again to continue.
  11. Select the Spring Web MVC framework and click Finish.
  12. If a library is missing from your workstation, a message pops up. Click the Resolve Problems… button for instructions,
  13. On the Resolve Project Problems window click the Resolve… button,
  14. Download the missing library to your workstation. In this case, navigate your web browser to
  15. Download the “javaee-endorsed-api-7.0.jar” library
  16. Create the folder C:\Users\YOUR_USER_NAME\AppData\Roaming\NetBeans\8.2\modules\ext\javaee7-endorsed
  17. Extract the “javaee-endorsed-api-7.0.jar” file into the new folder,
  18. On the Ant Library Manager window click the New Library… button,
  19. Enter “javaee-endorsed-api-7.0” into the Library Name field and click OK,
  20. Click the Add JAR/Folder… button,
  21. Navigate the to extracted JAR file at “C:\Users\YOUR_USER_NAME\AppData\Roaming\NetBeans\8.2\modules\ext\javaee7-endorsed” and click the Add JAR/Folder button,
  22. On the Ant Library Manager window click the OK button,
  23. On the Resolve Project Problems window click Close.

Start the application

  1. In the Project list right-click the web application project and select Run
  2. The Output window should display a similar message,
  3. Open a web browser and navigate to http://localhost:8080/MY_PROJECT_NAME, to display the index page. The server is case sensitive, so make sure the spelling of the project name is correct.


The application configuration files

With the default settings the index.jsp composes the index page. It is in the Web Pages/WEB-INF/jsp directory.

The web.xml file in the Configuration Files directory points to the first Java Server Pages file: redirect.jsp

The redirect.jsp file is located in the Web Pages directory

The Dispatcher

The dispatcher-servlet.xml file contains the mapping between the HTML file, controller, and view.

<property name="mappings">
    <prop key="index.htm">indexController</prop>

The bean section specifies the name of the view for the controller.

 The index controller.
 <bean name="indexController"
       p:viewName="index" />


Configure NetBeans for Java Web development

The base installation of NetBeans does not include the web development category.


To add the Java web development tools to NetBeans

  1. Start the NetBeans IDE,
  2. In the Tools menu select Plugins,
  3. On the Available Plugins tab select the Java EE Base plugin and click the Install button,
  4. If any of the installed plugins is missing the valid signature, you need to click the Continue button to allow the installation,
  5. For the plugin installation, you need to restart the NetBeans IDE,
  6. During the next start, NetBeans installs the new plugins,
  7. The Java Web category is now available.

Create the AWS credentials file from a Chef Data Bag

When a process on a server instance needs access to an AWS account, the user who will execute the AWS CLI commands needs to be able to automatically authenticate in AWS.

For automatic AWS authentication, the AWS CLI creates two files in the .aws directory:

  • config and
  • credentials.

The location of this directory depends on the operating system and the type of user.

  • On Linux, the location is ~/.aws ( the user’s home directory )
  • On Windows, it is located at C:\Users\USER_NAME\.aws
  • On Windows, if the file was created by SYSTEM, the location is C:\Windows\System32\config\systemprofile\.aws

Store the AWS key values

To create these files, you need to store the AWS Access Key and Secret Key. The safest place for these values is an encrypted data bag. To automatically generate the AWS files, create a data bag file and name it the same as the “id” in the following structure:

  "MY_PROFiLE_1": {
    "region": "MY_REGION_1",
    "aws_access_key_id": "MY_ACCESSKEY_1",
    "aws_secret_access_key": "MY_SECRET_KEY_1"
  "MY_PROFiLE_2": {
    "region": "MY_REGION_2",
    "aws_access_key_id": "MY_ACCESSKEY_2",
    "aws_secret_access_key": "MY_SECRET_KEY_2"

To create and encrypt the data bag see my post on Chef Data Bags

Create the AWS authentication files

  1. In your Chef recipe, first install the AWS CLI and reboot the server, so the new path entry will be available for the Chef process.
  2. The following Chef code will create the AWS config and credential files. The script
    1. opens and decrypts the data bag,
    2. loads it into a hash table,
    3. iterates through the hash items,
    4. skips the “id” item,
    5. stores the AWS key values in a temporary file,
    6. executes the “aws configure” command to generate the AWS config and credential files.
  # Iterate through the data bag and create the credentials file

  puts "***** Creating the AWS credentials file"

  # Load the encrypted data bag into a hash
  aws_credentials = Chef::EncryptedDataBagItem.load('MY_DATA_BAG_NAME', 'MY_DATA_BAG_ITEM_NAME').to_hash

  # Iterate through the items, skip the "id"
  aws_credentials.each_pair do |key, value|

    # skip the "id"
    next if key == "id"

    # Add the credentials to the .aws/credentials file
    puts "Account #{key}, Region #{value['region']}"

    batch "add_aws_credentials_#{key}" do
      code <<-EOF echo #{value["aws_access_key_id"]}> input.txt
        echo #{value["aws_secret_access_key"]}>> input.txt
        echo #{value["region"]}>> input.txt
        echo.>> input.txt
        aws configure --profile #{key} < input.txt



Soundproof Enclosure for the Monoprice Select Mini 3D Printer

The Monoprice Select Mini printer is an open design, all noise making parts are exposed, and as the stepper motors move the head and the platform, the vibration transfers to the table it is sitting on. There are a few sound proof enclosure designs on the internet, but I have found one that looks cool and easy to assemble. The original design doesn’t use the lid as a platform, but as I found out, the lid on flexible legs and the soft foam insulator under the printer greatly reduces the vibration transferred to the table. My family doesn’t even notice anymore when the printer keeps working overnight on a large model. Without the enclosure, I always had to make sure the printer stopped before bedtime.

The enclosure provides significant noise reduction. I have used an iPhone app to measure the noise from 1 meter distance. The 6dB difference doesn’t look too much, but on the logarithmic scale that means half volume reduction.

  • Without the cover: 39 dB
  • With cover, door open: 34 dB
  • Door closed: 33 dB

I could not measure much difference in noise levels with and without the insulator on the door, but during night printing even a small reduction in noise level counts.

My version of the soundproof enclosure for the Monoprice Select Mini 3D printer is based on the great design announced by Daniel Smith at
The original build instructions are at

In this post, I will show the modifications I made to the original design. Read the original article for more information.

I re post the bill of materials in case the original article disappears:

The total cost of my version is about $150, though you can eliminate a few of the line items to bring the cost down if needed. Ended up not buying the web camera, as I can check on the progress anytime by walking to the printer. Maybe later I will buy it to create time lapse videos.

The extra items in the bill of materials above for my design:

  • Double sided 3M foam tape to attach the custom legs,
  • 8 thin wood screws to secure the blowers.
  • Elmers Glue and clear packing tape to secure the dome
  • 12 strong magnets to attach the insulator to the door if necessary.

The final product

The major differences are the transparent dome on the top and using the lid as the bottom of the box. The dome serves two purposes: Room for the tube at the top of the head, and provides a great view of the 3D object on the platform during the printing process. The lid provides the needed alignment when I put the box above the printer because the build platform almost hits the front and the back of the box.

Mark the openings

Measure twice, cut once told my father, and he was right. The original author already warned us, because the box sits above the printer upside down, it is very easy to cut the openings on the wrong side of the box.  I have started the process with a permanent marker and marked all openings on the box. Before cutting the material, I placed the box above the printer and verified the location of all of them.

The dome

When the head is at the highest position, the feeding tube needs more room than what the plastic box provides.

The transparent dome is the packing material of a large headphone. First I cut the opening for the dome with an electric jigsaw.

The air outlets

The distance between the hole centers is 15 mm, drill the holes with 8 mm drill bits.

Fan mounting holes

The original plan recommended Super Glue to mount the fans, I wanted a more secure hold, so I used thin wood screws to attach the fans to the box. To mark the location of the holes I inserted the screws into the mounting holes of the fans, painted the heads with the permanent marker and quickly pushed them to the planned location inside the box. After a few tries, I could see the screw locations on the walls. I enlarged the marks with a thick permanent marker and using a flash light copied the locations to the outside surface. To get the correct position I used small strips of the insulating material under the blowers because those will be on the surface of the insulator.

Speed controller

I drilled a hole for the potentiometer of the speed controller and used the nut to secure it below the power strip on the left side.

Power strip

Drilled four holes for the zip ties and cut a square opening with a Dremel tool for the plug.


Room for the build platform at the back

THe build platform almost touches the front and the back of the box. To make more room at the back I used the same Dremel tool to remove the ribs from the back of the box.

Printer power cable openings

To change the filament, replace the blue painter’s tape on the build platform, or remove a large object, I frequently have to lift the box. To easily position the box over the printer, I use the lid as the base under the printer. To be able to easily remove the box and place it on the floor, the power strip only provides power for the blowers and the LED strip ( I haven’t installed the camera yet ), I left the power supply of the printer outside of the box and plugged it separately into the wall outlet. I used a 5/8″ wood bit and the Dremel tool to enlarge the hole for the barrel plug.

I also drilled two holes for the cable tie to secure the power cord to the lid.

I also had to cut into the edge of the box where the printer power cord enters the box.

Easy lifting

To be able to easily lift the box, I have cut the tabs with the Dremel tool on the sides of the lid where the handles are.

Cool air for the printer

The printer also needs fresh air to cool the control board inside. The Monprice Select Mini has openings at the bottom, so I have cut holes into and elevated the lid with custom legs to provide the air it needs. I used a sheet of paper to copy the exact location of the opening to the lid. The lines are 15 mm apart, and I used an 8 mm bit to drill the holes.

I cut strips of the insulator to lift the printer because I had to pull it forward to provide enough room at the back for the platform. The left side of the printer is much heavier, so it needs more support there.

To provide room for the air flow under the lid, I had to print custom legs for the edge and the center to support the weight of the printer. The diameter of the legs is 30 mm. The height at the edges is 5 mm, under the printer 13 mm. I used the flexible TPU material for better noise reduction, and double sided 3M foam tape to secure them.


Cut the insulator

I traced the box to cut the insulator. For the back and side walls make the insulator larger because the turns need extra material. You can cut the excess after you have pasted it in place.

Secure the dome

My dome has a 10mm flat edge around, so I used Elmers Glue and transparent packing tape to secure the dome from the inside of the box. The insulator provides the additional support. I put the blower wires under the insulator of the back wall. Cut an opening in the insulator for the speed controller, do not hide it, because it needs air for cooling. Cut into the insulator for the output of the blowers.

Cut into the insulator where the build platform needs extra room.

LED lights

Install the LED strip above the door and hide the wire under the insulator. Use the USB outlets of the power strip to power it.

Door insulation

I left the protecting paper on the insulator for the door. I use 12 strong magnets to be able to attach and easily remove the insulator from the door. I hold a magnet on the inside surface of the insulator, and another one on the outside of the door. I could not detect significant noise level differences with our without the door insulator, but during night printing every decibel counts.


Ruby Gem Management

Ruby gems are Ruby programs and libraries with a name, version and the platform that can execute them.

List the installed gems on your system

gem list

Detailed list that includes the author, homepage, license, install location and a short description

gem list -d

Install the latest version of the gem

gem install GEM_NAME

Install a specific version of the Gem

gem install GEM_NAME -v GEM_VERSION

Uninstall the gem from your system

gem uninstall GEM_NAME

Uninstall a  gem from a specific location


Update the Gem list in your system after Gem uninstallation

gem update --system





Bootstrap Chef nodes to connect them to the Chef server

A Chef node is a physical or virtual machine with an operating system that is connected to the Chef server. Once the node has made the connection to the Chef server, the installed Chef Client can execute Chef cookbooks to configure the machine.

Bootstrapping is the process to connect the node the first time to the Chef server, or to attach it again if the node lost the connectivity to the Chef server. To be able to bootstrap a node, your workstation needs to have the Chef Development Kit installed. The kit includes the ‘knife’ command that communicates with the Chef server. Your workstation also has to be able to connect to the Chef server with the YOUR_USERNAME.pem file you store in the .chef directory just above your cookbooks.

Bootstrap a Linux node

To bootstrap a Linux node, open a terminal window on your workstation and execute the command:

knife bootstrap MY_NODE_IP -x MY_USERNAME -P MY_PASSWORD --sudo --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]'

Bootstrap a Windows node

knife bootstrap windows winrm MY_NODE_IP -x MY_USERNAME -P MY_PASSWORD --node-name THE_NODE_NAME --environment THE_ENVIRONMENT --run-list 'recipe[MY_COOKBOOK1::default],recipe[MY_COOKBOOK2::default]' -V


  • MY_NODE_IP is the IP address of the node you want to attach to the Chef server,
  • MY_USERNAME and MY_PASSWORD are the credentials to connect to the node,
  • THE_NODE_NAME is the unique name you want the node to use in the Chef server database. If you are bootstrapping a server that lost connectivity to the Chef server, find the node name in the node list.
  • THE_ENVIRONMENT is the name of the environment the node will run the cookbook in,
  • the run list is a list of cookbooks and roles

Dynamically set Chef resource attributes

When you need to set a Chef resource attribute based on the current state of the environment, there is a way to dynamically provide the value.

  1. Set the value of a boolean variable with a test,
  2. Declare the Chef resource and assign a reference to it to a variable,
  3. Set the resource attribute based on the value of the boolean variable.
# Set a boolean variable with a test 
  "#{node['domain']}" != ""

# Execute a resource and get a reference to it into a variable
# Set the attribute value based on the boolean variable



How to create a bootable USB drive to install Windows

If the computer you want to install Microsoft WIndows on, does not have a DVD drive, you can install Windows from a USB drive. To start the computer from the USB drive, you need to prepare the drive to make it bootable.

Microsoft has a free tool that can download the edition of the WIndows operating system you need, format the USB drive, make it bootable, and place the installer file on it.

  1. Using a web browser navigate to,
  2. Click the Download tool now button to install the Microsoft Media Creation Tool,
  3. Start the downloaded MediaCreationTool.exe program and follow the prompts.