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 re | |
| import time | |
| from dataclasses import dataclass | |
| from functools import lru_cache | |
| from pathlib import Path | |
| from typing import Any, ClassVar, Final, Literal | |
| import boto3 | |
| from botocore.config import Config | |
| from botocore.exceptions import ClientError |
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
| from typing import Any | |
| from dotenv import load_dotenv | |
| from langchain_aws import ChatBedrockConverse | |
| from langchain_core.prompts import PromptTemplate | |
| from langchain_core.runnables import RunnableLambda, RunnableParallel | |
| from pydantic import BaseModel, Field | |
| load_dotenv('.env') |
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
| --- | |
| Resources: | |
| QueueForPipe: | |
| Type: AWS::SQS::Queue | |
| LambdaServiceRole: | |
| Type: AWS::IAM::Role | |
| Properties: | |
| AssumeRolePolicyDocument: | |
| Statement: | |
| - Action: sts:AssumeRole |
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
| #!/usr/bin/env python3 | |
| import boto3 | |
| import os | |
| # Example usage from a bash shell: | |
| # PREFIX='AWS COMM' AWS_PROFILE=comm-mgmt ROLE_NAME=AWSControlTowerExecution python ./aws_switch_role_bookmark_generator.py > "./aws-switch-role-bookmarks.html" | |
| # Environment variables for configuration | |
| role_name = os.environ.get("ROLE_NAME", "OrganizationAccountAccessRole") |
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
| #!/usr/bin/env python | |
| import boto3 | |
| import json | |
| sechub = boto3.client("securityhub") | |
| sts = boto3.client("sts") | |
| caller_arn = sts.get_caller_identity()["Arn"] | |
| print(caller_arn) |
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
| AWSTemplateFormatVersion: "2010-09-09" | |
| Description: Creates a Step Functions State Machine that is executed when new items are added to a DynamoDB Table. | |
| Resources: | |
| Table: | |
| Type: "AWS::DynamoDB::Table" | |
| Properties: | |
| AttributeDefinitions: | |
| - AttributeName: "PK" | |
| AttributeType: "S" | |
| KeySchema: |
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
| def dict_dot_notation(d, path=[]): | |
| d2 = {} | |
| for k, v in d.items(): | |
| k_path = path + [str(k)] | |
| k_formatted = ".".join(k_path) | |
| if isinstance(v, dict): | |
| # merge in dict with recursive call | |
| d2 = {**d2, **dict_dot_notation(v, path=k_path)} | |
| elif isinstance(v, list) or isinstance(v, tuple): |
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
| it('should persist user to dynamodb', async () => { | |
| await createUser(userInput); | |
| expect(mockDynamoDbDocumentClient).toHaveReceivedCommandWith(PutCommand, { | |
| TableName: 'TestUserTable', | |
| Item: userToCreate, | |
| }); | |
| }); |
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
| /*Remove null properties from a nested json object*/ | |
| function parse(input) { | |
| if ( | |
| input == null || | |
| (Array.isArray(input) && input.length == 0) || | |
| JSON.stringify(input) == "{}" | |
| ) { | |
| return null; | |
| } |
NewerOlder