-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated infra folder structure to account for org_mgmt vs child_accou…
…nts separate cloudformation templates
- Loading branch information
1 parent
8a98731
commit d7ff72b
Showing
9 changed files
with
119 additions
and
41 deletions.
There are no files selected for viewing
Binary file added
BIN
+1.72 KB
infra/org_mgmt_account/api/app/config/__pycache__/connections.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+591 Bytes
infra/org_mgmt_account/api/app/config/__pycache__/logging.cpython-39.pyc
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import boto3 | ||
from botocore.exceptions import NoCredentialsError, PartialCredentialsError | ||
|
||
class AWSConnections: | ||
def __init__(self, region_name: str = "us-east-1"): | ||
self.region_name = region_name | ||
self.sqs_client = None | ||
self.dynamodb_client = None | ||
|
||
def create_sqs_client(self): | ||
try: | ||
self.sqs_client = boto3.client('sqs', region_name=self.region_name) | ||
print("SQS client created successfully") | ||
except (NoCredentialsError, PartialCredentialsError) as e: | ||
print(f"Error creating SQS client: {e}") | ||
|
||
def create_dynamodb_client(self): | ||
try: | ||
self.dynamodb_client = boto3.client('dynamodb', region_name=self.region_name) | ||
print("DynamoDB client created successfully") | ||
except (NoCredentialsError, PartialCredentialsError) as e: | ||
print(f"Error creating DynamoDB client: {e}") | ||
|
||
def get_sqs_client(self): | ||
if not self.sqs_client: | ||
self.create_sqs_client() | ||
return self.sqs_client | ||
|
||
def get_dynamodb_client(self): | ||
if not self.dynamodb_client: | ||
self.create_dynamodb_client() | ||
return self.dynamodb_client | ||
|
||
aws_connections = AWSConnections() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
|
||
def configure_logging(): | ||
# Define the logging configuration | ||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", | ||
handlers=[ | ||
logging.StreamHandler() | ||
] | ||
) | ||
|
||
# Create a logger instance | ||
logger = logging.getLogger("quiet_riot") | ||
return logger | ||
|
||
# Example usage | ||
if __name__ == "__main__": | ||
logger = configure_logging() | ||
logger.info("Logging is configured.") |
This file contains 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
Binary file added
BIN
+412 Bytes
infra/org_mgmt_account/api/app/routers/__pycache__/live.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+1.86 KB
infra/org_mgmt_account/api/app/routers/__pycache__/query.cpython-39.pyc
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from fastapi import APIRouter | ||
from enum import Enum | ||
|
||
router = APIRouter() | ||
|
||
@router.get("/live") | ||
async def live(): | ||
return {"status": "alive"} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from fastapi import APIRouter | ||
from enum import Enum | ||
from pydantic import BaseModel | ||
from typing import List, Union | ||
|
||
router = APIRouter() | ||
|
||
class PrincipalType(str, Enum): | ||
AWS_ACCOUNT_IDS = "AWS Account IDs" | ||
MICROSOFT_365_DOMAINS = "Microsoft 365 Domains" | ||
AWS_SERVICES_FOOTPRINTING = "AWS Services Footprinting" | ||
AWS_ROOT_USER_EMAIL_ADDRESS = "AWS Root User E-mail Address" | ||
AWS_IAM_PRINCIPALS = "AWS IAM Principals" | ||
IAM_ROLES = "IAM Roles" | ||
IAM_USERS = "IAM Users" | ||
MICROSOFT_365_USERS = "Microsoft 365 Users (e-mails)" | ||
GOOGLE_WORKSPACE_USERS = "Google Workspace Users (e-mails)" | ||
|
||
|
||
class QueryRequest(BaseModel): | ||
principal_type: PrincipalType | ||
principal_value: str | ||
|
||
|
||
class BulkQueryRequest(BaseModel): | ||
principal_values: List[str] | ||
|
||
@router.post("/query") | ||
async def query(request: QueryRequest): | ||
# Placeholder for actual query logic | ||
if not request.principal_value: | ||
raise HTTPException(status_code=400, detail="Invalid principal value") | ||
return { | ||
"principal_type": request.principal_type, | ||
"principal_value": request.principal_value, | ||
"status": "queried", | ||
} | ||
|
||
|
||
@router.post("/bulk-query") | ||
async def bulk_query(request: BulkQueryRequest): | ||
# Placeholder for actual bulk query logic | ||
if not request.principal_values: | ||
raise HTTPException(status_code=400, detail="Invalid principal values") | ||
return {"principal_values": request.principal_values, "status": "bulk queried"} |