Skip to content

Instantly share code, notes, and snippets.

View rupertbg's full-sized avatar

Rupert rupertbg

View GitHub Profile
@rupertbg
rupertbg / ec2-image-builder-issue.md
Created May 29, 2023 05:08
AWS EC2 Image Builder removes cronie

Here is a note that should be in the docs

AWS EC2 Image Builder has a script that runs for linux builds called RunSanitizeScript

This script removes a few things that the AMI builder process adds.

One of those things is the package cronie on Amazon Linux.

If you actually want this package then you have to install it another way, maybe via User Data?

@rupertbg
rupertbg / codebuild-secondary-buildspec.yml
Last active October 7, 2023 10:29
Use the buildspec.yml from another (Secondary Source) repo for your Source repo in AWS CodeBuild (Demonstrated with Cloudformation)
CodeBuildProject:
Type: AWS::CodeBuild::Project
Properties:
Name: !Ref GitHubRepoName
BadgeEnabled: true
Description: Builds a Docker image using a BuildSpec from another repo
ServiceRole: !ImportValue Your-CodeBuild-Role
TimeoutInMinutes: 15
Artifacts:
Type: NO_ARTIFACTS
@rupertbg
rupertbg / self-deleting-ec2.yml
Created August 19, 2019 04:37
A self-deleting EC2 Instance in a Cloudformation stack
AWSTemplateFormatVersion: 2010-09-09
Description: A self-deleting EC2 instance
Parameters:
VpcId:
Type: AWS::EC2::VPC::Id
Description: VPC to use
InstanceType:
AWSTemplateFormatVersion: 2010-09-09
Description: Sumo Logic CloudWatch log collector
Parameters:
Environment:
Type: String
AllowedValues:
- test
- prod
Default: test
@rupertbg
rupertbg / alb_sumo.txt
Created April 26, 2019 13:18
AWS Application Load Balancer (ALB, ELB v2) log message parse query for Sumologic
parse "* * * * * * * * * * * * \"*\" \"*\" * * * \"*\" \"*\" \"*\" * * \"*\" \"*\" \"*\"" as type, timestamp, elb, client, target, request_processing_time, target_processing_time, response_processing_time, elb_status_code, target_status_code, received_bytes, sent_bytes, request, user_agent, ssl_cipher, ssl_protocol, target_group_arn, trace_id, domain_name, chosen_cert_arn, matched_rule_priority, request_creation_time, actions_executed, redirect_url, error_reason
@rupertbg
rupertbg / get-codepipeline-execution-id-within-codebuild.sh
Last active April 1, 2024 12:49
Get a CodePipeline Execution ID from within a CodeBuild Job
aws codepipeline get-pipeline-state --region us-west-2 --name ${CODEBUILD_INITIATOR#codepipeline/} --query 'stageStates[?actionStates[?latestExecution.externalExecutionId==`'${CODEBUILD_BUILD_ID}'`]].latestExecution.pipelineExecutionId' --output text
@rupertbg
rupertbg / delete-policies.sh
Created February 7, 2018 07:17
AWS CLI delete policies including all versions (requires jq)
#!/bin/bash
set -euxo pipefail;
policies=$(cat ./policies.txt); # A new-line separated list of policy ARNs
for policy in $policies; do
policiesVersions="$(aws iam list-policy-versions --policy-arn "$policy" | jq -r ".Versions[] | select(.IsDefaultVersion == false) | .VersionId")";
for pv in $policiesVersions; do
aws iam delete-policy-version --policy-arn "$policy" --version-id $pv;
done;
@rupertbg
rupertbg / fizzbuzz.js
Last active February 14, 2019 02:52
Simple JS FizzBuzz Solution
for (var i = 1; i <= 30; i++) {
var output = "";
!(i % 3) ? output += 'fizz' : null;
!(i % 5) ? output += 'buzz' : null;
output ? console.log(i, output) : null;
}
@rupertbg
rupertbg / li-profile-show.js
Last active February 25, 2017 01:47
View full LinkedIn profile, without logging in, when 'advocate-modal' is restricting page scroll. Run in browser console.
document.getElementsByClassName('advocate-modal-visible')[0].classList.remove('advocate-modal-visible'); document.getElementById('advocate-modal')[0].style.display = "none";