|
| 1 | +# Sample Web App Example |
| 2 | + |
| 3 | +This example demonstrates a complete deployment of AWS Transfer Family Web App with IAM Identity Center authentication, S3 Access Grants, CloudTrail audit logging, and CORS configuration. |
| 4 | + |
| 5 | +## What This Example Demonstrates |
| 6 | + |
| 7 | +- **Complete end-to-end setup** from IAM Identity Center users/groups to web-app deployment |
| 8 | +- **CloudTrail integration** with KMS encryption and SNS notifications for audit logging |
| 9 | +- **CORS configuration** restricted to the web app endpoint for security |
| 10 | +- **Flexible user/group management** supporting both test user and/or creation and imported existing users/groups |
| 11 | +- **Automatic path prefixing** demonstrating how to construct full S3 paths from bucket names |
| 12 | +- **Custom branding** with logo and favicon support |
| 13 | + |
| 14 | +## What Gets Deployed |
| 15 | + |
| 16 | +### Identity Center Resources (Optional) |
| 17 | + |
| 18 | +- Users and groups (when `create_test_users_and_groups = true`) |
| 19 | +- Group creation and group memberships for created users |
| 20 | +- OR references to existing Identity Center users/groups (default mode) |
| 21 | + |
| 22 | +### Transfer Web App |
| 23 | + |
| 24 | +- Web app with Identity Center authentication and custom branding |
| 25 | +- S3 Access Grants instance with default location scope ("s3://") |
| 26 | +- Access grants for configured users and/or groups |
| 27 | + |
| 28 | +### Storage and Audit |
| 29 | + |
| 30 | +- S3 bucket with encryption, versioning, and public access blocking |
| 31 | +- CORS configuration restricted to web app endpoint |
| 32 | +- CloudTrail with KMS encryption and SNS notifications |
| 33 | +- Dedicated S3 bucket for CloudTrail logs |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +1. **Configure users/groups**: Choose between creating test users and/or groups or configuring existing ones |
| 38 | +2. **Email addresses**: If creating new users, provide real email addresses for user activation |
| 39 | +3. **Deploy**: Run `terraform apply` |
| 40 | +4. **User Activation**: If creating new users, they receive activation emails to set up accounts |
| 41 | +5. **Access**: Log in through the web app endpoint URL |
| 42 | + |
| 43 | +## User and Group Management Options |
| 44 | + |
| 45 | +This example supports two approaches for managing users and groups: |
| 46 | + |
| 47 | +### Option 1: Create Test Users and Groups (Default: Disabled) |
| 48 | + |
| 49 | +Set `create_test_users_and_groups = true` to have Terraform create new Identity Center users and groups: |
| 50 | + |
| 51 | +- Creates users with email activation required |
| 52 | +- Creates groups with specified descriptions and member assignments |
| 53 | +- Automatically handles group memberships |
| 54 | +- Ideal for demo environments or new Identity Center setups |
| 55 | +- **Note**: When enabled, any configurations in `imported-users.tf` and `imported-groups.tf` will be ignored |
| 56 | + |
| 57 | +### Option 2: Import Existing Users and Groups (Default: Enabled) |
| 58 | + |
| 59 | +Configure existing Identity Center users/groups via `imported-users.tf` and `imported-groups.tf`: |
| 60 | + |
| 61 | +- **imported-users.tf**: Reference existing users by username and assign individual access grants |
| 62 | +- **imported-groups.tf**: Reference existing groups by name and assign group-level access grants |
| 63 | +- Users and groups must already exist in Identity Center before deployment |
| 64 | +- Ideal for production environments with established Identity Center configurations |
| 65 | + |
| 66 | +S3 paths are automatically prefixed with the bucket name: |
| 67 | + |
| 68 | +```hcl |
| 69 | +s3_path = "/*" # Becomes "bucket-name/*" in the module call |
| 70 | +``` |
| 71 | + |
| 72 | +To switch modes, modify the `create_test_users_and_groups` variable and update the respective configuration files. |
| 73 | + |
| 74 | +## Configuration Variables |
| 75 | + |
| 76 | +### Required Variables |
| 77 | + |
| 78 | +None - all variables have defaults |
| 79 | + |
| 80 | +### Optional Variables with Defaults |
| 81 | + |
| 82 | +#### AWS Configuration |
| 83 | + |
| 84 | +- `aws_region` (default: `"us-east-1"`) - AWS region for deployment |
| 85 | +- `identity_center_instance_arn` (default: `null`) - ARN of Identity Center instance (required if create_identity_center_instance is false) |
| 86 | +- `identity_store_id` (default: `null`) - ID of Identity Center identity store (required if create_identity_center_instance is false) |
| 87 | +- `create_identity_center_instance` (default: `false`) - Whether to create a new Identity Center instance (required if identity_center_instance_arn and identity_store_id are null) |
| 88 | +- `s3_access_grants_instance_id` (default: `null`) - ID of existing S3 Access Grants instance, creates new if not specified |
| 89 | + |
| 90 | +#### User and Group Configuration |
| 91 | + |
| 92 | +- `create_test_users_and_groups` (default: `false`) - Whether to create new users/groups or use existing ones |
| 93 | +- `test_users` (default: admin and analyst users) - Map of users to create when `create_test_users_and_groups = true` |
| 94 | +- `test_groups` (default: admins and analysts groups) - Map of groups to create when `create_test_users_and_groups = true` |
| 95 | + |
| 96 | +#### Web App Customization |
| 97 | + |
| 98 | +- `logo_file` (default: `"anycompany-logo-small.png"`) - Path to logo file for web app branding |
| 99 | +- `favicon_file` (default: `"favicon.png"`) - Path to favicon file for web app |
| 100 | +- `custom_title` (default: `"AnyCompany Financial Solutions"`) - Custom title for the web app |
| 101 | + |
| 102 | +#### Resource Tagging |
| 103 | + |
| 104 | +- `tags` (default: Name="Demo Web App File Transfer Portal", Environment="Demo", Project="Web App File Transfer Portal") - Tags to organize, search, and filter your web apps. |
| 105 | + |
| 106 | +### Example Test User Configuration |
| 107 | + |
| 108 | +```hcl |
| 109 | +test_users = { |
| 110 | + "admin" = { |
| 111 | + display_name = "Admin User" |
| 112 | + user_name = "admin" |
| 113 | + first_name = "Admin" |
| 114 | + last_name = "User" |
| 115 | + email = "admin@example.com" |
| 116 | + } |
| 117 | +} |
| 118 | +# Note: Only used when create_test_users_and_groups = true |
| 119 | +``` |
| 120 | + |
| 121 | +### Example Test Group Configuration |
| 122 | + |
| 123 | +```hcl |
| 124 | +test_groups = { |
| 125 | + "admins" = { |
| 126 | + group_name = "Admins" |
| 127 | + description = "Read and write access to files" |
| 128 | + members = ["admin"] |
| 129 | + access_grants = [{ |
| 130 | + s3_path = "/*" # Auto-prefixed with bucket name |
| 131 | + permission = "READWRITE" |
| 132 | + }] |
| 133 | + } |
| 134 | +} |
| 135 | +# Note: Only used when create_test_users_and_groups = true |
| 136 | +``` |
| 137 | + |
| 138 | +## S3 Path Examples |
| 139 | + |
| 140 | +Supported path patterns (auto-prefixed with bucket name in this example): |
| 141 | + |
| 142 | +- `/*` - All objects in the bucket |
| 143 | +- `/reports*` - Prefix within bucket |
| 144 | +- `/data/logs*` - Prefix within prefix |
| 145 | +- `/data/file.txt` - Specific object |
| 146 | + |
| 147 | +## Important Notes |
| 148 | + |
| 149 | +- **Email Addresses**: Must be real for user activation when creating new users |
| 150 | +- **Identity Center**: Requires existing instance in your account with `identity_center_instance_arn` and `identity_store_id` provided, or set `create_identity_center_instance = true` to create a new one |
| 151 | +- **User/Group Management**: Choose between creating test users or importing existing ones via configuration files |
| 152 | +- **CloudTrail**: Logs all S3 data events on the web app bucket |
| 153 | +- **CORS**: Restricted to web app endpoint only (no wildcards) |
| 154 | +- **Custom Branding**: Logo and favicon files should be placed in the example directory |
| 155 | +- **Production Warning**: This example uses `force_destroy = true` on the CloudTrail logging S3 bucket for easy cleanup. |
| 156 | + This is NOT suitable for production as it will delete all audit logs when running `terraform destroy`. |
| 157 | + Remove this setting for production deployments. |
| 158 | +- **Costs**: Creates billable AWS resources |
| 159 | +- **Cleanup**: Run `terraform destroy` to remove all resources |
0 commit comments