diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/global.yml b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/global.yml index c6762d6d1..a1b5861f9 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/global.yml +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/global.yml @@ -679,7 +679,7 @@ Resources: python: 3.9 nodejs: 14 commands: - - npm install cdk@1.188 -g -y --quiet --no-progress + - npm install cdk@2.68 -g -y --quiet --no-progress - aws s3 cp s3://$SHARED_MODULES_BUCKET/adf-build/ ./adf-build/ --recursive --quiet - pip install -r adf-build/requirements.txt -r adf-build/helpers/requirements.txt -q -t ./adf-build pre_build: diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/pipeline_management.yml b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/pipeline_management.yml index 2a7a40232..d12bd275c 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/pipeline_management.yml +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/pipeline_management.yml @@ -663,7 +663,7 @@ Resources: python: 3.9 nodejs: 14 commands: - - npm install cdk@1.188 -g -y --quiet --no-progress + - npm install cdk@2.68 -g -y --quiet --no-progress - aws s3 cp s3://$SHARED_MODULES_BUCKET/adf-build/ ./adf-build/ --recursive --quiet - pip install -r adf-build/requirements.txt -q -t ./adf-build - chmod 755 adf-build/cdk/execute_pipeline_stacks.py adf-build/cdk/generate_pipeline_stacks.py diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_chatbot.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_chatbot.py index 95b40abca..7c771a473 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_chatbot.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_chatbot.py @@ -8,8 +8,9 @@ from aws_cdk import ( aws_codestarnotifications as cp_notifications, aws_codepipeline as codepipeline, - core, + Stack ) +from constructs import Construct from logger import configure_logger ADF_DEPLOYMENT_REGION = os.environ["AWS_REGION"] @@ -28,17 +29,17 @@ ] -class PipelineNotifications(core.Construct): +class PipelineNotifications(Construct): def __init__( self, - scope: core.Construct, + scope: Construct, id: str, pipeline: codepipeline.CfnPipeline, notification_config, **kwargs, ): # pylint: disable=W0622 super().__init__(scope, id, **kwargs) - stack = core.Stack.of(self) + stack = Stack.of(self) slack_channel_arn = ( f"arn:{stack.partition}:chatbot::{ADF_DEPLOYMENT_ACCOUNT_ID}:" f"chat-configuration/slack-channel/" diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_cloudformation.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_cloudformation.py index 869bfe77b..e84318b0a 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_cloudformation.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_cloudformation.py @@ -5,9 +5,7 @@ """ import os -from aws_cdk import ( - core -) +from constructs import Construct from cdk_constructs import adf_codepipeline @@ -15,9 +13,9 @@ ADF_DEFAULT_BUILD_TIMEOUT = 20 -class CloudFormation(core.Construct): +class CloudFormation(Construct): # pylint: disable=W0622, W0235 - def __init__(self, scope: core.Construct, id: str, **kwargs): + def __init__(self, scope: Construct, id: str, **kwargs): super().__init__(scope, id, **kwargs) @staticmethod diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codebuild.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codebuild.py index ae26f6a14..4eab0bdc4 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codebuild.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codebuild.py @@ -12,27 +12,30 @@ aws_kms as _kms, aws_ecr as _ecr, aws_ec2 as _ec2, - core + Stack, + Duration, + Aws ) +from constructs import Construct from cdk_constructs.adf_codepipeline import Action ADF_DEPLOYMENT_REGION = os.environ["AWS_REGION"] ADF_DEPLOYMENT_ACCOUNT_ID = os.environ["ACCOUNT_ID"] -DEFAULT_CODEBUILD_IMAGE = "UBUNTU_14_04_PYTHON_3_7_1" +DEFAULT_CODEBUILD_IMAGE = "STANDARD_5_0" DEFAULT_BUILD_SPEC_FILENAME = 'buildspec.yml' DEFAULT_DEPLOY_SPEC_FILENAME = 'deployspec.yml' ADF_DEFAULT_BUILD_ROLE_NAME = 'adf-codebuild-role' ADF_DEFAULT_BUILD_TIMEOUT = 20 -class CodeBuild(core.Construct): +class CodeBuild(Construct): # pylint: disable=no-value-for-parameter # pylint: disable=W0622 def __init__( self, - scope: core.Construct, + scope: Construct, id: str, shared_modules_bucket: str, deployment_region_kms: str, @@ -43,7 +46,7 @@ def __init__( **kwargs, ): super().__init__(scope, id, **kwargs) - stack = core.Stack.of(self) + stack = Stack.of(self) # if CodeBuild is being used as a deployment action we want to allow # target specific values. @@ -123,7 +126,7 @@ def __init__( ), description=f"ADF CodeBuild Project for {id}", project_name=f"adf-deploy-{id}", - timeout=core.Duration.minutes(timeout), + timeout=Duration.minutes(timeout), role=_iam.Role.from_role_arn( self, 'build_role', @@ -205,7 +208,7 @@ def __init__( ), description=f"ADF CodeBuild Project for {map_params['name']}", project_name=f"adf-build-{map_params['name']}", - timeout=core.Duration.minutes(timeout), + timeout=Duration.minutes(timeout), build_spec=build_spec, role=_iam.Role.from_role_arn( self, @@ -399,7 +402,7 @@ def generate_build_env_variables( "ADF_DEPLOYMENT_MAP_SOURCE": deployment_map_source, "ADF_DEPLOYMENT_MAP_NAME": deployment_map_name, "S3_BUCKET_NAME": shared_modules_bucket, - "ACCOUNT_ID": core.Aws.ACCOUNT_ID, + "ACCOUNT_ID": Aws.ACCOUNT_ID, **( map_params .get('default_providers', {}) diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codecommit.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codecommit.py index f18417032..9a1f0f622 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codecommit.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codecommit.py @@ -6,9 +6,9 @@ import os from aws_cdk import ( - aws_codepipeline as _codepipeline, - core + aws_codepipeline as _codepipeline ) +from constructs import Construct from cdk_constructs.adf_codepipeline import Action @@ -17,8 +17,8 @@ ADF_DEFAULT_BUILD_TIMEOUT = 20 -class CodeCommit(core.Construct): - def __init__(self, scope: core.Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 +class CodeCommit(Construct): + def __init__(self, scope: Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 super().__init__(scope, id, **kwargs) default_providers = map_params.get("default_providers", {}) source_props = default_providers.get("source", {}).get("properties", {}) diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codepipeline.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codepipeline.py index ac129f52c..f166cdd4f 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codepipeline.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codepipeline.py @@ -11,8 +11,10 @@ aws_codepipeline as _codepipeline, aws_events as _eventbridge, aws_events_targets as _eventbridge_targets, - core + SecretValue, + Fn ) +from constructs import Construct from cdk_constructs import adf_events from logger import configure_logger @@ -241,7 +243,7 @@ def _generate_configuration(self): .get('branch', self.default_scm_branch) ), # pylint: disable=no-value-for-parameter - "OAuthToken": core.SecretValue.secrets_manager( + "OAuthToken": SecretValue.secrets_manager( ( self.map_params['default_providers']['source'] .get('properties', {}) @@ -682,7 +684,7 @@ def _get_output_artifacts(self): return [] -class Pipeline(core.Construct): +class Pipeline(Construct): _import_arns = [ 'CodePipelineRoleArn', 'CodeBuildRoleArn', @@ -696,7 +698,7 @@ class Pipeline(core.Construct): # pylint: disable=W0622 def __init__( self, - scope: core.Construct, + scope: Construct, id: str, map_params: dict, ssm_params: dict, @@ -827,7 +829,7 @@ def import_required_arns(): output = [] for arn in Pipeline._import_arns: # pylint: disable=no-value-for-parameter - output.append(core.Fn.import_value(arn)) + output.append(Fn.import_value(arn)) return output def add_pipeline_trigger(self, trigger_type, trigger_config): diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codestar.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codestar.py index c0b1e9e02..f3ba0cc9e 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codestar.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codestar.py @@ -7,9 +7,9 @@ import os from aws_cdk import ( - aws_codepipeline as _codepipeline, - core + aws_codepipeline as _codepipeline ) +from constructs import Construct from cdk_constructs.adf_codepipeline import Action @@ -18,8 +18,8 @@ ADF_DEFAULT_BUILD_TIMEOUT = 20 -class CodeStar(core.Construct): - def __init__(self, scope: core.Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 +class CodeStar(Construct): + def __init__(self, scope: Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 super().__init__(scope, id, **kwargs) self.source = _codepipeline.CfnPipeline.StageDeclarationProperty( name="Source-CodeStar", diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_events.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_events.py index 7f9a60d54..6d2a51e75 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_events.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_events.py @@ -11,8 +11,9 @@ aws_events_targets as _targets, aws_codepipeline as _codepipeline, aws_sns as _sns, - core + Stack ) +from constructs import Construct ADF_DEPLOYMENT_REGION = os.environ["AWS_REGION"] @@ -21,11 +22,11 @@ ADF_PIPELINE_PREFIX = os.environ.get("ADF_PIPELINE_PREFIX", "") -class Events(core.Construct): - def __init__(self, scope: core.Construct, id: str, params: dict, **kwargs): # pylint: disable=W0622 +class Events(Construct): + def __init__(self, scope: Construct, id: str, params: dict, **kwargs): # pylint: disable=W0622 super().__init__(scope, id, **kwargs) # pylint: disable=no-value-for-parameter - stack = core.Stack.of(self) + stack = Stack.of(self) _pipeline = _codepipeline.Pipeline.from_pipeline_arn(self, 'pipeline', params["pipeline"]) _source_account = params.get('source', {}).get('account_id') _provider = params.get('source', {}).get('provider') diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_github.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_github.py index 1c972b9b3..23c6006e2 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_github.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_github.py @@ -8,8 +8,9 @@ from aws_cdk import ( aws_codepipeline as _codepipeline, - core + Token ) +from constructs import Construct from cdk_constructs.adf_codepipeline import Action @@ -18,8 +19,8 @@ ADF_DEFAULT_BUILD_TIMEOUT = 20 -class GitHub(core.Construct): - def __init__(self, scope: core.Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 +class GitHub(Construct): + def __init__(self, scope: Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 super().__init__(scope, id, **kwargs) self.source = _codepipeline.CfnPipeline.StageDeclarationProperty( name="Source-Github", @@ -65,6 +66,6 @@ def create_webhook_when_required(scope, pipeline, map_params): target_action="source", name=f"adf-webhook-{map_params['name']}", # pylint: disable=no-value-for-parameter - target_pipeline_version=core.Token.as_number(pipeline_version), + target_pipeline_version=Token.as_number(pipeline_version), register_with_third_party=True ) diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_jenkins.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_jenkins.py index 744edb229..ff24edb75 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_jenkins.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_jenkins.py @@ -6,17 +6,17 @@ import os from aws_cdk import ( - aws_codepipeline as _codepipeline, - core + aws_codepipeline as _codepipeline ) +from constructs import Construct from cdk_constructs.adf_codepipeline import Action ADF_DEPLOYMENT_REGION = os.environ["AWS_REGION"] ADF_DEPLOYMENT_ACCOUNT_ID = os.environ["ACCOUNT_ID"] -class Jenkins(core.Construct): - def __init__(self, scope: core.Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 +class Jenkins(Construct): + def __init__(self, scope: Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 super().__init__(scope, id, **kwargs) self.build = _codepipeline.CfnPipeline.StageDeclarationProperty( name="Build", diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_notifications.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_notifications.py index ac45247ff..b531ff047 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_notifications.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_notifications.py @@ -11,8 +11,9 @@ aws_iam as _iam, aws_kms as _kms, aws_lambda_event_sources as _event_sources, - core + Stack ) +from constructs import Construct from logger import configure_logger ADF_DEPLOYMENT_REGION = os.environ["AWS_REGION"] @@ -21,13 +22,13 @@ LOGGER = configure_logger(__name__) -class Notifications(core.Construct): +class Notifications(Construct): def __init__( - self, scope: core.Construct, id: str, map_params: dict, **kwargs + self, scope: Construct, id: str, map_params: dict, **kwargs ): # pylint: disable=W0622 super().__init__(scope, id, **kwargs) LOGGER.debug('Notification configuration required for %s', map_params['name']) - stack = core.Stack.of(self) + stack = Stack.of(self) # pylint: disable=no-value-for-parameter _slack_func = _lambda.Function.from_function_arn( self, diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_s3.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_s3.py index 92e10f66e..684949ff9 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_s3.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_s3.py @@ -7,9 +7,9 @@ import os from aws_cdk import ( - aws_codepipeline as _codepipeline, - core + aws_codepipeline as _codepipeline ) +from constructs import Construct from cdk_constructs.adf_codepipeline import Action @@ -18,8 +18,8 @@ ADF_DEFAULT_BUILD_TIMEOUT = 20 -class S3(core.Construct): - def __init__(self, scope: core.Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 +class S3(Construct): + def __init__(self, scope: Construct, id: str, map_params: dict, **kwargs): #pylint: disable=W0622 super().__init__(scope, id, **kwargs) self.source = _codepipeline.CfnPipeline.StageDeclarationProperty( name="Source-S3", diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/tests/test_adf_codebuild_determine_build_image.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/tests/test_adf_codebuild_determine_build_image.py index 93353f9c8..2f25b9bf3 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/tests/test_adf_codebuild_determine_build_image.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/tests/test_adf_codebuild_determine_build_image.py @@ -7,7 +7,7 @@ from mock import patch from aws_cdk import ( aws_codebuild as _codebuild, - core, + Stack, ) from cdk_constructs.adf_codebuild import CodeBuild, DEFAULT_CODEBUILD_IMAGE @@ -68,7 +68,7 @@ def test_determine_build_image_build_defaults(ecr_repo, build_image): step. As no specific config for the default build provider is set it should return the default config. """ - scope = core.Stack() + scope = Stack() target = None map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) # Set deploy one to alternative, so we can test @@ -105,7 +105,7 @@ def test_determine_build_image_build_str(ecr_repo, build_image): step. As specific config for the default build provider is set it should use these, not the deploy specific config. """ - scope = core.Stack() + scope = Stack() target = None map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['build'] = \ @@ -145,7 +145,7 @@ def test_determine_build_image_build_ecr(ecr_repo, build_image): it should use these with ECR, not the deploy specific config. Plus setting the 'specific' tag, as that is specified. """ - scope = core.Stack() + scope = Stack() target = None map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['build'] = \ @@ -196,7 +196,7 @@ def test_determine_build_image_build_ecr_no_tag(ecr_repo, build_image): it should use these with ECR, not the deploy specific config. Plus setting the 'latest' default tag, as that is not specified. """ - scope = core.Stack() + scope = Stack() target = None map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['build'] = deepcopy( @@ -249,7 +249,7 @@ def test_determine_build_image_deploy_defaults(ecr_repo, build_image): step. As no specific config for the default deploy provider is set it should return the default config. """ - scope = core.Stack() + scope = Stack() target = SIMPLE_TARGET map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) # Set build one to alternative, so we can test @@ -287,7 +287,7 @@ def test_determine_build_image_deploy_target_str(ecr_repo, build_image): step. As specific config for the target is set it should use these, not the default deploy specific config. """ - scope = core.Stack() + scope = Stack() target = CODEBUILD_SPECIFIC_MAP_PARAMS_STR map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) # Set build one to alternative, so we can test @@ -324,7 +324,7 @@ def test_determine_build_image_deploy_str(ecr_repo, build_image): step. As specific config for the default deploy provider is set it should use these, not the build specific config. """ - scope = core.Stack() + scope = Stack() target = SIMPLE_TARGET map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['deploy'] = \ @@ -363,7 +363,7 @@ def test_determine_build_image_deploy_target_str_too(ecr_repo, build_image): step. As specific config for the target is set it should use these, not the default build or deploy specific config. """ - scope = core.Stack() + scope = Stack() target = CODEBUILD_SPECIFIC_MAP_PARAMS_ALT2_STR map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['deploy'] = \ @@ -403,7 +403,7 @@ def test_determine_build_image_deploy_ecr(ecr_repo, build_image): it should use these with ECR, not the build specific config. Plus setting the 'specific' tag, as that is specified. """ - scope = core.Stack() + scope = Stack() target = SIMPLE_TARGET map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['deploy'] = \ @@ -453,7 +453,7 @@ def test_determine_build_image_deploy_ecr_too(ecr_repo, build_image): with ECR, not the default build or deploy specific config. Plus setting the 'specific' tag, as that is specified. """ - scope = core.Stack() + scope = Stack() target = deepcopy(CODEBUILD_SPECIFIC_MAP_PARAMS_ECR) target['properties']['image']['repository_arn'] = 'arn:other:one' map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) @@ -505,7 +505,7 @@ def test_determine_build_image_deploy_ecr_no_tag(ecr_repo, build_image): it should use these with ECR, not the build specific config. Plus setting the 'latest' default tag, as that is not specified. """ - scope = core.Stack() + scope = Stack() target = SIMPLE_TARGET map_params = deepcopy(CODEBUILD_BASE_MAP_PARAMS) map_params['default_providers']['deploy'] = deepcopy( @@ -558,7 +558,7 @@ def test_determine_build_image_deploy_ecr_no_tag_too(ecr_repo, build_image): with ECR, not the default build or deploy specific config. Plus setting the 'latest' default tag, as that is not specified. """ - scope = core.Stack() + scope = Stack() target = deepcopy(CODEBUILD_SPECIFIC_MAP_PARAMS_ECR) target['properties']['image']['repository_arn'] = 'arn:other:one' del target['properties']['image']['tag'] diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/adf_default_pipeline.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/adf_default_pipeline.py index be85d4f99..98c6d0066 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/adf_default_pipeline.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/adf_default_pipeline.py @@ -6,7 +6,7 @@ import os -from aws_cdk import aws_codepipeline as _codepipeline, core +from aws_cdk import aws_codepipeline as _codepipeline, Stack from cdk_constructs import adf_codepipeline from cdk_constructs import adf_codebuild from cdk_constructs import adf_jenkins @@ -27,7 +27,7 @@ PIPELINE_TYPE = "default" -def generate_adf_default_pipeline(scope: core.Stack, stack_input): +def generate_adf_default_pipeline(scope: Stack, stack_input): stages = [] notification_config = ( diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/main.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/main.py index be2867054..196e9b235 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/main.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/main.py @@ -5,9 +5,8 @@ This is the main construct file file for PipelineStack """ -from aws_cdk import ( - core -) +from aws_cdk import Stack, aws_s3 as s3 +from constructs import Construct from logger import configure_logger from cdk_stacks.adf_default_pipeline import ( @@ -18,10 +17,10 @@ LOGGER = configure_logger(__name__) -class PipelineStack(core.Stack): +class PipelineStack(Stack): def __init__( self, - scope: core.Construct, + scope: Construct, stack_input: dict, **kwargs ) -> None: # pylint: disable=R0912, R0915 diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_default_pipeline_type.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_default_pipeline_type.py index ae814661e..3fc7c6594 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_default_pipeline_type.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_default_pipeline_type.py @@ -3,7 +3,7 @@ # pylint: skip-file -from aws_cdk import core +from aws_cdk import App from cdk_stacks.main import PipelineStack @@ -53,7 +53,7 @@ def test_pipeline_creation_outputs_as_expected_when_input_has_1_target_with_2_wa "modules": "fake-bucket-name", "kms": f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id", } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() @@ -120,7 +120,7 @@ def test_pipeline_creation_outputs_as_expected_when_input_has_2_targets_with_2_w "modules": "fake-bucket-name", "kms": f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id", } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_pipeline_creation.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_pipeline_creation.py index bd99b3af4..7813d184c 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_pipeline_creation.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_stacks/tests/test_pipeline_creation.py @@ -7,7 +7,7 @@ import os from mock import patch -from aws_cdk import core +from aws_cdk import App from cdk_stacks.main import PipelineStack @@ -16,7 +16,7 @@ def test_pipeline_generation_fails_if_pipeline_type_is_not_specified(mock): stack_input = {"pipeline_input": {"params": {}}} stack_input["pipeline_input"]["name"] = "test-stack" stack_input["pipeline_input"]["params"]["type"] = "fail" - app = core.App() + app = App() with pytest.raises(ValueError): pipeline_stack = PipelineStack(app, stack_input) mock.assert_not_called() @@ -26,7 +26,7 @@ def test_pipeline_generation_fails_if_pipeline_type_is_not_specified(mock): def test_pipeline_generation_works_when_no_type_specified(mock): stack_input = {"pipeline_input": {"params": {}}} stack_input["pipeline_input"]["name"] = "test-stack" - app = core.App() + app = App() PipelineStack(app, stack_input) mock.assert_called() @@ -37,7 +37,7 @@ def test_pipeline_generation_works_when_no_type_specified(mock): stack_input["pipeline_input"]["name"] = "test-stack" stack_input["pipeline_input"]["params"]["type"] = "Default" - app = core.App() + app = App() PipelineStack(app, stack_input) mock.assert_called() @@ -70,7 +70,7 @@ def test_pipeline_creation_outputs_as_expected_when_source_is_s3_and_build_is_co f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id" ), } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() @@ -127,7 +127,7 @@ def test_pipeline_creation_outputs_as_expected_when_source_is_codecommit_and_bui f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id" ), } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() @@ -189,7 +189,7 @@ def test_pipeline_creation_outputs_as_expected_when_source_is_codecommit_with_co f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id" ), } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() @@ -260,7 +260,7 @@ def test_pipeline_creation_outputs_with_codeartifact_trigger(): "modules": "fake-bucket-name", "kms": f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id", } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() @@ -323,7 +323,7 @@ def test_pipeline_creation_outputs_with_codeartifact_trigger_with_package_name() f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id" ), } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() @@ -391,7 +391,7 @@ def test_pipeline_creation_outputs_with_invalid_trigger_type(): f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id" ), } - app = core.App() + app = App() with pytest.raises(Exception) as e_info: PipelineStack(app, stack_input) @@ -444,7 +444,7 @@ def test_pipeline_creation_outputs_as_expected_when_notification_endpoint_is_cha f"arn:aws:kms:{region_name}:{account_id}:key/my-unique-kms-key-id" ), } - app = core.App() + app = App() PipelineStack(app, stack_input) cloud_assembly = app.synth() diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/generate_pipeline_stacks.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/generate_pipeline_stacks.py index 6022890b8..8a00f3954 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/generate_pipeline_stacks.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/generate_pipeline_stacks.py @@ -13,7 +13,7 @@ import json # CDK Specific -from aws_cdk import core +from aws_cdk import App, DefaultStackSynthesizer from cdk_stacks.main import PipelineStack from logger import configure_logger @@ -30,8 +30,14 @@ def main(): for template_path in _templates: with open(template_path, encoding="utf-8") as template: stack_input = json.load(template) - app = core.App() - PipelineStack(app, stack_input) + app = App() + PipelineStack( + app, + stack_input, + synthesizer=DefaultStackSynthesizer( + generate_bootstrap_version_rule=False + ), + ) app.synth() diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/requirements.txt b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/requirements.txt index 0a0413f78..46f256dfc 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/requirements.txt +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/requirements.txt @@ -1,54 +1,6 @@ # Install libs here that you might want in AWS CodeBuild -aws-cdk-assets~=1.188.0 -aws-cdk.aws-apigateway~=1.188.0 -aws-cdk.aws-applicationautoscaling~=1.188.0 -aws-cdk.aws-autoscaling_common~=1.188.0 -aws-cdk.aws-autoscaling_hooktargets~=1.188.0 -aws-cdk.aws-autoscaling~=1.188.0 -aws-cdk.aws-certificatemanager~=1.188.0 -aws-cdk.aws-chatbot~=1.188.0 -aws-cdk.aws-cloudformation~=1.188.0 -aws-cdk.aws-cloudfront~=1.188.0 -aws-cdk.aws-cloudwatch~=1.188.0 -aws-cdk.aws-codebuild~=1.188.0 -aws-cdk.aws-codecommit~=1.188.0 -aws-cdk.aws-codedeploy~=1.188.0 -aws-cdk.aws-codepipeline-actions~=1.188.0 -aws-cdk.aws-codepipeline~=1.188.0 -aws-cdk.aws-dynamodb~=1.188.0 -aws-cdk.aws-ec2~=1.188.0 -aws-cdk.aws-ecr_assets~=1.188.0 -aws-cdk.aws-ecr~=1.188.0 -aws-cdk.aws-ecr~=1.188.0 -aws-cdk.aws-ecs~=1.188.0 -aws-cdk.aws-elasticloadbalancingv2~=1.188.0 -aws-cdk.aws-elasticloadbalancing~=1.188.0 -aws-cdk.aws-events_targets~=1.188.0 -aws-cdk.aws-events~=1.188.0 -aws-cdk.aws-iam~=1.188.0 -aws-cdk.aws-kinesis~=1.188.0 -aws-cdk.aws-kms~=1.188.0 -aws-cdk.aws-lambda_event_sources~=1.188.0 -aws-cdk.aws-lambda~=1.188.0 -aws-cdk.aws-logs~=1.188.0 -aws-cdk.aws-route53_targets~=1.188.0 -aws-cdk.aws-route53~=1.188.0 -aws-cdk.aws-s3_assets~=1.188.0 -aws-cdk.aws-s3_assets~=1.188.0 -aws-cdk.aws-s3_notifications~=1.188.0 -aws-cdk.aws-s3~=1.188.0 -aws-cdk.aws-sam~=1.188.0 -aws-cdk.aws-secretsmanager~=1.188.0 -aws-cdk.aws-servicediscovery~=1.188.0 -aws-cdk.aws-sns_subscriptions~=1.188.0 -aws-cdk.aws-sns~=1.188.0 -aws-cdk.aws-sns~=1.188.0 -aws-cdk.aws-sqs~=1.188.0 -aws-cdk.aws-ssm~=1.188.0 -aws-cdk.aws-stepfunctions~=1.188.0 -aws-cdk.core~=1.188.0 -aws-cdk.cx-api~=1.188.0 -aws-cdk.region-info~=1.188.0 +aws-cdk-lib==2.68.0 +constructs>=10.0.0,<11.0.0 aws-sam-cli==1.69.0 awscli==1.27.48 boto3==1.26.48