Skip to content

Instantly share code, notes, and snippets.

View bahrmichael's full-sized avatar

Michael Bahr bahrmichael

View GitHub Profile
AWSTemplateFormatVersion: '2010-09-09-OC'
Parameters:
instanceArn:
Type: String
principalId:
Type: String
Parameters:
<<: !Include '../organization-parameters.yml'
appName:
Type: String
Default: 'sso'
# AWS SSO instance ARN
instanceArn:
Type: String
Parameters:
<<: !Include "../organization-parameters.yml"
catalogBucket:
Type: String
Default: community-resource-provider-catalog
SsoAssignmentGroupRp:
Type: register-type
ResourceType: "Community::SSO::AssignmentGroup"
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
budgetName:
Type: String
emailAddress:
Type: String
Default: ''
budgetAmount:
Type: Number
Parameters:
<<: !Include '../organization-parameters.yml'
BudgetAlarms:
Type: update-stacks
Template: ./budgets.yml
StackName: !Sub '${resourcePrefix}-billing-alarm'
TerminationProtection: false
DefaultOrganizationBinding:
Region: !Ref primaryRegion
import * as DynamoDB from 'aws-sdk/clients/dynamodb';
import {v4 as uuid} from 'uuid';
const ddb = new DynamoDB.DocumentClient({region: 'us-east-1'});
const t = (startInMinutes: number) => {
const d = new Date(new Date().getTime() + 1_000 * 60 * startInMinutes);
return {
"pk": `j#${d.getUTCFullYear()}-${d.getUTCMonth()}-${d.getUTCDate()}T${d.getUTCHours()}:${d.getUTCMinutes()}`,
"sk": `${d.toISOString()}#${uuid()}`,
test
// file with imports
// old: import { SQS } from "aws-sdk";
import * as SQS from "aws-sdk/clients/sqs";
// eslint rule
"rules": {
"no-restricted-imports": ["error", "aws-sdk"]
}
@bahrmichael
bahrmichael / iam-ddb-query-table-and-index.js
Created July 7, 2021 18:19
An IAM statement which allows the Query operation on a "EventsTable" and a GSI called "eventIdIndex"
{
Effect: 'Allow',
Action: ['dynamodb:Query'],
Resource: [
// assuming a table "EventsTable" with a GSI called "eventIdIndex"
{'Fn::GetAtt': ['EventsTable', 'Arn']},
{'Fn::Join': [ '/', [{ 'Fn::GetAtt': ['EventsTable', 'Arn' ] }, 'index', 'eventIdIndex' ]]}
]
}
def lambda_handler(event, context):
data = event['data']
print(data)
prices = []
types = []
volumes = []
for page_data in data: