### Module reference during installation step 1 Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/.header.md References the module in Terraform configuration with the same parameters as the Quick Start example, used as the first step of installation. ```hcl module "transfer_connector" { source = "aws-ia/transfer-family/aws//modules/transfer-connectors" url = "sftp://external-server.com" access_role = "arn:aws:iam::123456789012:role/transfer-connector-role" sftp_username = "sftp-user" sftp_private_key = file("~/.ssh/id_rsa") tags = { Environment = "Dev" Project = "File Transfer" } } ``` -------------------------------- ### One-shot deploy with terraform init and apply Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/.header.md Deploys the entire example pipeline in one run. All enable_* flags in variables.tf default to true, so a fresh apply provisions the full setup. ```bash cd examples/sftp-automated-workflows-agentcore terraform init terraform apply ``` -------------------------------- ### Run Terratest Tests Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/CONTRIBUTING.md Set up and run Terratest tests for the examples and root modules. Includes initializing the Go module, installing the Terratest terraform module, and running tests with a 45-minute timeout. ```sh # from the root of the repository cd test go mod init github.com/aws-ia/terraform-project-ephemeral go mod tidy go install github.com/gruntwork-io/terratest/modules/terraform go test -timeout 45m ``` -------------------------------- ### Quick start - SFTP Connector Terraform module Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/README.md Creates an SFTP connector using the module. Ensure the access_role ARN is provided, as it is not created by the module. The example sets the remote server URL, IAM role, SFTP username and private key, and optional tags. ```hcl module "transfer_connectors" { source = "aws-ia/transfer-family/aws//modules/transfer-connectors" url = "sftp://external-server.com" access_role = "arn:aws:iam::123456789012:role/transfer-connector-role" sftp_username = "sftp-user" sftp_private_key = file("~/.ssh/id_rsa") tags = { Environment = "Dev" Project = "File Transfer" } } ``` -------------------------------- ### Copy example configuration Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/examples/complete/README.md Copies the example Terraform variables file to terraform.tfvars for customization. ```bash cp terraform.tfvars.example terraform.tfvars ``` -------------------------------- ### Test User Configuration Example Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sample-web-app/.header.md Example configuration for the test_users variable. Only used when create_test_users_and_groups is set to true. ```hcl test_users = { "admin" = { display_name = "Admin User" user_name = "admin" first_name = "Admin" last_name = "User" email = "admin@example.com" } } # Note: Only used when create_test_users_and_groups = true ``` -------------------------------- ### Initialize and apply Terraform Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/examples/complete/README.md Runs Terraform init, plan, and apply to deploy the example infrastructure. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Simple SFTP Server Setup Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/.header.md Configuration for a basic SFTP server using the transfer-server module with logging enabled. ```hcl module "transfer_server" { source = "aws-ia/transfer-family/aws//modules/transfer-server" # Basic server configuration server_name = "demo-transfer-server" domain = "S3" protocols = ["SFTP"] endpoint_type = "PUBLIC" identity_provider = "SERVICE_MANAGED" # Enable logging enable_logging = true log_retention_days = 14 tags = { Environment = "Demo" Project = "SFTP" } } ``` -------------------------------- ### Apply configuration during installation step 4 Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/.header.md Runs terraform apply to apply the configuration. ```bash terraform apply ``` -------------------------------- ### Basic connector configuration in Quick Start section Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/.header.md Creates an SFTP connector with specified URL, IAM access role, SFTP credentials, and tags. The access_role must be provided; the module does not create it. ```hcl module "transfer_connectors" { source = "aws-ia/transfer-family/aws//modules/transfer-connectors" url = "sftp://external-server.com" access_role = "arn:aws:iam::123456789012:role/transfer-connector-role" sftp_username = "sftp-user" sftp_private_key = file("~/.ssh/id_rsa") tags = { Environment = "Dev" Project = "File Transfer" } } ``` -------------------------------- ### Initialize Terraform workspace during installation step 2 Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/.header.md Runs terraform init to initialize the Terraform workspace after referencing the module. ```bash terraform init ``` -------------------------------- ### Destroy infrastructure Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/examples/complete/README.md Destroys all resources created by the example. ```bash terraform destroy ``` -------------------------------- ### Review planned changes during installation step 3 Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/.header.md Runs terraform plan to review the changes that will be applied. ```bash terraform plan ``` -------------------------------- ### Test Group Configuration Example Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sample-web-app/.header.md Example configuration for the test_groups variable. Only used when create_test_users_and_groups is set to true. The s3_path is auto-prefixed with the bucket name. ```hcl test_groups = { "admins" = { group_name = "Admins" description = "Read and write access to files" members = ["admin"] access_grants = [{ s3_path = "/*" # Auto-prefixed with bucket name permission = "READWRITE" }] } } # Note: Only used when create_test_users_and_groups = true ``` -------------------------------- ### direnv Setup for SFTP Connector Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-send/.header.md Alternatively, use the provided .envrc file with direnv to set environment variables and then run Terraform. ```bash direnv allow terraform init terraform apply ``` -------------------------------- ### Get CloudFront URL Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/examples/complete/README.md Outputs the CloudFront URL for the landing page. ```bash terraform output cloudfront_url ``` -------------------------------- ### Implementation location of transfer-users module Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-internet-facing-vpc-endpoint-service-managed-S3/README.md Indicates where the user import module is located and how it is called in the example. ```text Located in: modules/transfer-users Called by: examples/sftp-internet-facing-vpc-endpoint-service-managed-S3 ``` -------------------------------- ### Configure Transfer Users module Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/.header.md Example configuration for the transfer-users module, linking it to the server, S3 bucket, and KMS key. ```hcl module "sftp_users" { source = "aws-ia/transfer-family/aws//modules/transfer-users" users = local.users create_test_user = true # Test user is for demo purposes.... server_id = module.transfer_server.server_id s3_bucket_name = module.s3_bucket.s3_bucket_id s3_bucket_arn = module.s3_bucket.s3_bucket_arn kms_key_id = aws_kms_key.transfer_family_key.arn } ``` -------------------------------- ### Correct MFA password format example Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-okta/.header.md Shows the correct format for entering a password and TOTP code when MFA is enabled: concatenate them with no spaces or separators. The example uses password 'MyPass123' and TOTP code '456789' to enter 'MyPass123456789'. ```bash # Password: MyPass123 # TOTP Code: 456789 # Enter: MyPass123456789 (no spaces, no separators) ``` -------------------------------- ### Staged walkthrough scripts Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/.header.md Runs the staged walkthrough scripts to deploy and test each layer incrementally, ending with a full teardown. See walkthrough/README.md and walkthrough/DEMO-SETUP.md for the full guide. ```bash cd walkthrough/scripts ./stage0-deploy.sh # foundation ./stage1-deploy.sh # transfer server ./stage1-test.sh # SFTP upload smoke test ./stage2-deploy.sh # malware protection ./stage2-test.sh ./stage3-deploy.sh # AI orchestration ./stage3-test.sh ./stage4-deploy.sh # web app ./cleanup.sh # full teardown ``` -------------------------------- ### Environment Variables Setup Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-dynamic/.header.md Set required environment variables using TF_VAR_ prefix. Either provide an existing secret ARN or provide credentials to create a new secret. ```bash export TF_VAR_sftp_server_endpoint="example.com" # Either provide an existing secret ARN export TF_VAR_existing_secret_arn="arn:aws:secretsmanager:region:account-id:secret:secret-name" # Or provide credentials to create a new secret export TF_VAR_sftp_username="your-username" export TF_VAR_sftp_private_key="$(cat ~/.ssh/id_rsa)" export TF_VAR_trusted_host_keys='["ssh-rsa AAAAB3NzaC1yc2EAAAA..."]' export TF_VAR_source_directory="/uploads" export TF_VAR_eventbridge_schedule="rate(1 hour)" export TF_VAR_enable_dynamodb_tracking="true" export TF_VAR_aws_region="us-east-1" terraform init terraform apply ``` -------------------------------- ### terraform.tfvars Example with Non-Default Values for Malware Protection Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-malware-protection-guardduty/.header.md Shows non-default values for various variables to customize the example. Includes AWS region, user management, file organization prefixes, malware protection settings, and resource tagging. The defaults for each variable are noted in comments. ```hcl # AWS Configuration aws_region = "us-west-2" # Deploy to different AWS region (default: us-east-1) # User Management users_file = "custom-users.csv" # Use different CSV file for user definitions (default: users.csv) create_test_user = false # Skip creating test user (default: true) # File Organization clean_prefix = "clean/" # Add prefix to clean files destination (default: null - root of bucket) quarantine_prefix = "quarantine/" # Add prefix to quarantined files (default: null - root of bucket) error_prefix = "errors/" # Add prefix to error files (default: null - root of bucket) # Malware Protection Settings sns_topic_arn_for_threats = "arn:aws:sns:us-east-1:123456789012:malware-alerts" # Enable SNS notifications for malware detection (default: null - no notifications) enable_object_tagging = false # Disable GuardDuty automatic object tagging (default: true) object_prefixes_to_scan = ["user1", "user2", "uploads"] # Scan only specific directories (default: [] - scan all files) # Resource Tagging tags = { # Override default tags Environment = "Development" Project = "File Transfer" Owner = "MyTeam" } ``` -------------------------------- ### Reference Transfer Family Modules Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/.header.md Example of how to reference the transfer-server and transfer-connectors modules in your Terraform configuration. ```hcl module "transfer_server" { source = "aws-ia/transfer-family/aws//modules/transfer-server" # Module parameters # ... } module "transfer_connectors" { source = "aws-ia/transfer-family/aws//modules/transfer-connectors" # Required parameters url = "sftp://external-server.com" access_role = "arn:aws:iam::123456789012:role/transfer-connector-role" # Optional parameters sftp_username = "sftp-user" sftp_private_key = file("~/.ssh/id_rsa") trusted_host_keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAA..."] # ... } ``` -------------------------------- ### Basic usage with trusted host keys Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-connectors/.header.md SFTP connector setup including trusted_host_keys for server identity verification, in addition to credentials and tags. ```hcl module "transfer-connectors" { source = "aws-ia/transfer-family/aws//modules/transfer-connectors" url = "sftp://external-server.com" access_role = "arn:aws:iam::123456789012:role/transfer-connector-role" sftp_username = "sftp-user" sftp_private_key = file("~/.ssh/id_rsa") trusted_host_keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAA..." ] tags = { Environment = "Demo" Project = "File Transfer" } } ``` -------------------------------- ### Transfer Users Module Configuration Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-internet-facing-vpc-endpoint-service-managed-S3/.header.md Configuration block for the transfer-users module within the main example. ```hcl module "sftp_users" { source = "../../modules/transfer-users" users = local.users create_test_user = true # Test user is for demo purposes server_id = module.transfer_server.server_id s3_bucket_name = module.s3_bucket.s3_bucket_id s3_bucket_arn = module.s3_bucket.s3_bucket_arn kms_key_id = aws_kms_key.transfer_family_key.arn } ``` -------------------------------- ### Environment Variables Setup Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-static/.header.md Set required variables as environment variables using TF_VAR_ prefix, then run terraform init and apply. Either provide an existing secret ARN or credentials to create a new secret. ```bash export TF_VAR_sftp_server_endpoint="example.com" # Either provide an existing secret ARN export TF_VAR_existing_secret_arn="arn:aws:secretsmanager:region:account-id:secret:secret-name" # Or provide credentials to create a new secret export TF_VAR_sftp_username="your-username" export TF_VAR_sftp_private_key="$(cat ~/.ssh/id_rsa)" export TF_VAR_trusted_host_keys='["ssh-rsa AAAAB3NzaC1yc2EAAAA..."]' export TF_VAR_file_paths_to_retrieve='["/uploads/report.csv", "/data/file1.txt"]' export TF_VAR_eventbridge_schedule="rate(1 hour)" export TF_VAR_aws_region="us-east-1" terraform init terraform apply ``` -------------------------------- ### Useful Commands: terraform output, aws sts, aws s3, aws cognito-idp Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Useful commands for the demo: view all Terraform outputs, get a specific output (transfer_server_endpoint), check the AWS account, list S3 buckets, and view Cognito users using the output from terraform output -raw cognito_user_pool_id. ```bash # View all Terraform outputs terraform output # Get specific output terraform output -raw transfer_server_endpoint # Check AWS account aws sts get-caller-identity # List S3 buckets aws s3 ls # View Cognito users aws cognito-idp list-users --user-pool-id $(terraform output -raw cognito_user_pool_id) ``` -------------------------------- ### Quick Start: Transfer Web App Module Configuration Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-web-app/.header.md Minimal configuration to create a Transfer Family web app. Requires an IAM Identity Center instance ARN and identity store ID. Defines users and groups with S3 Access Grants for permissions. Tags are optional. ```hcl module "transfer_web_app" { source = "aws-ia/transfer-family/aws//modules/transfer-web-app" # Required Identity Center Configuration identity_center_instance_arn = "arn:aws:sso:::instance/ssoins-1234567890abcdef" identity_store_id = "d-1234567890" # Identity Center Users and Groups identity_center_users = [ { username = "admin" access_grants = [{ s3_path = "bucket/*" permission = "READWRITE" }] } ] identity_center_groups = [ { group_name = "Analysts" access_grants = [{ s3_path = "bucket/*" permission = "READ" }] } ] tags = { Environment = "Demo" Project = "File Portal" } } ``` -------------------------------- ### Quick Start Terraform Module Configuration Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-malware-protection/.header.md Basic configuration for the Transfer Family Malware Protection module, specifying the ingestion bucket and routing destinations for various scan outcomes. ```hcl module "guardduty_malware_protection" { source = "aws-ia/transfer-family/aws//modules/transfer-malware-protection" s3_ingest_bucket = { bucket_name = "[ingest-bucket-name]" object_prefixes = ["[ingest-prefix-list]"] } routing_config = { "NO_THREATS_FOUND" = "[output-bucket]/[output-prefix]" "THREATS_FOUND" = "[output-bucket]/[output-prefix]" "UNSUPPORTED" = "[output-bucket]/[output-prefix]" "ACCESS_DENIED" = "[output-bucket]/[output-prefix]" "FAILED" = "[output-bucket]/[output-prefix]" } } ``` -------------------------------- ### Implementation of User Import Module Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-public-endpoint-service-managed-S3/.header.md Shows the module call for the transfer-users module, which handles user import. It is located in modules/transfer-users and called by this example. The module requires the server ID, S3 bucket details, and KMS encryption ARN. ```hcl module "sftp_users" { source = "../../modules/transfer-users" users = local.users create_test_user = local.create_test_user server_id = module.transfer_server.server_id s3_bucket_name = module.s3_bucket.s3_bucket_id s3_bucket_arn = module.s3_bucket.s3_bucket_arn sse_encryption_arn = aws_kms_key.sse_encryption.arn } ``` -------------------------------- ### Output Format Example: JSON array of document extraction objects Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/agent-source-code/document_extraction_agent/prompts/system_prompt.txt Shows the exact JSON structure the agent must return. Each object contains s3_path, doc_type, and an extracted map where each field is wrapped with a value and confidence. The example covers three document types: policy_document, photo, and repair-estimate. Confidence values must follow the scoring guidelines: 1.0 for clear, 0.9 for minor interpretation, 0.7–0.89 for partial visibility, 0.5–0.69 for best guesses, and 0.0 when absent. Placeholders should not be used; real values are expected. ```json [ {{"s3_path": "claim-123/policy.pdf", "doc_type": "policy_document", "extracted": {{ "policy_number": {{"value": "POL-12345", "confidence": 0.95}}, "policyholder_name": {{"value": "Jane Doe", "confidence": 0.92}}, "coverage_type": {{"value": "comprehensive", "confidence": 0.88}}, "coverage_limit": {{"value": 50000, "confidence": 0.85}}, "deductible": {{"value": 1000, "confidence": 0.90}}, "effective_date": {{"value": "2025-01-15", "confidence": 0.95}}, "expiration_date": {{"value": null, "confidence": 0.0}}, "beneficiaries": {{"value": ["Jane Doe"], "confidence": 0.80}}, "additional_notes": {{"value": null, "confidence": 0.0}} }}}}, {{"s3_path": "claim-123/photo.jpg", "doc_type": "photo", "extracted": {{ "damage_type": {{"value": "vehicle", "confidence": 0.90}}, "severity": {{"value": "moderate", "confidence": 0.75}}, "description": {{"value": "Dent on front bumper with paint scratches", "confidence": 0.85}}, "affected_areas": {{"value": ["front_bumper"], "confidence": 0.88}} }}}}, {{"s3_path": "claim-123/estimate.pdf", "doc_type": "repair-estimate", "extracted": {{ "shop_name": {{"value": "AutoFix Pro", "confidence": 0.95}}, "estimate_date": {{"value": "2025-02-10", "confidence": 0.90}}, "line_items": {{"value": [ {{"description": "Front bumper replacement", "cost": 1200}}, {{"description": "Paint work", "cost": 600}}, {{"description": "Labor (3 hrs)", "cost": 450}} ], "confidence": 0.88}}, "total_cost": {{"value": 2250, "confidence": 0.92}}, "labor_hours": {{"value": 3, "confidence": 0.85}} }}}} ] ``` -------------------------------- ### Test Upload to Main SFTP Bucket Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-send/.header.md Get the main bucket name from Terraform outputs and upload a test file to trigger the automatic transfer. ```bash # Get the main bucket name from Terraform outputs terraform output sftp_bucket_name # Upload a test file aws s3 cp test-file.txt s3://$(terraform output -raw sftp_bucket_name)/ ``` -------------------------------- ### Quick Start: Create a basic SFTP Transfer Server Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/.header.md Use this Terraform configuration to create a minimal AWS Transfer Family SFTP server with SERVICE_MANAGED identity provider and S3 domain. The module source is aws-ia/transfer-family/aws//modules/transfer-server. Tags are optional but recommended for environment and project identification. ```hcl module "transfer_sftp" { source = "aws-ia/transfer-family/aws//modules/transfer-server" identity_provider = "SERVICE_MANAGED" protocols = ["SFTP"] domain = "S3" tags = { Environment = "Dev" Project = "File Transfer" } } ``` -------------------------------- ### Test Upload to Test Bucket Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-send/.header.md Get the test bucket name from Terraform outputs and upload a test file to trigger the automatic transfer. ```bash # Get the test bucket name from Terraform outputs terraform output test_bucket_name # Upload a test file aws s3 cp test-file.txt s3://$(terraform output -raw test_bucket_name)/ ``` -------------------------------- ### S3 Path Auto-Prefix Example Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sample-web-app/.header.md Shows how the s3_path value is automatically prefixed with the bucket name in the module call. The comment indicates that "/*" becomes "bucket-name/*". ```hcl s3_path = "/*" # Becomes "bucket-name/*" in the module call ``` -------------------------------- ### Check S3 Bucket for Retrieved Files Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-static/.header.md Check the S3 bucket for retrieved files. Get the bucket name from Terraform outputs and list files under the retrieved-files prefix. ```bash # Get the S3 bucket name from Terraform outputs terraform output s3_bucket_name # List retrieved files aws s3 ls s3://$(terraform output -raw s3_bucket_name)/retrieved-files/ ``` -------------------------------- ### Column details for users.csv Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-internet-facing-vpc-endpoint-service-managed-S3/README.md Describes the columns in the users.csv file: username (unique identifier), home_dir (S3 bucket path starting with /), public_key (SSH public key format), and role_arn (optional custom IAM role ARN). ```text username: Unique identifier for SFTP access home_dir: S3 bucket path (must start with /) public_key: SSH public key for authentication (ssh-rsa or ecdsa-sha2-nistp256/384/521) role_arn: (Optional) Custom IAM role ARN ``` -------------------------------- ### Query DynamoDB Transfer Records Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-static/.header.md Monitor transfer metadata in DynamoDB if tracking is enabled. Get the table name from Terraform outputs and scan for transfer records. ```bash # Get the DynamoDB table name from Terraform outputs (if enabled) terraform output dynamodb_table_name # Query transfer records aws dynamodb scan --table-name $(terraform output -raw dynamodb_table_name) ``` -------------------------------- ### SFTP Authentication with Password and TOTP Concatenation Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-okta/.header.md When MFA is enabled, users concatenate their password with the TOTP code (no separator) and use it as the SFTP password. The example shows the command and the password entry. ```bash # If password is "MySecurePass123" and TOTP code is "456789" # Enter: MySecurePass123456789 sftp user@example.com@server-endpoint Password: MySecurePass123456789 ``` -------------------------------- ### Quick Start: Module Usage Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-malware-protection/README.md Defines a Terraform module call using the 'aws-ia/transfer-family/aws//modules/transfer-malware-protection' source. Configures the ingest S3 bucket with object prefixes and maps routing for scan results (NO_THREATS_FOUND, THREATS_FOUND, UNSUPPORTED, ACCESS_DENIED, FAILED) to output destinations. The module handles GuardDuty scanning, EventBridge, optional SQS, Lambda processing, and optional SNS/DLQ. ```hcl module "guardduty_malware_protection" { source = "aws-ia/transfer-family/aws//modules/transfer-malware-protection" s3_ingest_bucket = { bucket_name = "[ingest-bucket-name]" object_prefixes = ["[ingest-prefix-list]"] } routing_config = { "NO_THREATS_FOUND" = "[output-bucket]/[output-prefix]" "THREATS_FOUND" = "[output-bucket]/[output-prefix]" "UNSUPPORTED" = "[output-bucket]/[output-prefix]" "ACCESS_DENIED" = "[output-bucket]/[output-prefix]" "FAILED" = "[output-bucket]/[output-prefix]" } } ``` -------------------------------- ### One-shot deployment Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Recommended for first-time evaluation to provision the full pipeline in a single run. ```bash cd .. terraform init terraform apply ``` -------------------------------- ### Customize deployment with terraform.tfvars Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-entra-lambda/.header.md Use this HCL configuration to customize the deployment by setting AWS region, name prefix, Entra ID parameters, and tags. The Entra ID client secret must be stored in AWS Secrets Manager as Plaintext before running the example. ```hcl # terraform.tfvars aws_region = "us-east-1" name_prefix = "my-sftp" entra_usernames = ["user@example.onmicrosoft.com"] entra_provider_name = "example.onmicrosoft.com" entra_client_id = "a11aaaa1-1111-1a11-111a-11a11a1a11aa" entra_authority_url = "https://login.microsoftonline.com/xyz" entra_client_secret_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:entra-secret-AbCdEf" default_user_ipv4_allow_list = ["10.0.0.0/8"] tags = { Environment = "production" Project = "secure-file-transfer" } ``` -------------------------------- ### Stage 0 deployment and verification Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Deploy the foundation layer and verify environment settings. ```bash ./stage0-deploy.sh # IAM Identity Center, Cognito, Custom IDP Lambda, # 4 AgentCore agent runtimes ./stage0-verify.sh # Verify environment + Bedrock model access ``` -------------------------------- ### Demo helper scripts Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Scripts to assist with live demonstrations and monitoring. ```bash ./run_demo.sh # Starter narration for a presented demo ./monitor_agents.sh all # Tail all agent + orchestrator logs (color-coded) ./view_results.sh # List processed claims + open summary.html ``` -------------------------------- ### Stage 1: Transfer Server Deploy and Test Commands Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Commands to deploy and test the SFTP server for Stage 1. Run these from the demo environment directory. ```bash ./stage1-deploy.sh # Deploy SFTP server ./stage1-test.sh # Test SFTP upload ``` -------------------------------- ### Terraform Init and Apply Commands Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-send/.header.md Run these commands after configuring terraform.tfvars to initialize and apply the Terraform configuration. ```bash terraform init terraform apply ``` -------------------------------- ### Test SFTP connection for user1 (explicit config) Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-cognito-lambda/.header.md Sets environment variables for server endpoint and username, then connects via sftp and lists bucket root. The user will be prompted for the password. ```bash # Get the server endpoint SERVER_ENDPOINT=$(terraform output -raw server_endpoint) # Get the username USER=$(terraform output -raw cognito_username) # Connect via SFTP (you'll be prompted for the password) sftp $USER@$SERVER_ENDPOINT # Once connected, you'll see the root of the S3 bucket sftp> ls # Shows all files in the bucket root ``` -------------------------------- ### Stage 1 deployment and testing Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Deploy the Transfer Family SFTP server and test file uploads. ```bash ./stage1-deploy.sh # Transfer Family SFTP server + upload bucket ./stage1-test.sh # Upload a test claim ZIP via SFTP ``` -------------------------------- ### Navigate to walkthrough scripts Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Change directory to the location of the deployment scripts. ```bash cd examples/sftp-automated-workflows-agentcore/walkthrough/scripts ``` -------------------------------- ### With Landing Page - module "cognito" Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/README.md Enables the optional CloudFront-backed landing page by setting create_landing_page to true and providing a landing_page_template path. The template file must exist at the specified path. ```hcl module "cognito" { source = "./cognito-hosted-ui" user_pool_name = "my-app-users" domain_prefix = "my-app-auth" create_landing_page = true landing_page_template = "${path.module}/landing.html" tags = { Environment = "production" } } ``` -------------------------------- ### Stage 2 deployment and testing Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Deploy GuardDuty Malware Protection and test file routing. ```bash ./stage2-deploy.sh # GuardDuty Malware Protection + clean/quarantine routing ./stage2-test.sh # Upload clean and EICAR test files; observe routing ``` -------------------------------- ### Initialize and Validate Terraform Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/CONTRIBUTING.md Run terraform init and terraform validate to prepare the environment and validate the configuration. ```sh terraform init terraform validate ``` -------------------------------- ### Manually Trigger Scheduler Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-static/.header.md Manually trigger the EventBridge Scheduler to test file retrieval. First get the scheduler name from Terraform outputs, then invoke it with AWS CLI. ```bash # Get the scheduler name from Terraform outputs terraform output scheduler_name # Manually trigger the scheduler (if supported by AWS CLI) aws scheduler invoke-schedule --name $(terraform output -raw scheduler_name) ``` -------------------------------- ### Deploy Stage 0 Infrastructure Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Runs the stage0-deploy.sh script to initialize Terraform, show the deployment command, wait for confirmation, deploy all Stage 0 resources, and display deployment information with console links. ```bash cd examples/sftp-automated-workflows-agentcore/walkthrough/scripts ./stage0-deploy.sh ``` -------------------------------- ### Basic Usage - module "cognito" Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/README.md Minimal configuration to create a Cognito User Pool with Managed Login. The domain_prefix must be globally unique. Tags are optional but recommended for environment management. ```hcl module "cognito" { source = "./cognito-hosted-ui" user_pool_name = "my-app-users" domain_prefix = "my-app-auth" # Must be globally unique app_client_name = "my-app-client" tags = { Environment = "production" ManagedBy = "Terraform" } } ``` -------------------------------- ### Run tflint Checks Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/CONTRIBUTING.md Initialize tflint with the project configuration and then run it with force to lint the Terraform code. ```sh tflint --init --config ${PROJECT_PATH}/.config/.tflint.hcl tflint --force --config ${PROJECT_PATH}/.config/.tflint.hcl ``` -------------------------------- ### Full Cleanup: ./cleanup.sh Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Run from the walkthrough/scripts folder to empty all S3 buckets, destroy all infrastructure (Stages 0-4), and remove local Terraform state files. ```bash ./cleanup.sh ``` -------------------------------- ### Retrieve Cognito user passwords from Secrets Manager Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-cognito-lambda/.header.md After deployment, get the secret name from Terraform output, then use AWS CLI to fetch all or specific user passwords (user1, user2). Requires jq to parse the JSON response. ```bash # Get the secret name from Terraform output SECRET_NAME=$(terraform output -raw cognito_user_password_secret_name) # Retrieve all user credentials aws secretsmanager get-secret-value \ --secret-id $SECRET_NAME \ --query SecretString \ --output text | jq # Or retrieve specific user passwords aws secretsmanager get-secret-value \ --secret-id $SECRET_NAME \ --query SecretString \ --output text | jq -r '.user1.password' aws secretsmanager get-secret-value \ --secret-id $SECRET_NAME \ --query SecretString \ --output text | jq -r '.user2.password' ``` -------------------------------- ### Stage 2: Malware Protection Deploy and Test Commands Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Commands to deploy and test GuardDuty malware scanning for Stage 2. ```bash ./stage2-deploy.sh # Deploy GuardDuty malware scanning ./stage2-test.sh # Test malware scan and routing ``` -------------------------------- ### Stage 3 deployment and testing Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Deploy the AI orchestration layer and test the end-to-end claim workflow. ```bash ./stage3-deploy.sh # MCP gateway + claims_reader Lambda + DynamoDB + # claims orchestrator Lambda ./stage3-test.sh # End-to-end claim through all 4 AgentCore agents ``` -------------------------------- ### With VPC (Create New VPC) Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-custom-idp-solution/.header.md Usage with a new VPC created for the Lambda function by setting use_vpc and create_vpc to true, and specifying the VPC CIDR. API Gateway is not provisioned. ```hcl module "custom_idp" { source = "../../modules/transfer-custom-idp-solution" name_prefix = "my-sftp" # Create new VPC for Lambda use_vpc = true create_vpc = true vpc_cidr = "10.0.0.0/16" provision_api = false tags = { Environment = "production" } } ``` -------------------------------- ### Generate Documentation with terraform-docs Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/CONTRIBUTING.md Generate documentation using terraform-docs with the project configuration and without updating the lockfile. ```sh # from the root of the repository terraform-docs --config ${PROJECT_PATH}/.config/.terraform-docs.yaml --lockfile=false ./ ``` -------------------------------- ### Command Line Variables for Terraform Apply Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-send/.header.md Run terraform apply with -var flags to provide configuration variables directly on the command line. ```bash terraform init terraform apply -var="sftp_server_url=sftp://example.com:22" \ -var="sftp_username=your-username" \ -var="sftp_password=your-password" \ -var="sftp_remote_path=/upload" \ -var="aws_region=us-east-1" ``` -------------------------------- ### Stage 4: Web Application Deploy Command Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Command to deploy the web app for internal users in Stage 4. ```bash ./stage4-deploy.sh # Deploy web app for internal users ``` -------------------------------- ### Run Markdown Lint Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/CONTRIBUTING.md Run mdl with the project configuration to lint markdown files. ```sh mdl --config ${PROJECT_PATH}/.config/.mdlrc .header.md examples/*/.header.md ``` -------------------------------- ### Troubleshooting: Change Directory and Make Script Executable Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Commands to resolve the 'command not found' error by changing to the correct directory and making the script executable. ```bash cd examples/sftp-automated-workflows-agentcore ``` ```bash chmod +x stage0-deploy.sh ``` -------------------------------- ### Reset to Stage 0: ./cleanup.sh --reset-to-stage0 Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Run from the walkthrough/scripts folder to empty all S3 buckets, destroy Stages 1-4 only, preserve Stage 0 (Identity Center, Cognito), and keep Terraform state for Stage 0. Use this option to re-run the demo from Stage 1 or iterate on Stages 1-4 configurations. ```bash ./cleanup.sh --reset-to-stage0 ``` -------------------------------- ### With Custom Branding - module "cognito" Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/modules/cognito-hosted-ui/README.md Applies custom branding settings from a JSON file specified by branding_settings. The file must be a valid Cognito branding configuration. ```hcl module "cognito" { source = "./cognito-hosted-ui" user_pool_name = "my-app-users" domain_prefix = "my-app-auth" branding_settings = "${path.module}/cognito-branding.json" tags = { Environment = "production" } } ``` -------------------------------- ### Basic Usage (Direct Lambda) Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-custom-idp-solution/.header.md Basic usage of the module with direct Lambda invocation, no API Gateway, and automatic creation of DynamoDB tables. No VPC attachment is configured. ```hcl module "custom_idp" { source = "../../modules/transfer-custom-idp-solution" name_prefix = "my-sftp" # DynamoDB tables will be created automatically users_table_name = "" identity_providers_table_name = "" # No VPC attachment use_vpc = false create_vpc = false # Direct Lambda invocation (no API Gateway) provision_api = false tags = { Environment = "production" Project = "file-transfer" } } ``` -------------------------------- ### Configure S3 Access Grants with New Instance and Location Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-web-app/.header.md The default and recommended approach for configuring S3 Access Grants by creating a new instance and location for all buckets. ```hcl # Creates new instance and location with scope for all buckets (default) s3_access_grants_location_new = "s3://" # Default value - recommended approach ``` -------------------------------- ### With Existing VPC Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-custom-idp-solution/.header.md Usage with an existing VPC by setting use_vpc to true, create_vpc to false, and providing the VPC ID, subnet IDs, and security group IDs. API Gateway is not provisioned. ```hcl module "custom_idp" { source = "../../modules/transfer-custom-idp-solution" name_prefix = "my-sftp" # Use existing VPC use_vpc = true create_vpc = false vpc_id = "vpc-12345678" subnet_ids = ["subnet-12345678", "subnet-87654321"] security_group_ids = ["sg-12345678"] provision_api = false tags = { Environment = "production" } } ``` -------------------------------- ### Verify Stage 0 Deployment Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Runs the stage0-verify.sh script to check prerequisites, AWS credentials, deployed resources (Identity Center, Cognito), and Bedrock model access. ```bash ./stage0-verify.sh ``` -------------------------------- ### Run Checkov Compliance Check Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/CONTRIBUTING.md Run checkov with the project configuration file to perform compliance checks. ```sh checkov --config-file ${PROJECT_PATH}/.config/.checkov.yml ``` -------------------------------- ### Stage 4 deployment Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Deploy the Transfer Family Web App and S3 Access Grants. ```bash ./stage4-deploy.sh # Transfer Family Web App + S3 Access Grants instance ``` -------------------------------- ### Command Line Variables Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-static/.header.md Provide variables directly on the command line using -var flags. This method is useful for quick testing or CI/CD pipelines. ```bash terraform init terraform apply -var="sftp_server_endpoint=example.com" \ -var="sftp_username=your-username" \ -var="sftp_private_key=$(cat ~/.ssh/id_rsa)" \ -var='trusted_host_keys=["ssh-rsa AAAAB3NzaC1yc2EAAAA..."]' \ -var='file_paths_to_retrieve=["/uploads/report.csv"]' \ -var="eventbridge_schedule=rate(1 hour)" \ -var="aws_region=us-east-1" ``` -------------------------------- ### With API Gateway Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-custom-idp-solution/.header.md Usage with API Gateway enabled by setting provision_api to true. No VPC attachment is configured. ```hcl module "custom_idp" { source = "../../modules/transfer-custom-idp-solution" name_prefix = "my-sftp" # Enable API Gateway provision_api = true use_vpc = false create_vpc = false tags = { Environment = "production" } } ``` -------------------------------- ### List retrieved files in S3 Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-retrieve-dynamic/.header.md Verify that files have been successfully retrieved by listing the contents of the S3 bucket. ```bash # Get the S3 bucket name from Terraform outputs terraform output s3_bucket_name # List retrieved files aws s3 ls s3://$(terraform output -raw s3_bucket_name)/retrieved-files/ --recursive ``` -------------------------------- ### Review Terraform Plan Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/.header.md Command to review the planned changes before applying the configuration. ```bash terraform plan ``` -------------------------------- ### Stage 3: AI Claims Processing Deploy and Test Commands Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/DEMO-SETUP.md Commands to deploy and test the MCP gateway, claims_reader Lambda, orchestrator Lambda, and DynamoDB for Stage 3. ```bash ./stage3-deploy.sh # Deploy MCP gateway + claims_reader Lambda + orchestrator Lambda + DynamoDB ./stage3-test.sh # Test AI processing pipeline ``` -------------------------------- ### Cleanup scripts Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-automated-workflows-agentcore/walkthrough/README.md Scripts to destroy resources or roll back to the foundation stage. ```bash ./cleanup.sh # Full cleanup (destroy + bucket emptying) ./cleanup.sh --reset-to-stage0 # Roll back to stage 0 only ``` -------------------------------- ### Test SFTP connection with Okta credentials Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-okta/.header.md Retrieves the server endpoint and connects via SFTP using an Okta user email. Without MFA, use the Okta password; with MFA, append the TOTP code to the password (e.g., MyPassword123456). Once connected, you can list, upload, and download files. ```bash # Get the server endpoint SERVER_ENDPOINT=$(terraform output -raw server_endpoint) # Get the username (one of the emails in your okta_users list) USER=user@example.com # Connect via SFTP # - Without MFA: Use your Okta password # - With MFA: Use your Okta password + TOTP code (e.g., MyPassword123456) sftp $USER@$SERVER_ENDPOINT # Once connected, you'll see the root of the S3 bucket sftp> ls sftp> put testfile.txt sftp> get testfile.txt ``` -------------------------------- ### Environment Variables for SFTP Connector Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-connector-automated-file-send/.header.md Set the required environment variables to configure the SFTP connector. Provide either an existing secret ARN or credentials to create a new secret. Uncomment sftp_private_key if using private key authentication. ```bash export TF_VAR_sftp_server_url="sftp://example.com:22" # Either provide an existing secret ARN export TF_VAR_existing_secret_arn="arn:aws:secretsmanager:region:account-id:secret:secret-name" # Or provide credentials to create a new secret export TF_VAR_sftp_username="your-username" export TF_VAR_sftp_password="your-password" # export TF_VAR_sftp_private_key="$(cat ~/.ssh/id_rsa)" # Uncomment if using private key export TF_VAR_sftp_remote_path="/upload" export TF_VAR_aws_region="us-east-1" terraform init terraform apply ``` -------------------------------- ### With Existing DynamoDB Tables Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-custom-idp-solution/.header.md Usage with existing DynamoDB tables by providing the table names. No VPC attachment and no API Gateway are configured. ```hcl module "custom_idp" { source = "../../modules/transfer-custom-idp-solution" name_prefix = "my-sftp" # Use existing DynamoDB tables users_table_name = "existing-users-table" identity_providers_table_name = "existing-providers-table" use_vpc = false provision_api = false tags = { Environment = "production" } } ``` -------------------------------- ### Test SFTP Connection for Default Fallback User Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/examples/sftp-idp-entra-lambda/.header.md Connect via SFTP as a user without an explicit DynamoDB record, using the $default$ configuration. The user must exist in Microsoft Entra ID. Files are isolated in a user-specific directory. ```bash # Connect as user2 (User must exist in Microsoft Entra ID application) sftp user2@$SERVER_ENDPOINT # Once connected, you'll be in an isolated user-specific directory sftp> ls # Shows only files in /home/users/user2/ # Files uploaded by user2 are isolated from user1 sftp> put myfile.txt # File is stored at: s3:///users/user2/myfile.txt ``` -------------------------------- ### Configure code_signing_config_arn variable Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-malware-protection/.header.md Optional variable to specify a Lambda code signing configuration ARN. Defaults to null. ```hcl code_signing_config_arn = "arn:aws:signer:region:account:/signing-profiles/profile-name" ``` -------------------------------- ### Configure tags variable Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-malware-protection/.header.md Optional variable to set resource tags. Defaults to an empty map. ```hcl tags = { Environment = "Production" Project = "File Security" Owner = "Security Team" } ``` -------------------------------- ### Home Directory Mapping Configuration Source: https://github.com/aws-ia/terraform-aws-transfer-family/blob/main/modules/transfer-users/.header.md Configures logical home directory mapping for SFTP users, mapping the root entry to a target S3 path using the bucket name and home directory variable. ```hcl home_directory_type = "LOGICAL" home_directory_mappings { entry = "/" target = "/${s3_bucket_name}${home_dir}" } ```