Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
@brianleroux
brianleroux / cdn-invalidate.js
Created September 21, 2024 13:20
Invalidate a CloudFront CDN distribution cache
import awsLite from '@aws-lite/client'
const aws = await awsLite()
await aws.CloudFront.CreateInvalidation({
CallerReference: Date.now()+'',
Id: 'xxx',
InvalidationBatch: '/*',
})
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Description": "Exported by architect/package@9.0.0-RC.1 on 2024-03-13T16:59:13.480Z",
"Resources": {
"Role": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
@brianleroux
brianleroux / declarative.html
Created July 25, 2023 21:16
declarative vs imperative
<!-- describing what I want -->
<my-apple></my-apple>
@brianleroux
brianleroux / fix-s3.js
Created April 13, 2023 16:08
fix for s3 behaviour change
/**
* put this file in src/plugins/ and add the following to the arcfile:
*
* @plugins
* fix-s3
*/
module.exports = { deploy: { start }}
async function start ({ arc, cloudformation }) {
let ref = cloudformation.Resources.StaticBucket.Properties
In the year 2256, the San Francisco Bay Area Rapid Transit system, known simply as the SF BART, was still a vital part of daily life in the bustling city. Despite the many societal upheavals and wars that had threatened to destroy it, the SF BART had managed to survive and thrive, providing reliable transportation to millions of inhabitants.
The key to the SF BART's success was its adaptability and resilience. When a massive earthquake devastated San Francisco in the early 22nd century, the BART system was able to quickly repair and rebuild, thanks in part to its strong infrastructure and robust emergency protocols. When the city faced a major food shortage, the BART's efficient transportation network allowed for the swift distribution of resources, ensuring that no one went hungry.
But the SF BART's greatest challenge came during the Romulan War. As the war raged on, the city of San Francisco was subjected to numerous bombing raids and ground assaults. The SF BART faced significant damage, but the dedicate
@brianleroux
brianleroux / logs.txt
Created November 16, 2022 23:47
quick test of lambda layer w Deno runtime
Nov 16th 2022, 03:46:08 PM
REPORT RequestId: f949935c-0f0e-4718-9976-9df42585adb5 Duration: 2.05 ms Billed Duration: 3 ms Memory Size: 1152 MB Max Memory Used: 76 MB
Nov 16th 2022, 03:46:04 PM
REPORT RequestId: 89ba7dfa-72d1-4ad7-9dac-2214d1698697 Duration: 4.42 ms Billed Duration: 338 ms Memory Size: 1152 MB Max Memory Used: 75 MB Init Duration: 333.05 ms
@brianleroux
brianleroux / plugin.js
Created July 28, 2022 19:09
make api gateway send back rest api style req/res
/**
* this incantation will set the HttpApi response payload
* format to 1.0 which enables multiple headers
* https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.response
*/
module.exports = {
deploy: {
async start ({ arc, cloudformation }) {
if (!arc) console.log('missing arc')
let base = cloudformation.Resources.HTTP.Properties.DefinitionBody.paths['/']
@brianleroux
brianleroux / fun.js
Created June 14, 2022 16:22
example of runtime resource discovery built into architect
import arc from '@architect/functions'
// send an event to the SNS topic named 'ping'
// … under the hood the ARN is arn:aws:sns:us-west-2:818138539153:appname-ping-Q1C4HOR7RT2H:6bd207a6-4aaf-4015-bad4-a30adf7944f
await arc.events.publish({
name: 'ping',
payload: { pingID: Date.now() }
})
// read from the db table named 'pings'
let aws = require('aws-sdk')
module.exports = {
CloudFormation: aws.CloudFormation,
ApiGatewayV2: aws.ApiGatewayV2,
ACM: aws.ACM,
Route53: aws.Route53,
}
> @architect/architect@9.5.1 test:unit
> cross-env tape 'test/unit/**/*-test.js'
TAP version 13
# Core Architect packages and necessary CLI interfaces are present
ok 1 create found
ok 2 create CLI found
ok 3 deploy found
ok 4 deploy CLI found