Skip to content

AWS-Specific Code References in nf.core Library

This report documents all AWS-specific code, imports, and references found in the nf.core library.

Summary

The nf.core library contains AWS-specific code in the following areas: 1. Backend configuration and state management 2. Provider imports and references 3. Test infrastructure using FakeCloud 4. Performance benchmarks and examples

Detailed Findings

1. Backend Configuration Files

/nf/core/backend_config.py

  • Lines 58-59, 105-126, 149-186: AWS environment detection and configuration
  • Checks for AWS environment variables: AWS_ACCESS_KEY_ID, AWS_PROFILE, ECS_CONTAINER_METADATA_URI
  • Detects EC2 instances via /sys/hypervisor/uuid
  • Configures S3 backend with:
    • Default region: us-east-1 (line 91, 153)
    • S3 bucket naming pattern: nf-state-{account_id}-{region}-{project_name}
    • DynamoDB table naming: nf-state-lock-{account_id}
  • Line 214: Imports boto3 for AWS account ID retrieval

/nf/core/state_engine_factory.py

  • Lines 91-99, 114-122: S3Backend imports and configuration
  • Imports from nf.backends.aws import S3Backend
  • Default region: us-east-1 (lines 96, 119)
  • Configures S3 backend with bucket, key, region, DynamoDB table

/nf/core/transactional_state_engine.py

  • Lines 133-141: S3Backend import and configuration
  • Imports from nf.backends.aws import S3Backend
  • Default region: us-east-1 (line 139)

2. Backend Chain Implementation

/nf/core/backend_chain.py

  • Lines 116-123: S3Backend-specific dependency checking
  • References _bucket_resource and _table_resource attributes
  • Checks for S3 bucket and DynamoDB table resources

3. Provider References

/nf/core/drift/__init__.py

  • Lines 137-142: AWS provider auto-detection
  • Attempts to import from nf.providers.aws import get_provider_client
  • Part of provider auto-detection mechanism

/nf/core/config/config_normalization.py

  • Lines 1-200: Schema-aware configuration normalization
  • Coerces set/list inputs for any provider using schema metadata
  • Replaces AWS-specific endpoint workaround with provider-agnostic handling

/nf/core/schema_utils.py

  • Lines 97-101: AWS provider-specific handling
  • Special handling for endpoints block to prevent AWS provider crashes
  • Comment: "The AWS provider crashes when endpoints have all 297 attributes"

4. Test Infrastructure

/tests/integration/aws/ directory

Contains comprehensive AWS integration tests using FakeCloud:

fakecloud_utils.py
  • Lines 33-110: AWS provider configuration for FakeCloud
  • Imports from nf.providers.hashicorp.aws import AwsProvider
  • Configures AWS services: S3, DynamoDB, SSM, SNS, IAM, Lambda, EC2, etc.
  • Default region: us-east-1
  • Sets AWS environment variables for service endpoints
  • Lines 267-382: Cleanup functions using boto3 for AWS services

5. AWS Resource Examples in Tests

Throughout the test files, there are numerous examples using AWS resources: - aws_instance - aws_vpc - aws_s3_bucket - aws_dynamodb_table - aws_iam_role - aws_lambda_function - aws_security_group - aws_subnet

6. Import Patterns Found

  1. External AWS imports:
  2. import boto3 (backend_config.py, fakecloud_utils.py)
  3. from nf.backends.aws import S3Backend (state_engine_factory.py, transactional_state_engine.py)
  4. from nf.providers.hashicorp.aws import AwsProvider (fakecloud_utils.py)
  5. from nf.providers.aws import get_provider_client (drift/init.py)

  6. AWS-specific constants:

  7. Default region: us-east-1 (multiple files)
  8. AWS service names: s3, dynamodb, ec2, lambda, iam, etc.

Recommendations

  1. Region Configuration: The hardcoded us-east-1 default region appears in multiple places. Consider centralizing this configuration.

  2. Provider Imports: The imports from nf.backends.aws and nf.providers.aws suggest these are separate packages, making the core library dependent on AWS-specific packages.

  3. Backend Detection: The AWS environment detection is tightly integrated into the core backend configuration logic.

  4. Test Dependencies: The integration tests heavily rely on AWS services and FakeCloud, which is AWS-specific.

Files with AWS References

Core implementation files: - /nf/core/backend_config.py - /nf/core/state_engine_factory.py - /nf/core/transactional_state_engine.py - /nf/core/backend_chain.py - /nf/core/drift/__init__.py - /nf/core/endpoints_fix.py - /nf/core/schema_utils.py

Test files (selected): - /tests/integration/aws/*.py (entire directory) - /tests/test_backend_chain.py - /tests/test_backend_bootstrap.py - /tests/test_state_engine.py - /tests/test_drift.py - /tests/test_hcl_output.py - /tests/performance/test_aws_resource_performance*.py

And many more test files containing AWS resource examples and imports.