3
0

client_auth_stack.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 (core)
  7. from auth.cognito_user_pool_sms_role import CognitoUserPoolSMSRole
  8. from cognito.cognito_user_pool import CognitoUserPool
  9. from cognito.cognito_identity_pool import CognitoIdentityPool
  10. from utils import name_utils
  11. from utils.constants import *
  12. class AWSClientAuthStack(core.Stack):
  13. """
  14. Composes AWS resources required by AWSClientAuth gem to provide authentication and authorization.
  15. """
  16. def __init__(self, scope: core.Construct, project_name: str, env: core.Environment,
  17. **kwargs) -> None:
  18. """
  19. :param scope: Construct role scope will be attached to.
  20. :param project_name: Name of the project for resource.
  21. :param env: Environment set up by App.
  22. :param kwargs: -
  23. """
  24. super().__init__(scope, id=name_utils.format_aws_resource_id(STACK_FEATURE_NAME, project_name, env,
  25. core.Stack.__name__),
  26. stack_name=name_utils.format_aws_resource_name(STACK_FEATURE_NAME, project_name, env,
  27. core.Stack.__name__), env=env,
  28. tags={'AWSProject': project_name, 'AWSFeature': STACK_FEATURE_NAME},
  29. description=f'Deployed resources for the AWS Client Auth Gem for {project_name} project '
  30. f'in {env.region} region',
  31. **kwargs)
  32. sms_role = CognitoUserPoolSMSRole(self, STACK_FEATURE_NAME, project_name, env)
  33. cognito_user_pool = CognitoUserPool(self, STACK_FEATURE_NAME, project_name, env, sms_role)
  34. CognitoIdentityPool(self, STACK_FEATURE_NAME, project_name, env, cognito_user_pool)