Skip to content

Instantly share code, notes, and snippets.

View duttonw's full-sized avatar

William Dutton duttonw

  • Queensland Government
  • Brisbane, Australia
View GitHub Profile
@duttonw
duttonw / custom-my-account-endpoint.php
Created August 20, 2016 05:13 — forked from claudiosanches/custom-my-account-endpoint.php
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@duttonw
duttonw / KMSKeyPolicy.json
Created December 14, 2018 04:49
KMS policy for cross account org usage
{
"Version": "2012-10-17",
"Id": "key-consolepolicy-4",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${AWS::AccountId}:root"
},
@duttonw
duttonw / key-rotation-lambda.yml
Created December 14, 2018 05:14
cloudformation template for lambda user access key rotation which secret manager will use
---
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
BuildVersion:
Description: Build number
Type: String
Environment:
Description: Deploy Target
Type: String
@duttonw
duttonw / aws-key-rotation-lambda.py
Created December 14, 2018 05:15
lambda python module
import boto3
import json
import logging
import os
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
@duttonw
duttonw / SmtpSecretsManagerWithRotation.yml
Created December 14, 2018 05:22
Cloudformation template for Secrets Manager rotating a user access key
---
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
BuildVersion:
Description: Build number
Type: String
Environment:
Description: Environment
Type: String
@duttonw
duttonw / asgToRoute53Update.cfn.yml
Last active March 31, 2019 00:25
AutoScaling Group to update Route53 hostedZoneID by tag, asgUpdateRoute53.js is the un-minified code in the tamplte
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: AutoScaling Group to Route 53 record update
#ensure you have the Tag DomainMeta set which a value of <HostedZoneId>:<Domain> on the ASG i.e. DomainMeta: Z10MWC8V7JDDU1:www.mydomain.com
Parameters:
Service:
Type: String
Default: 'asgToRoute53'
Description: Service name for this product
@duttonw
duttonw / SsmParamUtil.java
Created May 29, 2019 00:32
SSM Parameter Store as properties for Lambda
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
import com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathRequest;
import com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathResult;
import com.amazonaws.services.simplesystemsmanagement.model.Parameter;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@duttonw
duttonw / Hoxton.SR8 local testing outside aws exception log
Created October 7, 2020 05:21
Spring cloud param store Hoxton.SR6 to Hoxton.SR8 how to run locally
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.4.RELEASE:run (default-cli) @ sec-application ---
[WARNING] Fork mode disabled, devtools will be disabled
Fork mode disabled, devtools will be disabled
Spring Boot: 2.3.4.RELEASE
2020-10-07 15:19:26.759 INFO 27180 --- [ main] a.g.q.s.sample.SampleSpringEntry : The following profiles are active: default,testResources
2020-10-07 15:19:34.439 WARN 27180 --- [ main] c.a.a.p.i.BasicProfileConfigLoader : Your profile name includes a 'profile ' prefix. This is considered part of the profile name in the Java SDK, so you will need to include this prefix in your profile name when you reference this profile from your Java code.
2020-10-07 15:19:34.447 WARN 27180 --- [ main] i.InstanceMetadataServiceResourceFetcher : Fail to retrieve token
com.amazonaws.SdkClientException: Failed to connect to service endpoint:
@duttonw
duttonw / GetInternalNLBIp4List.cfn.yml
Created February 1, 2023 22:55
CFN Template for collecting private ip4 address of a ELBv2 (network)
#In this example we want to get the private ip4 address of a ELBv2 (network)
#Full stack located here: https://github.com/qld-gov-au/quickstart-atlassian-bitbucket/blob/d6ebe59b5ccdd204a7edc72ab6f0f89d575ac6f8/templates/quickstart-bitbucket-dc.template.yaml
#Network Load Balancer health checks, need internal ip to approve connectivity
InternalNLBIp4List:
DependsOn: NetworkLoadBalancerELB2
Type: Custom::InternalNLBIp4ListCollector
Version: 1.0
Properties:
@duttonw
duttonw / AwsParamStoreBatchLoadSecrets.sh
Created June 6, 2024 23:11
AWs Param Store batch lost secrets with helper function (with example)
#!/bin/bash
# Function to set or update a parameter in AWS Parameter Store
set_parameter() {
local PARAM_NAME=$1
local PARAM_VALUE=$2
local IS_SECRET=${3:-false} # Default false, set to true for secret (encrypted) parameters
# Determine the parameter type
if [ "$IS_SECRET" = true ]; then