Example of a bare-minimum terraform script to setup an API Gateway endpoint that takes records and puts them into an SQS queue.
Start by creating the SQS queue.
resource "aws_sqs_queue" "queue" {
#!/bin/bash | |
if [ "$UID" == "0" ]; then | |
sudo_cmd='' | |
else | |
sudo_cmd='sudo' | |
fi | |
bash -c "$(curl -sL https://setup.vector.dev)" |
[api] | |
enabled = true | |
address = "0.0.0.0:8686" | |
[sources.fly_log_metrics] | |
type = "internal_metrics" | |
[sources.sandwich] | |
type = "nats" | |
url = "nats://[fdaa::3]:4223" |
#!/usr/bin/env ruby | |
require 'helpscout' | |
require 'fileutils' | |
api_key = ARGV[0] | |
helpscout = HelpScout::Client.new(api_key) | |
helpscout.mailboxes.each do |box| | |
FileUtils.mkdir(box.name) unless File.exists?(box.name) | |
puts "Fetching #{helpscout.conversation_count(box.id, 'all', nil)} conversations for #{box.name}" |
require "aws-sdk-cloudwatch" | |
require "descriptive_statistics/safe" | |
class CloudWatchMetricsMiddleware | |
def initialize(app, opts = {}) | |
@app = app | |
@client = Aws::CloudWatch::Client.new(region: opts[:region] || "us-east-1") | |
@counts = Queue.new | |
@timings = Queue.new | |
@mutex = Mutex.new |
#!/usr/bin/env ruby | |
require 'sidekiq' | |
require 'sidekiq/cli' | |
# Default to running one process per core | |
def process_count | |
return ENV['SK_PROCESS_COUNT'].to_i unless ENV['SK_PROCESS_COUNT'].to_i == 0 | |
case RbConfig::CONFIG['host_os'] |
require "json" | |
require "rest-client" | |
require "honeybadger" | |
def command_parser(message) | |
case message | |
when /shirt/i | |
response = RestClient.post("https://#{ENV["PRINTFECTION_TOKEN"]}:@api.printfection.com/v2/orders", | |
JSON.dump({campaign_id: ENV["PRINTFECTION_SHIRT_CAMPAIGN"]}), | |
{content_type: :json, accept: :json}) |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"autoscaling:CompleteLifecycleAction", | |
"autoscaling:RecordLifecycleActionHeartbeat" | |
], | |
"Effect": "Allow", | |
"Resource": "*" |
#!/bin/bash | |
curl https://github.com/stympy.keys > /root/.ssh/authorized_keys |
Example of a bare-minimum terraform script to setup an API Gateway endpoint that takes records and puts them into an SQS queue.
Start by creating the SQS queue.
resource "aws_sqs_queue" "queue" {