Skip to content

Commit

Permalink
dbg aws credentials provider issues wip
Browse files Browse the repository at this point in the history
  • Loading branch information
usrbinkat committed Nov 25, 2024
1 parent 602f767 commit a78345e
Show file tree
Hide file tree
Showing 32 changed files with 664 additions and 3,943 deletions.
46 changes: 17 additions & 29 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ../konductor/__main__.py
# ./__main__.py
"""
Konductor Infrastructure as Code Platform
Expand All @@ -8,53 +8,41 @@
import sys
from pulumi import log, export
import pulumi
from typing import NoReturn

from modules.core.initialization import initialize_pulumi
from modules.core.config import get_enabled_modules, get_stack_outputs
from modules.core.metadata import setup_global_metadata
from modules.core.deployment import DeploymentManager

def main() -> None:
def main() -> NoReturn:
"""
Main entry point for Konductor's Pulumi Python Infrastructure as Code (IaC).
Raises:
SystemExit: With code 1 on error, implicit 0 on success
"""
try:
# Initialize Pulumi and load configuration
# Initialize
init_config = initialize_pulumi()

# Set up global metadata
setup_global_metadata(init_config)

# Get the list of enabled modules from the configuration
# Get enabled modules
modules_to_deploy = get_enabled_modules(init_config.config)

if not modules_to_deploy:
log.info("No modules to deploy.")
else:
log.info(f"Deploying modules: {', '.join(modules_to_deploy)}")

# Create a DeploymentManager with the initialized configuration
deployment_manager = DeploymentManager(init_config)

# Deploy the enabled modules
deployment_manager.deploy_modules(modules_to_deploy)

# Generate and export stack outputs
try:
stack_outputs = get_stack_outputs(init_config)
log.info("No modules to deploy")
return

# Export each section separately for better organization
export("compliance", stack_outputs["compliance"])
export("config", stack_outputs["config"])
export("k8s_app_versions", stack_outputs["k8s_app_versions"])
# Deploy
deployment_manager = DeploymentManager(init_config)
deployment_manager.deploy_modules(modules_to_deploy)

log.info("Successfully exported stack outputs")
except Exception as e:
log.error(f"Failed to export stack outputs: {str(e)}")
raise
# Export results
stack_outputs = get_stack_outputs(init_config)
export("outputs", stack_outputs)

except Exception as e:
log.error(f"Unexpected error: {str(e)}")
log.error(f"Deployment failed: {str(e)}")
sys.exit(1)

if __name__ == "__main__":
Expand Down
89 changes: 4 additions & 85 deletions modules/aws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,10 @@
# ./pulumi/modules/aws/__init__.py
"""
AWS Cloud Infrastructure Module
Provides AWS infrastructure management capabilities including organizations,
networking, and resource provisioning with built-in compliance controls.
"""
from typing import List, Optional, Tuple, Dict, Any, TYPE_CHECKING
import pulumi
# ./modules/aws/__init__.py
"""AWS module for Konductor."""

from .types import AWSConfig
from .provider import AWSProvider
from .organization import AWSOrganization
from .resources import ResourceManager
from .networking import NetworkManager
from .iam import IAMManager
from .eks import EksManager
from .security import SecurityManager
from .exceptions import ResourceCreationError, ConfigurationError

if TYPE_CHECKING:
from pulumi import Resource
from .deploy import AWSModule

__all__ = [
'AWSProvider',
'AWSOrganization',
'ResourceManager',
'NetworkManager',
'IAMManager',
'EksManager',
'SecurityManager',
'AWSConfig',
'create_aws_infrastructure',
'ResourceCreationError',
'ConfigurationError'
'AWSModule'
]

def create_aws_infrastructure(
config: AWSConfig,
dependencies: Optional[List[Resource]] = None
) -> Tuple[str, Resource, Dict[str, Any]]:
"""
Creates AWS infrastructure based on the provided configuration.
This is the main entry point for AWS infrastructure creation. It orchestrates
the deployment of all AWS resources including organizations, networking,
security controls, and workload resources.
Args:
config: AWS configuration settings including organization, networking,
security, and workload configurations
dependencies: Optional list of resources this deployment depends on
Returns:
Tuple containing:
- Version string
- Main infrastructure resource (typically the organization)
- Dictionary of outputs including resource IDs and ARNs
Raises:
ValueError: If configuration is invalid
ResourceCreationError: If resource creation fails
"""
try:
# Initialize provider with configuration
provider = AWSProvider(config)

# Create managers in dependency order
security = SecurityManager(provider)
networking = NetworkManager(provider)
organization = AWSOrganization(provider)
resources = ResourceManager(provider)
iam = IAMManager(provider)
eks = EksManager(provider)

# Deploy infrastructure
return provider.deploy(
dependencies,
managers={
"security": security,
"networking": networking,
"organization": organization,
"resources": resources,
"iam": iam,
"eks": eks
}
)

except Exception as e:
pulumi.log.error(f"Failed to create AWS infrastructure: {str(e)}")
raise
Empty file removed modules/aws/accounts.py
Empty file.
Loading

0 comments on commit a78345e

Please sign in to comment.