Wednesday, August 31, 2022

AWS EC2 Hibernate Java SDK v2 Example

I recently wanted to automate the creation of developer VMs in AWS using EC2 instances. To improve the developer experience (DX), I didn't like the developers having to shut down their instances to save money and lose their work. I wanted them to be able to hibernate their instances and return to where they left off. Unfortunately, I couldn't find an example of this using the AWS Java SDK v2. So after some experimentation, I created this example.

There are two requirements for hibernating an EC2 instance. First, the EBS drive must be encrypted. Second, the hibernate option must be enabled. Both of these requirements must be met when the instance is created.

Ec2Client ec2 = Ec2Client.builder()
.region(Region.US_EAST_2)
.build();

RunInstancesRequest runRequest = RunInstancesRequest.builder()
.imageId("ami-081f2c86d8b025c4b")
.instanceType(InstanceType.T3_MEDIUM)
.maxCount(1)
.minCount(1)
.keyName("dev-key")
.blockDeviceMappings(BlockDeviceMapping.builder()
.deviceName("/dev/xvda")
.ebs(EbsBlockDevice.builder()
.volumeSize(40)
.deleteOnTermination(true)
.encrypted(true)
.build())
.build())
.hibernationOptions(HibernationOptionsRequest.builder().configured(true).build())
.securityGroups("devvm-default-sg")
.build();

RunInstancesResponse response = ec2.runInstances(runRequest);
String instanceId = response.instances().get(0).instanceId();

software.amazon.awssdk.services.ec2.model.Tag nameTag = software.amazon.awssdk.services.ec2.model.Tag.builder()
.key("Name").value("hibernate example")
.build();

CreateTagsRequest tagRequest = CreateTagsRequest.builder()
.resources(instanceId)
.tags(nameTag)
.build();

ec2.createTags(tagRequest);
You can find a complete example at https://github.com/cjudd/ec2hibernate.

Wednesday, February 10, 2016

The Ultimate Enterprise Java Build Solution Revisited

In May of 2009, I wrote the blog post The Ultimate Enterprise Java Build Solution. Over the past 7 years since I wrote the post I have helped half a dozen clients set this system up and had several more tell me they also implemented it after seeing the post or listening to me talk about it at a user group or conference. In the post I talked about using Maven on the developers laptop for local builds, Subversion to store the code, Hudson to grab the code and run the same Maven build that ultimately pushed artifacts to Nexus and code quality metrics to Sonar. Surprisingly this hasn't changed much over the years. In addition to Maven, today you might use Gradle for the builds and in addition to Subversion you might use Git and/or Github for version control. Instead of Hudson you probably would use Jenkins which use to be Hudson and you probably use sonarqube instead of Sonar which is just a name change. You might still use Nexus or one of the other artifact repositories.

One of the things that has changed though is how you might deploy the solution. Instead of installing Jenkins, Nexus and sonarqube individually by hand, now you can use Docker to get you up and going even faster. I have also created a docker-compose.xml file so you can get all of them and their dependencies up and running with once simple command of docker-compose up -d.

I love progress.

Sunday, June 12, 2011

iPad is the perfect conference device

As a software developer that relies on heavy duty hardware, I have been reluctant to attend any of the many tech conferences without my full size and capable laptop. This weekend I decided not to break my back caring my 17in MBP. This weekend, I only carried my first gen WIFI iPad to the No Fluff Just Stuff conference. I was pleasantly surprised it was all I needed. I even attended a git hands-on workshop by Matthew McCullough and was able to complete all the labs.

There were several things that enabled me to do this. First NFJS provides a great iPad app for the conference. It sets the bar really high for other conferences because it includes the schedules, evals, and presentation slides you can make notes on. I personally choose to get the PDFs and use GoodReader to annotate them so I could use them on my Mac later. Second I kept Textastic in the back ground to make notes that had nothing to do with the presentation or something I wanted to do immediately when I get back to the office. Third I used iSSH to ssh into my server for the git workshop. Finally the hotel offered free Internet and for a tech conference it worked surprisingly well.

