This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unset AWS_ACCESS_KEY_ID && unset AWS_SECRET_ACCESS_KEY && unset AWS_SESSION_TOKEN && eval $(aws sts assume-role --role-arn "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" --role-session-name "gc-local-shell" | jq -r '"export AWS_ACCESS_KEY_ID=\"" + .Credentials.AccessKeyId + "\"\nexport AWS_SECRET_ACCESS_KEY=\"" + .Credentials.SecretAccessKey + "\"\nexport AWS_SESSION_TOKEN=\"" + .Credentials.SessionToken + "\""') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export AWS_PAGER="" | |
subnetId=$1 | |
if [ -z "$subnetId" ] | |
then | |
echo "No subnet ID provided. Please provide a subnet ID as an argument." | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SynthUtils } from '@aws-cdk/assert'; | |
import * as cdk from 'aws-cdk-lib'; | |
import { Stack, StageSynthesisOptions } from 'aws-cdk-lib'; | |
import { Template } from 'aws-cdk-lib/assertions'; | |
import { InfrastructureStack } from '../../src/lib/infrastructure-stack'; | |
type Options = StageSynthesisOptions & { | |
/** | |
* Ignore Assets | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import os | |
import requests | |
import unittest | |
from unittest.mock import patch | |
import requests_mock | |
def send_slack_message(message, slack_url): | |
slack_response = requests.post( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Sha256 } from '@aws-crypto/sha256-browser'; | |
import { defaultProvider } from '@aws-sdk/credential-provider-node'; | |
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'; | |
import { HttpRequest } from '@aws-sdk/protocol-http'; | |
import { SignatureV4 } from '@aws-sdk/signature-v4'; | |
import { CdkCustomResourceEvent, CdkCustomResourceHandler } from 'aws-lambda'; | |
export async function signRequest(request: HttpRequest, region = 'eu-west-1') { | |
const signer = new SignatureV4({ | |
credentials: defaultProvider(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Sha256 } from '@aws-crypto/sha256-browser'; | |
import { defaultProvider } from '@aws-sdk/credential-provider-node'; | |
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'; | |
import { HttpRequest } from '@aws-sdk/protocol-http'; | |
import { SignatureV4 } from '@aws-sdk/signature-v4'; | |
// import { region } from './http-agent'; use an aws region string | |
// import { getEnv } from './utils'; just calls process.env or returns default | |
export async function indexDocumentonAwsES(body, index, type, id, domain) { | |
const request = new HttpRequest({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defaultProvider } from '@aws-sdk/credential-provider-node'; | |
import { Client } from '@opensearch-project/opensearch'; | |
// tslint:disable-next-line:no-var-requires | |
const createAwsOpensearchConnector = require('aws-opensearch-connector'); | |
export async function getEsClient(node: string = `https://${process.env.elasticsearch}`) { | |
const es = new Client({ | |
...createAwsOpensearchConnector({ | |
credentials: await defaultProvider()(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FrozenDict(dict): | |
def __setitem__(self, key, value): | |
raise TypeError("This dictionary is frozen. You cannot add or modify items.") | |
def __hash__(self): | |
items = tuple(self.items()) | |
return hash(items) | |
my_dict = {"a": 1, "b": 2, "c": 3} | |
my_frozen_dict = FrozenDict(my_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require :cl) | |
(defun calc-pi (n) | |
(let ((in-circle 0)) | |
(loop for i from 1 to n do | |
(let ((x (random 1.0)) | |
(y (random 1.0))) | |
(when (< (+ (* x x) (* y y)) 1) | |
(incf in-circle)))) | |
(* 4 (/ in-circle n)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run with ts-node script.ts --no-cache | |
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | |
/* eslint-disable no-console */ | |
import { | |
ChangeBatch, | |
ChangeResourceRecordSetsCommand, | |
DeleteHostedZoneCommand, | |
ListHostedZonesCommand, | |
ListResourceRecordSetsCommand, |
NewerOlder