|
| 1 | +# Terraform AWS ARC (Cognito User Pool) Module Usage Guide |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +### Purpose of the Document |
| 6 | + |
| 7 | +This document provides guidelines and instructions for users looking to implement the Terraform AWS ARC Cognito User Pool module. |
| 8 | +The module simplifies and standardizes the provisioning of Amazon Cognito User Pools, App Clients, Identity Providers, Lambda triggers, and advanced security. |
| 9 | + |
| 10 | +### Module Overview |
| 11 | + |
| 12 | +The Terraform AWS ARC Cognito User Pool module provides a secure, opinionated, and modular foundation for deploying Cognito-based authentication and authorization in AWS. |
| 13 | + |
| 14 | +It supports: |
| 15 | + |
| 16 | +- Cognito User Pools with configurable attributes and policies. |
| 17 | + |
| 18 | +- App Clients with OAuth2 and Hosted UI options. |
| 19 | + |
| 20 | +- Federated Identity Providers (SAML, OIDC, or social). |
| 21 | + |
| 22 | +- Lambda triggers for pre-sign-up, post-confirmation, pre-authentication, etc. |
| 23 | + |
| 24 | +- Advanced security which includes MFA, Threat detection, Account takeover risk & logging to CloudWatch Logs, Amazon S3, or Kinesis Firehose. |
| 25 | + |
| 26 | +### Prerequisites |
| 27 | + |
| 28 | +Before using this module, ensure you have the following: |
| 29 | + |
| 30 | +- AWS credentials configured. |
| 31 | +- Terraform installed. |
| 32 | +- A working knowledge of: |
| 33 | + - AWS IAM & Cognito basics |
| 34 | + - Terraform HCL |
| 35 | + - Optional: VPC networking if using Lambda triggers with VPC integration. |
| 36 | + |
| 37 | +## Getting Started |
| 38 | + |
| 39 | +### Module Source |
| 40 | + |
| 41 | +To use the module in your Terraform configuration, include the following source block: |
| 42 | + |
| 43 | +```hcl |
| 44 | +module "arc-cognito-userpool" { |
| 45 | + source = "sourcefuse/arc-cognito-userpool/aws" |
| 46 | + version = "1.0.0" |
| 47 | +
|
| 48 | + environment = "dev" |
| 49 | + project = "arc" |
| 50 | + name = "auth" |
| 51 | + region = "us-east-1" |
| 52 | +
|
| 53 | + # Example basic config |
| 54 | + cognito_user_pool_name = "arc-demo-user-pool" |
| 55 | + # Add further required variables |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +Refer to the [Terraform Registry](https://registry.terraform.io/modules/sourcefuse/arc-cognito-userpool/aws/latest) for the latest version. |
| 60 | + |
| 61 | +### Integration with Existing Terraform Configurations |
| 62 | + |
| 63 | +Refer to the Terraform Registry for the latest version. |
| 64 | + |
| 65 | +## Integration with Existing Terraform Configurations |
| 66 | +Integrate the module with your existing Terraform mono repo configuration, follow the steps below: |
| 67 | + |
| 68 | +- Create a new folder in terraform/ named cognito-userpool |
| 69 | +- Create the required files, see the [examples](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool/examples) to base off of. |
| 70 | +- Configure with your backend: |
| 71 | + - Create the environment backend configuration file: config.<environment>.hcl |
| 72 | + - region: Where the backend resides |
| 73 | + - key: <working_directory>/terraform.tfstate |
| 74 | + - bucket: Bucket name where the terraform state will reside |
| 75 | + - dynamodb_table: Lock table so there are not duplicate tfplans in the mix |
| 76 | + - encrypt: Encrypt all traffic to and from the backend |
| 77 | + |
| 78 | +### Required AWS Permissions |
| 79 | + |
| 80 | +Ensure that the AWS credentials used to execute Terraform have the necessary permissions to create, list and modify: |
| 81 | + |
| 82 | +- cognito-idp:* (User Pools, App Clients, Identity Providers, Log Delivery Configurations) |
| 83 | +- iam:PassRole (for Lambda triggers) |
| 84 | +- lambda:* (if using triggers) |
| 85 | +- s3:* (if using S3 as a logging destination) |
| 86 | +- logs:* (if using CloudWatch Logs as a logging destination) |
| 87 | +- firehose:* (if using Firehose as a logging destination) |
| 88 | + |
| 89 | +## Module Configuration |
| 90 | + |
| 91 | +### Input Variables |
| 92 | + |
| 93 | +For a list of input variables, see the README [Inputs](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool#inputs) section. |
| 94 | + |
| 95 | +### Output Values |
| 96 | + |
| 97 | +For a list of outputs, see the README [Outputs](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool#outputs) section. |
| 98 | + |
| 99 | +## Module Usage |
| 100 | + |
| 101 | +### Basic Usage |
| 102 | + |
| 103 | +For basic usage, see the [examples/basic-user-pool](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool/examples/basic-user-pool) folder. |
| 104 | + |
| 105 | +This example will create: |
| 106 | + |
| 107 | +- A basic AWS Cognito User Pool |
| 108 | +- Two app clients |
| 109 | +- Create Users & Groups and further associate users to specified groups |
| 110 | + |
| 111 | +### Tips and Recommendations |
| 112 | + |
| 113 | +- The module focuses on provisioning AWS Cognito User Pool. |
| 114 | +- Adjust the configuration parameters as needed for your specific use case. |
| 115 | + |
| 116 | +## Troubleshooting |
| 117 | + |
| 118 | +### Reporting Issues |
| 119 | + |
| 120 | +If you encounter a bug or issue, please report it on the [GitHub repository](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool). |
| 121 | + |
| 122 | +## Security Considerations |
| 123 | + |
| 124 | +### Best Practices for AWS ___ |
| 125 | + |
| 126 | +Follow best practices to ensure secure AWS Cognito User Pool configurations: |
| 127 | + |
| 128 | +- [AWS Cognito User Pool Security Best Practices](https://docs.aws.amazon.com/cognito/latest/developerguide/security.html) |
| 129 | + |
| 130 | +## Contributing and Community Support |
| 131 | + |
| 132 | +### Contributing Guidelines |
| 133 | + |
| 134 | +Contribute to the module by following the guidelines outlined in the [CONTRIBUTING.md](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool/blob/main/CONTRIBUTING.md) file. |
| 135 | + |
| 136 | +### Reporting Bugs and Issues |
| 137 | + |
| 138 | +If you find a bug or issue, report it on the [GitHub repository](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool). |
| 139 | + |
| 140 | +## License |
| 141 | + |
| 142 | +### License Information |
| 143 | + |
| 144 | +This module is licensed under the Apache 2.0 license. Refer to the [LICENSE](https://github.com/sourcefuse/terraform-aws-arc-cognito-userpool/blob/main/LICENSE) file for more details. |
| 145 | + |
| 146 | +### Open Source Contribution |
| 147 | + |
| 148 | +Contribute to open source by using and enhancing this module. Your contributions are welcome! |
0 commit comments