I am alway surprised at how many people say the iPad is just a consumption device. After this weekend I am convinced the iPad is the perfect conference device. This is probably why NFJS is getting rid of paper next year and will be loaning devices out to all the attendees for the weekend.

Saturday, February 26, 2011

Free Mobile Development Lunch and Learns

Judd Solutions is offering free one hour mobile development lunch and learns for companies or groups in the Columbus Ohio area with 5 or more attendees. The three offerings are:
  • Beginning iOS development
  • Beginning Android development
  • Beginning mobile web development
  • Developing Android apps with Google App Inventor
If you are interested in learning more, please contact cjudd at juddsolutions.com.

Thursday, June 3, 2010

Your Phone is so much more than a Phone

I have been developing mobile apps since 2002. Ever since I started, I listened to people talk about the potential of cellphones especially in the area of marketing. Ok, even I have talked about the great potential. But the reality is even though I have written some really cool mobile applications I just have not seen these predictions come to reality until now. I think within in the last year we have seen mobile platforms take center stage and become the ultimate personal and convergent device. Most of this is due to rise of the iPhone and Android platforms. Let me show some of my observations.

Digital Wallet
Ultimate Communication Device
Connectivity Device
  • Always connected Internet device
  • Portable hotspot (Sprint HTC EVO) for connecting all your devices
Entertainment Device
  • Movies
  • TV (ABC)
  • Music
  • Books
  • YouTube
  • Games, Games and more Games
Location Aware
  • GPS apps
  • Compasses
Production
  • Camera and photo software
  • Video
And the list keeps going. Combined with the ease of portablity it is the only thing I always leave home with besides my wallet and hopefully someday I will be able to leave my wallet home too.

Thursday, March 25, 2010

How iPad and iPhone/iPod Touch Interactions Could Effect Gaming

I am very much anticipating April 3rd and the arrival of the iPad. The more I think about it the more I think about the impacts it will have. I have recently been spending a lot of time thinking about the new interaction opportunities we can have by combining the iPad with an iPhone or iPod Touch. I think these interactions become even more interesting in the context of gaming.

With the dimentions of the iPad, I can imagine placing it on a table facing up with four people surrounding it like a board game. Each person holding an iPhone or iPod Touch. For simplicity sake, imagine a game like Scrabble. On each person's iPhone or iPod Touch they can view their own tiles. On their turn, they can flick the tiles off their device and they could land on the iPad where the tiles can be moved into place. This type of interaction could work with anything somebody wanted to keep private like cards but then shared at the approriate time on the iPad. This interaction could also be used for photos much like the Microsoft Surface demos.

Now imagine turning the iPad up on its side or strapping it to the back of a car seat. Now you have a video game console. An iPhone or iPod Touch could be used as a game controller for a first person shotter , a stearing wheel for a driving or simulator game where tilting it could be the accelorator or finally a Nintendo Wii style remote for games including vibrating feedback and two sounds sources. So, instead of swing your iPhone around to make it sound like a light sabor, you can also make your first person game character wield a light sabor.

Now my son is sure to shatter my iPhone.

Wednesday, February 3, 2010

iPad Longevity

Like many people, I was a little disappointed by some of the glaring omissions from the Apple iPad announcement. However, as somebody who develops for the iPhone platform, I do feel I need to at least get a version of the cheapest model for testing purposes. At least that is what I am telling my CFO ;) But as I think about the decision of buying a first generation device now and realizing Apple will probably release the version I really want next year, I started think about the longevity of the iPad especially compared to a netbook or the Kindle. Even if I upgrade a year from now, I think the iPad's form factor and weight make it increadibly useful for the long hall. As iPad's retire, I can definately see them become dedicated reading devices next to the bed or dedicated gaming devices for the kids. But I can also imagine them being mounted on kitchen walls. Maybe even mounted within a frame to hid the black borders. It could be used to display a calendar, digital photos, the current local weather, a clock or all of the above. In addition, it could be a convient means to store or look up recipes. Hmm... Maybe I should create a Kitchen App.

AWS EC2 Hibernate Java SDK v2 Example

I recently wanted to automate the creation of developer VMs in AWS using EC2 instances. To improve the developer experience (DX), I didn'...