def __init__(self, scope: App, id: str, envs: EnvSettings, components: ComponentsStack): super().__init__(scope, id) self.backend_domain_name = StringParameter.from_string_parameter_name( self, "DomainNameParameter", string_parameter_name="/schema-cms-app/DOMAIN_NAME").string_value self.backend_url = f"https://{self.backend_domain_name}/api/v1/" self.job_processing_queues = components.data_processing_queues self.app_bucket = Bucket.from_bucket_arn( self, id="App", bucket_arn=Fn.import_value( ApiStack.get_app_bucket_arn_output_export_name(envs))) self.resize_lambda_image_bucket = Bucket.from_bucket_arn( self, id="Images", bucket_arn=Fn.import_value( ImageResizeStack. get_image_resize_bucket_arn_output_export_name(envs)), ) self.lambda_auth_token = Secret.from_secret_arn( self, id="lambda-auth-token", secret_arn=Fn.import_value( ApiStack.get_lambda_auth_token_arn_output_export_name(envs)), ) self.functions = [ self._create_lambda_fn(envs, memory_size, queue) for memory_size, queue in zip(envs.lambdas_sizes, self.job_processing_queues) ]
def add_react_build(stack: core.Stack, code_pipeline, source_output, bucket_arn: str): # Could refactor the bucket to be part of the stage # https://github.com/aws-samples/aws-cdk-examples/blob/master/typescript/static-site/static-site.ts # Need to move to a stack / into startuptoolbag # The codebuild project can be moved back out into the pipeline (bit awkward?) react_site_bucket = Bucket.from_bucket_arn(stack, id='SiteBucket', bucket_arn=bucket_arn) stack.build_output_artifact = codepipeline.Artifact() build_output_artifact = codepipeline.Artifact() codebuild_project = codebuild.PipelineProject( stack, "t-u-b-CDKCodebuild", project_name="t-u-b-CodebuildProject", build_spec=codebuild.BuildSpec.from_source_filename( filename='buildspec.yml'), environment=codebuild.BuildEnvironment(privileged=True), description='Pipeline for the-ultimate-boilerplate', timeout=core.Duration.minutes(60), ) build_action = codepipeline_actions.CodeBuildAction( action_name="ReactBuild", project=codebuild_project, input=source_output, outputs=[build_output_artifact]) s3_deploy = codepipeline_actions.S3DeployAction( action_name="ReactS3Push", input=build_output_artifact, bucket=react_site_bucket) # Would be more elegant to be one stage but the input to deploy must be created in a prior stage code_pipeline.add_stage(stage_name="ReactBuild", actions=[build_action]) code_pipeline.add_stage(stage_name="ReactDeploy", actions=[s3_deploy])