Skip to content

Instantly share code, notes, and snippets.

View bryantrobbins's full-sized avatar

Bryan Robbins bryantrobbins

View GitHub Profile
@bryantrobbins
bryantrobbins / facts.rb
Created June 17, 2016 13:37
Custom facts for AWS EC2 instances
Facter.add(:ec2_availability_zone) do
setcode do
Facter::Core::Execution.exec('curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone')
end
end
Facter.add(:aws_region) do
setcode do
az = Facter.value(:ec2_availability_zone)
az[0..-2]
# Get package updates
sudo yum update -y
# Check if docker installed
installed=`yum list installed | grep docker`
if [[ -z "${installed}" ]]; then
# Docker install steps required for AMI (Amazon Linux)
sudo yum install docker -y
sudo service docker start
@bryantrobbins
bryantrobbins / ApplicationTests.java
Created September 29, 2017 01:49
ElasticMQ as a local drop-in for AWS SQS in a SpringBoot + Spring JMS setup
// AWS provides a JMS library for SQS: https://aws.amazon.com/blogs/developer/using-amazon-sqs-with-spring-boot-and-spring-jms/
// I wanted to use that setup in a Spring Boot app, and to run some tests against an in-memory
// ElasticMQ queue, which is SQS (and AWS Java SDK) compatible. In case your scenario is EXACTLY like mine ... here you go
@RunWith(SpringRunner.class)
@SpringBootTest
// This annotation is important: Forces the Application Context (and SQS connections) to reset between tests. ElasticMQ will fail to
// stop if there are active connections.
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class ApplicationTests {