Skip to content

Instantly share code, notes, and snippets.

View jkodroff's full-sized avatar

Josh Kodroff jkodroff

View GitHub Profile
@jkodroff
jkodroff / index.ts
Created February 6, 2024 22:09
Pulumi SSM Instance - TypeScript
const sg = new aws.ec2.SecurityGroup("ssm-sg", {
vpcId: vpcId,
description: "Allow all egress, no ingress.",
egress: [{
fromPort: 0,
toPort: 0,
protocol: "-1",
cidrBlocks: ["0.0.0.0/0"],
description: "Allow all"
}]
@jkodroff
jkodroff / pulumi-exmaple-gen.sh
Created March 10, 2023 16:15
bash script to generate Pulumi in all languages from a YAML sample (as created by Daniel Bradley)
#!/bin/bash
pulumi convert --language python --out python --generate-only || true
pulumi convert --language typescript --out typescript --generate-only || true
pulumi convert --language java --out java --generate-only || true
pulumi convert --language go --out go || true
pulumi convert --language csharp --out csharp || true
# Read each source file
TS_SRC=$(cat typescript/index.ts)
// TfDataSourceToPulumi converts a given Terraform data source name tfName (e.g. "provider_foo_bar") and returns the
// standard conversion to a Pulumi function name (e.g. "getFooBar")
func TfDataSourceToPulumi(tfName string) string {
parts := strings.Split(tfName, "_")
if len(parts) < 2 {
return ""
}
// The first segment is the provider name, which we do not include in the Pulumi name.
parts = parts[1:]
@jkodroff
jkodroff / refresh_creds.sh
Last active March 29, 2023 15:58
Bash script to port temporary STS creds to environment variables when MFA is required.
#!/usr/bin/env bash
# Usage: source ./refresh_creds.sh
# NOTE: You *must* source this file because it modifies environment variables.
# Executing the script directly will not change the calling shell's environment.
if [ -z ${AWS_MFA_DEVICE_ARN+x} ]
then
echo "Environment variable AWS_MFA_DEVICE_ARN must be set to the ARN of your MFA device."
return 1
fi
@jkodroff
jkodroff / keybase.md
Created October 3, 2018 17:42
keybase.md

Keybase proof

I hereby claim:

  • I am jkodroff on github.
  • I am jkodroff (https://keybase.io/jkodroff) on keybase.
  • I have a public key ASBvthNxNwc-GeV746vq-tYHwA1rO6nxQ_S3PF0hlwPIMAo

To claim this, I am signing this object:

@jkodroff
jkodroff / .gitignore
Created March 30, 2018 14:21
.gitignore for Ansible/Molecule roles
__pycache__/
.molecule/
.pytest_cache/
*-console.log
@jkodroff
jkodroff / EmptySolution.sln
Created December 14, 2015 19:14
Empty VS Solution File, Visual Studio 2013.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
hg clone http://bitbucket.org/durin42/hg-git/ C:\hg-git
@jkodroff
jkodroff / .gitignore
Last active September 3, 2015 19:33
.gitignore for .NET Projects
obj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
_ReSharper*/
*.resharper
*.csproj.user
TestResult.xml
/src/Packages.dgml
*.suo
@jkodroff
jkodroff / gist:9d49e590b20fe1bb06b2
Created April 14, 2015 23:52
Working cron expression in Hangfire
var scheduledTime = DateTime.Today.AddHours(19).AddMinutes(-1).ToUniversalTime();
new RecurringJobManager()
.AddOrUpdate(
"upcoming-jobs-email",
Job.FromExpression(() => ObjectFactory.GetInstance<BackgroundJobs.UpcomingJobsEmails>().Run()),
// M-F, 6:59 PM, but in UTC (as Hangfire can only process UTC) and a minute early so it's on the same day
"{0} {1} * * 1-5"
.ToFormat(scheduledTime.Minute, scheduledTime.Hour)
);