app.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python3
  2. """
  3. Copyright (c) Contributors to the Open 3D Engine Project.
  4. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. SPDX-License-Identifier: Apache-2.0 OR MIT
  6. """
  7. import os
  8. from aws_cdk import (
  9. core
  10. )
  11. from constants import Constants
  12. from core.aws_core import AWSCore
  13. from example.example_resources_stack import ExampleResources
  14. """Configuration"""
  15. REGION = os.environ.get('O3DE_AWS_DEPLOY_REGION', os.environ.get('CDK_DEFAULT_REGION'))
  16. ACCOUNT = os.environ.get('O3DE_AWS_DEPLOY_ACCOUNT', os.environ.get('CDK_DEFAULT_ACCOUNT'))
  17. # Set the common prefix to group stacks in a project together.
  18. PROJECT_NAME = os.environ.get('O3DE_AWS_PROJECT_NAME', f'O3DE-AWS-PROJECT').upper()
  19. # The name of this feature
  20. FEATURE_NAME = 'AWSCore'
  21. # The name of this CDK application
  22. PROJECT_FEATURE_NAME = f'{PROJECT_NAME}-{FEATURE_NAME}'
  23. """End of Configuration"""
  24. # Set-up regions to deploy core stack to, or use default if not set
  25. env = core.Environment(account=ACCOUNT, region=REGION)
  26. app = core.App()
  27. core_construct = AWSCore(
  28. app,
  29. id_=f'{PROJECT_FEATURE_NAME}-Construct',
  30. project_name=PROJECT_NAME,
  31. feature_name=FEATURE_NAME,
  32. env=env
  33. )
  34. # Below is the Core example stack which is provided for working with AWSCore ScriptCanvas examples.
  35. # It also provided as an example how to reference resources across stacks via stack outputs.
  36. # See https://docs.aws.amazon.com/cdk/latest/guide/resources.html#resource_stack
  37. example_stack = ExampleResources(
  38. app,
  39. id_=f'{PROJECT_FEATURE_NAME}-Example-{env.region}',
  40. project_name=f'{PROJECT_NAME}',
  41. feature_name=FEATURE_NAME,
  42. tags={Constants.O3DE_PROJECT_TAG_NAME: PROJECT_NAME, Constants.O3DE_FEATURE_TAG_NAME: FEATURE_NAME},
  43. env=env
  44. )
  45. # Add the core stack as a dependency of the feature stack since the feature stack
  46. # requires the core stack outputs for deployment.
  47. example_stack.add_dependency(core_construct.common_stack)
  48. app.synth()