Skip to content

Instantly share code, notes, and snippets.

View Rud5G's full-sized avatar
🏡
Working remotely

Rudger Rud5G

🏡
Working remotely
View GitHub Profile
export interface EnvironmentConfig {
env: {
account: string;
region: string;
};
stageName: string;
stateful: {
bucketName: string;
};
stateless: {
@Rud5G
Rud5G / pipeline-stack.ts
Created November 23, 2023 14:25 — forked from leegilmorecode/pipeline-stack.ts
Example running Cypress in a CDK Pipelines pipeline
...
// add the feature-dev stage with the relevant environment config to the pipeline
// this is the test stage (beta)
const featureDevStage: PipelineStage = new PipelineStage(
this,
'FeatureDev',
{
...environments.featureDev,
}
@Rud5G
Rud5G / Dockerfile
Created August 17, 2023 14:35 — forked from huksley/Dockerfile
AWS ECS cluster with CDK for NextJS deployment
#
# Based on offical image from https://nextjs.org/docs/deployment#docker-image
# See dockerfile: https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
#
FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat git curl python3 make g++
WORKDIR /opt/app
RUN addgroup --system --gid 1001 app
RUN adduser --system --uid 1001 app -h /opt/app
@Rud5G
Rud5G / parameterStore.ts
Created August 3, 2023 15:48 — forked from rnag/parameterStore.ts
Create or obtain values from the AWS Parameter store with Typescript/node
import { SSM } from 'aws-sdk';
/**
* Get the value for a parameter in SSM Parameter Store. By default, decrypt
* the value as we assume it is stored as a "SecretString"
*
* Ref: https://gist.github.com/cbschuld/938190f81d00934f7a158ff223fb5e02
*
* @param ssm The SSM client
* @param name Name of the parameter
@Rud5G
Rud5G / parameterStore.ts
Created August 3, 2023 15:48 — forked from cbschuld/parameterStore.ts
Obtain values from the AWS Parameter store with Typescript/node
import { SSM } from "aws-sdk";
const getParameterWorker = async (name:string, decrypt:boolean) : Promise<string> => {
const ssm = new SSM();
const result = await ssm
.getParameter({ Name: name, WithDecryption: decrypt })
.promise();
return result.Parameter.Value;
}
@Rud5G
Rud5G / manually-remove-resource-from-amplify-project.md
Created February 28, 2023 14:53 — forked from josefaidt/manually-remove-resource-from-amplify-project.md
Instructions for surgically removing non-existent resource from local Amplify project

Let's say we've removed a Lambda Layer from the Lambda Console and are no longer able to perform operations using the Amplify CLI.

An error occurred fetching the latest layer version metadata for ""

> amplify remove function
? Choose the resource you would want to remove 10263layer58c94806 (layer)
When you delete a layer version, you can no longer configure functions to use it.
However, any function that already uses the layer version continues to have access to it.
✖ Loading layer data from the cloud...
#!/usr/bin/env node
const { existsSync: exists, promises: fs } = require('fs');
const { spawn } = require('child_process');
const path = require('path');
const c = require('chalk');
const dotenv = require('dotenv');
const nodemon = require('nodemon');
// set default node_env
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
@Rud5G
Rud5G / post-checkout
Created February 28, 2023 14:51 — forked from josefaidt/post-checkout
Git post-checkout hook to change AWS Amplify environments upon branch checkout
#!/bin/bash
# .git/hooks/post-checkout
# Utility to change AWS Amplify environments on branch checkout
# helper to get path to aws-exports.js
function get_aws_exports_path {
local AMPLIFY_PROJECT_CONFIG_PATH="amplify/.config/project-config.json"
local AMPLIFY_EXPORTS_PATH=$(jq -r '.javascript.config.SourceDir' $AMPLIFY_PROJECT_CONFIG_PATH)
if [[ "$AMPLIFY_EXPORTS_PATH" == */ ]]
const fn = new lambda.NodejsFunction(this, 'MyFunction', {
entry: fileURLToPath(new URL('./handler.ts', import.meta.url)),
functionName: `my-function`,
bundling: {
minify: true, // minify code, defaults to false
sourceMap: true, // include source map, defaults to false
sourceMapMode: lambda.SourceMapMode.INLINE, // defaults to SourceMapMode.DEFAULT
target: 'esnext',
define: {
'import.meta.vitest': 'undefined',