3
0

client_auth_stack.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. from aws_cdk import (
  7. Environment,
  8. Stack
  9. )
  10. from constructs import Construct
  11. from auth.cognito_user_pool_sms_role import CognitoUserPoolSMSRole
  12. from cognito.cognito_user_pool import CognitoUserPool
  13. from cognito.cognito_identity_pool import CognitoIdentityPool
  14. from utils import name_utils
  15. from utils.constants import *
  16. class AWSClientAuthStack(Stack):
  17. """
  18. Composes AWS resources required by AWSClientAuth gem to provide authentication and authorization.
  19. """
  20. def __init__(self, scope: Construct, project_name: str, env: Environment,
  21. **kwargs) -> None:
  22. """
  23. :param scope: Construct role scope will be attached to
  24. :param project_name: Name of the project for resource
  25. :param env: Environment set up by App
  26. :param kwargs: -
  27. """
  28. super().__init__(scope, id=name_utils.format_aws_resource_id(STACK_FEATURE_NAME, project_name, env,
  29. Stack.__name__),
  30. stack_name=name_utils.format_aws_resource_name(STACK_FEATURE_NAME, project_name, env,
  31. Stack.__name__), env=env,
  32. tags={'AWSProject': project_name, 'AWSFeature': STACK_FEATURE_NAME},
  33. description=f'Deployed resources for the AWS Client Auth Gem for {project_name} project '
  34. f'in {env.region} region',
  35. **kwargs)
  36. sms_role = CognitoUserPoolSMSRole(self, STACK_FEATURE_NAME, project_name, env)
  37. cognito_user_pool = CognitoUserPool(self, STACK_FEATURE_NAME, project_name, env, sms_role)
  38. CognitoIdentityPool(self, STACK_FEATURE_NAME, project_name, env, cognito_user_pool)