Пример #1
0
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact('SourceArtifact')
        cloud_assembly_artifact = codepipeline.Artifact('CloudAssembly')

        resume_stack_repository = codecommit.Repository.from_repository_name(
            self, "ResumeStack",repository_name="ResumeStack")

        pipeline = pipelines.CdkPipeline(
            self, 'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name="ResumeStack",
            source_action=cpactions.CodeCommitSourceAction(
                action_name='GetCodeCommit',
                output=source_artifact,
                repository=resume_stack_repository,
                trigger=cpactions.CodeCommitTrigger.POLL
                ),
            
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                action_name='SimpleSynthAction',
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command='npm install -g aws-cdk && pip install -r requirements.txt',
                synth_command='cdk synth'))

        build_stage = pipeline.add_application_stage(ResumeBuildStage(self, 'BuildWebsite'))
        deploy_stage = pipeline.add_application_stage(ResumeDeployStage(self, 'Website'))
        
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        # Install_command - installs CDK
        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='Webinar_Pipeline',
            source_action=cpactions.GitHubSourceAction(
                action_name='GitHub',
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager('github-token'),
                owner='kevinggrimm',
                repo='aws-cdk-pipeline',
                trigger=cpactions.GitHubTrigger.POLL),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command=
                'npm install -g aws-cdk && pip install -r requirements.txt',
                build_command='pytest unittests',
                synth_command='cdk synth'))

        # Can be a different account and region
        # Easy ability to deploy to different regions, accounts
        pre_prod_app = WebServiceStage(self,
                                       'Pre-prod',
                                       env=core.Environment(
                                           account="893961191302",
                                           region="us-west-1"))

        pre_prod_stage = pipeline.add_application_stage(pre_prod_app)

        # use_outputs - give env var to fill; ask pipeline for stack output represented by URL
        pre_prod_stage.add_actions(
            pipelines.ShellScriptAction(
                action_name='Integ',
                run_order=pre_prod_stage.next_sequential_run_order(),
                additional_artifacts=[source_artifact],
                commands=[
                    'pip install -r requirements.txt',
                    'pytest integtests',
                ],

                # Output represented by URL output
                # Can create identifiable outputs for usage in pipeline
                use_outputs={
                    'SERVICE_URL':
                    pipeline.stack_output(pre_prod_app.url_output)
                }))

        pipeline.add_application_stage(
            WebServiceStage(self,
                            'Prod',
                            env=core.Environment(account="893961191302",
                                                 region="us-west-1")))
Пример #3
0
    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = CdkPipeline(self, "Pipeline",
            pipeline_name="MyAppPipeline",
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_action=codepipeline_actions.GitHubSourceAction(
                action_name="GitHub",
                output=source_artifact,
                oauth_token=SecretValue.secrets_manager("GITHUB_TOKEN_NAME"),
                trigger=codepipeline_actions.GitHubTrigger.POLL,
                # Replace these with your actual GitHub project info
                owner="srinivasreddych",
                repo="cdk-pipelines"),
            synth_action=SimpleSynthAction.standard_npm_synth(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                # Use this if you need a build step (if you're not using ts-node
                # or if you have TypeScript Lambdas that need to be compiled).
                build_command="npm run build"
            )
        )
Пример #4
0
    def __init__(self, scope: core.Construct, id: str, params: dict, **kwargs):
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            'CdkPipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name=params['pipeline_name'],
            source_action=cpactions.BitBucketSourceAction(
                action_name='GithubAction',
                output=source_artifact,
                connection_arn=params['connection_arn'],
                owner=params['github_owner'],
                repo=params['github_repo'],
                branch=params['github_branch']),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                role_policy_statements=[
                    aws_iam.PolicyStatement(
                        actions=["secretsmanager:GetSecretValue"],
                        resources=[params['secret_arn']])
                ],
                install_command=
                'npm install -g aws-cdk && pip install --upgrade pip && pip install -r requirements.txt',
                synth_command="cdk synth -v -c region=%s -c secret_name=%s" %
                (params['region'], params['secret_name']),
            ))

        pipeline.add_application_stage(CmnStage(self, 'CMN'))
	def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
		super().__init__(scope, id, **kwargs)

		source_artifact = aws_codepipeline.Artifact()
		cloud_assembly_artifact = aws_codepipeline.Artifact()

		pipeline = CdkPipeline(
			self,
			"cdk_pipeline",
			pipeline_name="IntroCdkpipelinesStack_Pipeline",
			cloud_assembly_artifact=cloud_assembly_artifact,
			source_action=aws_codepipeline_actions.GitHubSourceAction(
				action_name="GitHub",
				output=source_artifact,
				oauth_token=SecretValue.secrets_manager(
					secret_id="github-token",
					json_field="github-token"
				),
				owner="MasatoShima",
				repo="Samples-AWS-Hands-On-CDK",
				trigger=aws_codepipeline_actions.GitHubTrigger.POLL
			),
			synth_action=SimpleSynthAction.standard_yarn_synth(
				source_artifact=source_artifact,
				cloud_assembly_artifact=cloud_assembly_artifact,
				install_command="pip install -r requirements.txt",
				subdirectory="./intro_cdkpipelines/"
			)
		)

		pipeline.add_application_stage(
			CdkpipelinesDemoStage(self, "PreProd")
		)
    def __init__(self,scope:core.Construct,id:str,**kwargs):
        super().__init__(scope,id,**kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(self, 'Pipeline',

            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='CdkTrainerPipeline',

            source_action=cpactions.GitHubSourceAction(
                action_name='Github',
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager('trainer-github-token'),
                owner='trey-rosius',
                repo='cdkTrainerPipeline',
                trigger=cpactions.GitHubTrigger.POLL),

            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command='npm install -g aws-cdk && pip install -r requirements.txt',
                synth_command= 'cdk synth'))
        pipeline.add_application_stage(WebServiceStage(self,'Pre-Production',env={
    
    'account':'132260253285',
    'region': 'us-east-2'}))    
Пример #7
0
    def __init__(self, scope: core.Construct, construct_id: str, **kwargs):
        super().__init__(scope, construct_id, **kwargs)

        source_artifact = cp.Artifact("SourceArtifact")
        cloud_assembly_artifact = cp.Artifact("CloudAssemblyArtifact")

        cicd_pipeline = pipelines.CdkPipeline(
            self,
            "DemoPipeline",
            cross_account_keys=False,
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name="DemoPipeline",
            source_action=cp_actions.GitHubSourceAction(
                action_name="GitHub",
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager(
                    "github-token-blake-enyart"),
                owner="blake-enyart",
                repo="data_pipeline_practice",
                branch="main",
                trigger=cp_actions.GitHubTrigger.POLL,
            ),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_commands=[
                    "npm install -g [email protected]",
                    "pip install -r requirements.txt",
                    "poetry config virtualenvs.create false",
                    "poetry install --no-dev",
                ],
                synth_command="cdk synth",
            ),
        )
Пример #8
0
  def __init__(self, scope: core.Construct, id: str, **kwargs):
    super().__init__(scope, id, **kwargs)

    source_artifact = codepipeline.Artifact()
    cloud_assembly_artifact = codepipeline.Artifact()

    pipeline = pipelines.CdkPipeline(self, 'Pipeline',
      cloud_assembly_artifact=cloud_assembly_artifact,
      pipeline_name='WebinarPipeline',

      source_action=cpactions.GitHubSourceAction(
        action_name='GitHub',
        output=source_artifact,
        oauth_token=core.SecretValue.secrets_manager('github-token'),
        owner='sandipganguly',
        repo='cdkpipeline',
        branch='master',
        trigger=cpactions.GitHubTrigger.POLL),

      synth_action=pipelines.SimpleSynthAction(
        source_artifact=source_artifact,
        cloud_assembly_artifact=cloud_assembly_artifact,
        install_command='npm install -g aws-cdk && pip install -r requirements.txt',
        build_command='pytest unittests',
        synth_command='cdk synth'))
Пример #9
0
    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = CdkPipeline(self, "Pipeline",
            pipeline_name="MyAppPipeline",
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_action=codepipeline_actions.GitHubSourceAction(
                action_name="GitHub",
                output=source_artifact,
                oauth_token=SecretValue.secrets_manager("pipeline_api_key"),
                trigger=codepipeline_actions.GitHubTrigger.POLL,
                # Replace these with your actual GitHub project info
                owner="joeycoak",
                repo="lab2-cdk"),
            synth_action=SimpleSynthAction.standard_npm_synth(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                # Use this if you need a build step (if you're not using ts-node
                # or if you have TypeScript Lambdas that need to be compiled).
                build_command="pip install -r requirements.txt",
                install_command="npm install -g aws-cdk && pip install -r requirements.txt",
                synth_command="cdk synth"
            )
        )
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            "ContinuousAudit",
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name="ContinuousAuditPipeline",
            source_action=codepipeline_actions.GitHubSourceAction(
                action_name="GitHub",
                branch="main",
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager("github-token"),
                owner="michael-dickinson-sainsburys",
                repo="continuous-audit"),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_commands=[
                    "npm install -g aws-cdk", "pip install --upgrade pip",
                    "pip install pytest", "pip install -r requirements.txt"
                ],
                synth_command="cdk synth",
                test_commands=["pytest -vvv"]))
        pipeline.add_application_stage(
            ProwlerStage(self,
                         "Test",
                         env={
                             "account": "673792865749",
                             "region": "eu-west-2"
                         }))
    def __init__(self, scope: core.Construct, construct_id: str,
                 deploy_flags: int, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        # The code that defines your stack goes here

        source_artifact = cppl.Artifact()
        cloud_assembly_artifact = cppl.Artifact()

        npm_install_cmd: str = 'npm install -g aws-cdk && pip install -r requirements.txt'

        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name=construct_id,
            source_action=cpplactions.GitHubSourceAction(
                action_name='GitHub',
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager(
                    'github-as-chuckwilbur-user'),
                owner='chuckwilbur',
                repo='study_guide_exercises',
                branch='main',
                trigger=cpplactions.GitHubTrigger.POLL),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command=npm_install_cmd,
                synth_command='cdk synth'))

        pipeline.add_application_stage(
            WebServerStage(self, 'Pre-Prod', deploy_flags, **kwargs))
Пример #12
0
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly = codepipeline.Artifact()
        
        build_environment = codebuild.BuildEnvironment(
            build_image=codebuild.LinuxBuildImage.AMAZON_LINUX_2_3,
            privileged=True
        )

        the_pipeline = pipelines.CdkPipeline(self, "Pipeline",
            pipeline_name="DefaultPipeline",
            cloud_assembly_artifact=cloud_assembly,
            source_action=actions.GitHubSourceAction(
                action_name="GitHub",
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager("github-token"),
                owner="JakeHendy",
                repo="cloudsatlhr"
            ),

            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                subdirectory="source",
                synth_command="npx cdk synth",
                install_command="pip install -r requirements.txt",
                environment=build_environment,
                cloud_assembly_artifact=cloud_assembly
                )
        )
        the_pipeline.add_application_stage(AcquisitionStack(self, "AcqusitionStackDev"))
Пример #13
0
    def __init__(self, scope: core.Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(self, 'PipelineToy',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='WebinarPipeline',
            source_action= cpactions.GitHubSourceAction(
                action_name='Github',
                output= source_artifact,
                oauth_token= core.SecretValue.secrets_manager('GitHub_cdk_workshop'),
                owner='JuanGQCadavid',
                repo='cdkAwsPipe',
                trigger=cpactions.GitHubTrigger.POLL),
            synth_action= pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command='npm install -g aws-cdk && pip install -r requirements.txt',
                synth_command='cdk synth')
            )

        pipeline.add_application_stage(WebServiceStage(self,'Pre-Prod', env={
            'region':'eu-central-1'
        }))
    def __init__(self, scope: core.Construct, id: str,
                 the_application: core.Stage, the_application_ue1: core.Stage,
                 **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = aws_codepipeline.Artifact()
        cloud_artifact = aws_codepipeline.Artifact()

        source_action = aws_codepipeline_actions.GitHubSourceAction(
            oauth_token=core.SecretValue.secrets_manager("github-token"),
            output=source_artifact,
            action_name="GitHub",
            owner="JakeHendy",
            repo="cdk-pipelines-demo",
            trigger=aws_codepipeline_actions.GitHubTrigger.WEBHOOK)

        synth_action = pipelines.SimpleSynthAction(
            install_command="pip install -r requirements.txt",
            synth_command="npx cdk synth",
            source_artifact=source_artifact,
            cloud_assembly_artifact=cloud_artifact)
        pipeline = pipelines.CdkPipeline(
            self,
            "Pipeline",
            cloud_assembly_artifact=cloud_artifact,
            source_action=source_action,
            synth_action=synth_action)
        # The code that defines your stack goes here

        pipeline.add_application_stage(the_application)
        pipeline.add_application_stage(the_application_ue1)
Пример #15
0
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # Creates a CodeCommit repository called 'WorkshopRepo'
        repo = codecommit.Repository(self,
                                     'WorkshopRepo',
                                     repository_name="WorkshopRepo")

        # Defines the artifact representing the sourcecode
        source_artifact = codepipeline.Artifact()
        # Defines the artifact representing the cloud assembly
        # (cloudformation template + all other assets)
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,

            # Generates the source artifact from the repo we created in the last step
            source_action=codepipeline_actions.CodeCommitSourceAction(
                action_name='CodeCommit',  # Any Git-based source control
                output=source_artifact,  # Indicates where the artifact is stored
                repository=repo  # Designates the repo to draw code from
            ),

            # Builds our source code outlined above into a could assembly artifact
            synth_action=pipelines.SimpleSynthAction(
                install_commands=[
                    'npm install -g aws-cdk',  # Installs the cdk cli on Codebuild
                    'pip install -r requirements.txt'  # Instructs Codebuild to install required packages
                ],
                synth_command='npx cdk synth',
                source_artifact=
                source_artifact,  # Where to get source code to build
                cloud_assembly_artifact=
                cloud_assembly_artifact,  # Where to place built source
            ))

        deploy = WorkshopPipelineStage(self, 'Deploy')
        deploy_stage = pipeline.add_application_stage(deploy)
        deploy_stage.add_actions(
            pipelines.ShellScriptAction(action_name='TestViewerEndpoint',
                                        use_outputs={
                                            'ENDPOINT_URL':
                                            pipeline.stack_output(
                                                deploy.hc_viewer_url)
                                        },
                                        commands=['curl -Ssf $ENDPOINT_URL']))
        deploy_stage.add_actions(
            pipelines.ShellScriptAction(
                action_name='TestAPIGatewayEndpoint',
                use_outputs={
                    'ENDPOINT_URL': pipeline.stack_output(deploy.hc_endpoint)
                },
                commands=[
                    'curl -Ssf $ENDPOINT_URL', 'curl -Ssf $ENDPOINT_URL/hello',
                    'curl -Ssf $ENDPOINT_URL/test'
                ]))
Пример #16
0
    def __init__(self, pipeline_data: PipelineData):
        super().__init__(pipeline_data.scope,
                         pipeline_data.name,
                         env=pipeline_data.env)
        self.source_artifact = cp.Artifact('Source')
        self.cloud_assembly_artifact = cp.Artifact('CloudAs')
        self.pipeline = CdkPipeline(
            self,
            "Pipeline",
            self_mutating=True,
            cross_account_keys=False,
            cloud_assembly_artifact=self.cloud_assembly_artifact,
            source_action=cpa.BitBucketSourceAction(
                role=iam.LazyRole(
                    self,
                    'SourceRole',
                    assumed_by=iam.AccountPrincipal(self.account),
                    managed_policies=[
                        iam.ManagedPolicy.from_aws_managed_policy_name(
                            'AmazonS3FullAccess')
                    ]),
                action_name="Ship",
                connection_arn=pipeline_data.github_connection_arn,
                owner=pipeline_data.github_owner,
                repo=pipeline_data.repo_name,
                branch=pipeline_data.repo_branch,
                output=self.source_artifact),
            synth_action=SimpleSynthAction(
                install_commands=pipeline_data.synth_install_commands,
                environment=cb.BuildEnvironment(
                    environment_variables={
                        env_key: cb.BuildEnvironmentVariable(
                            value=pipeline_data.build_env[env_key])
                        for env_key in pipeline_data.build_env
                    },
                    build_image=cb.LinuxBuildImage.STANDARD_5_0,
                    compute_type=cb.ComputeType.SMALL,
                    privileged=True),
                synth_command='cdk synth',
                action_name='Synthesize',
                cloud_assembly_artifact=self.cloud_assembly_artifact,
                source_artifact=self.source_artifact))
        pipeline = self.pipeline.node.try_find_child('Pipeline')
        build_stage = pipeline.node.try_find_child('Build')
        synth_action = build_stage.node.try_find_child('Synthesize')
        build_proj = synth_action.node.try_find_child('CdkBuildProject')
        cfn_build_project = build_proj.node.default_child

        # Need Privileged mode for starting docker
        cfn_build_project.add_property_override("Environment.PrivilegedMode",
                                                "true")
        # Updating from v4 by default in aws-cdk to v5
        cfn_build_project.add_property_override("Environment.Image",
                                                "aws/codebuild/standard:5.0")
        # Only clone the last commit. Don't clone the history
        cfn_build_project.add_property_override("Source.GitCloneDepth", 1)

        self.pipeline.add_application_stage(pipeline_data.app_stage)
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='CdkPipeline',
            source_action=cpactions.GitHubSourceAction(
                action_name='Github',
                oauth_token=core.SecretValue.secrets_manager('github-token'),
                output=source_artifact,
                owner='bgreengo',
                repo='aws-cdk-python-pipelines',
                trigger=cpactions.GitHubTrigger.POLL),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command=
                'npm install -g aws-cdk && pip install -r requirements.txt',
                build_command='pytest unittests',
                synth_command='cdk synth'))

        pre_prod_app = WebServiceStage(self,
                                       'Pre-Prod',
                                       env={
                                           'account': '987092829714',
                                           'region': 'us-west-2'
                                       })

        pre_prod_stage = pipeline.add_application_stage(pre_prod_app)

        pre_prod_stage.add_actions(
            pipelines.ShellScriptAction(
                action_name='Integ',
                run_order=pre_prod_stage.next_sequential_run_order(),
                additional_artifacts=[source_artifact],
                commands=[
                    'pip install -r requirements.txt',
                    'pytest integtests',
                ],
                use_outputs={
                    'SERVICE_URL':
                    pipeline.stack_output(pre_prod_app.url_output)
                }))

        pipeline.add_application_stage(
            WebServiceStage(self,
                            'Prod',
                            env={
                                'account': '987092829714',
                                'region': 'us-west-2'
                            }))
Пример #18
0
    def __init__(self, scope: core.Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        # artifacts for source code and assemblies
        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self, 'GenericPipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='GenericPipeline',
            source_action=codepipeline_actions.GitHubSourceAction(
                action_name='GitHub',
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager(
                    'github-token'
                ),
                owner='markusbecker',
                repo='generic_cdk',
                trigger=codepipeline_actions.GitHubTrigger.POLL
            ),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command='npm install -g aws-cdk && pip install -r requirements.txt',
                build_command='pytest unittests',
                synth_command='cdk synth'
            )
        )

        dev_stage = pipeline.add_application_stage(
            GenericAppStage(
                self, 'dev',
                env={
                    'account': '920278350745',
                    'region': 'eu-west-1'
                }
            )
        )

        dev_stage.add_manual_approval_action(
            action_name='ToProduction')

        pipeline.add_application_stage(
            GenericAppStage(
                self, 'prod',
                env={
                    'account': '920278350745',
                    'region': 'eu-west-1'
                }
            )
        )
    def __init__(self, scope: core.Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        this_dir = path.dirname(__file__)

        code_build_project = codebuild.PipelineProject(
            self,
            "demoServiceProject",
            build_spec=codebuild.BuildSpec.from_source_filename(
                './pipeline/java_services/DemoService/buildspec.yml'))

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()
        java_build_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='WebinarPipeline',
            source_action=cpactions.GitHubSourceAction(
                action_name='Github',
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager('github-token'),
                owner='JuanGQCadavid',
                repo='cd_last_project_pipeline',
                trigger=cpactions.GitHubTrigger.POLL),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command=
                'npm install -g aws-cdk && pip install -r requirements.txt',
                synth_command='cdk synth'))

        build_action = cpactions.CodeBuildAction(
            input=source_artifact,
            outputs=[java_build_artifact],
            project=code_build_project,
            action_name="demoServicesBuildAction",
        )

        buildStage = pipeline.add_stage(stage_name="JavaBuild")
        buildStage.add_actions(build_action)

        pre_prod_stage = pipeline.add_application_stage(
            WebServiceStage(self, 'Pre-prod', env={'region': 'us-east-1'}))

        pre_prod_stage.add_manual_approval_action(action_name='PromoteToProd')

        pipeline.add_application_stage(
            WebServiceStage(self, 'Prod', env={'region': 'us-east-1'}))
Пример #20
0
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        sourceArtifact = codepipeline.Artifact()
        cloudAssemblyArtifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(self, 'Pipeline',
                                         pipeline_name=self.node.try_get_context(
                                             'repository_name') + "-{}-pipeline".format(STAGE),
                                         cloud_assembly_artifact=cloudAssemblyArtifact,
                                         source_action=actions.GitHubSourceAction(
                                            action_name='GitHub',
                                            output=sourceArtifact,
                                            oauth_token=core.SecretValue.secrets_manager('github-token'),
                                            owner=self.node.try_get_context(
                                             'owner'),
                                            repo=self.node.try_get_context(
                                             'repository_name'),
                                            branch=STAGE
                                        ),
                                         synth_action=pipelines.SimpleSynthAction(
                                             synth_command="cdk synth",
                                             install_commands=[
                                                 "pip install --upgrade pip",
                                                 "npm i -g aws-cdk",
                                                 "pip install -r requirements.txt"
                                             ],
                                             source_artifact=sourceArtifact,
                                             cloud_assembly_artifact=cloudAssemblyArtifact,
                                             environment={
                                                 'privileged': True
                                             },
                                             environment_variables={
                                                 'DEV_ACCOUNT_ID': codebuild.BuildEnvironmentVariable(value=os.environ['DEV_ACCOUNT_ID']),
                                                 'STG_ACCOUNT_ID': codebuild.BuildEnvironmentVariable(value=os.environ['STG_ACCOUNT_ID']),
                                                 'PROD_ACCOUNT_ID': codebuild.BuildEnvironmentVariable(value=os.environ['PROD_ACCOUNT_ID']),
                                                 'MANAGE_ACCOUNT_ID': codebuild.BuildEnvironmentVariable(value=os.environ['MANAGE_ACCOUNT_ID'])
                                             }
                                         )
                                         )

        dev = PipelineStage(
            self,
            self.node.try_get_context('service_name') + "-{}".format(STAGE),
            env={
                'region': "ap-northeast-1",
                'account': os.environ['DEV_ACCOUNT_ID']
            }
        )

        dev_stage = pipeline.add_application_stage(dev)
Пример #21
0
    def __init__(self, scope: core.Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name='WebinarPipeline',
            source_action=cpactions.GitHubSourceAction(
                action_name='GitHub',
                output=source_artifact,
                oauth_token=core.SecretValue.secrets_manager('GITHUB-TOKEN'),
                owner='ajaykumar011',
                repo='my-pipeline',
                branch='main',
                trigger=cpactions.GitHubTrigger.POLL),
            synth_action=pipelines.SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                install_command=
                'npm install -g aws-cdk && pip install -r requirements.txt && pip install pytest',
                build_command='pytest unittests',
                synth_command='cdk synth'))

        pre_prod_app = WebServiceStage(
            self,
            'Pre-Prod',
            env={
                'account': PRE_PROD_ACCOUNT,
                'region':
                'ap-south-1',  #This is the same region where pipeline is
            })
        pre_prod_stage = pipeline.add_application_stage(pre_prod_app)
        pre_prod_stage.add_actions(
            pipelines.ShellScriptAction(
                action_name='Integ',
                run_order=pre_prod_stage.next_sequential_run_order(),
                additional_artifacts=[source_artifact],
                commands=[
                    'pip install -r requirements.txt',
                    'pip install requests',
                    'pip install pytest',
                    'pytest integtests',
                ],
                use_outputs={
                    'SERVICE_URL':
                    pipeline.stack_output(pre_prod_app.url_output)
                }))
Пример #22
0
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        sourceArtifact = codepipeline.Artifact()
        cloudAssemblyArtifact = codepipeline.Artifact()

        pipeline = pipelines.CdkPipeline(
            self,
            'Pipeline',
            pipeline_name=self.node.try_get_context('repository_name') +
            "-{}-pipeline".format(STAGE),
            cloud_assembly_artifact=cloudAssemblyArtifact,
            source_action=actions.GitHubSourceAction(
                action_name='GitHub',
                output=sourceArtifact,
                oauth_token=core.SecretValue.secrets_manager('github-token'),
                owner=self.node.try_get_context('owner'),
                repo=self.node.try_get_context('repository_name'),
                branch=STAGE2),
            synth_action=pipelines.SimpleSynthAction(
                synth_command="cdk synth",
                install_commands=[
                    "pip install --upgrade pip", "npm i -g aws-cdk",
                    "pip install -r requirements.txt"
                ],
                source_artifact=sourceArtifact,
                cloud_assembly_artifact=cloudAssemblyArtifact,
                environment={'privileged': True}))

        stg = PipelineStage(self,
                            self.node.try_get_context('repository_name') +
                            "-{}".format(STAGE),
                            env={
                                'region': "ap-northeast-1",
                                'account': os.environ['STG_ACCOUNT_ID']
                            })

        stg_stage = pipeline.add_application_stage(stg)
        stg_stage.add_actions(
            actions.ManualApprovalAction(
                action_name="Approval",
                run_order=stg_stage.next_sequential_run_order()))
        prod = PipelineStage(self,
                             self.node.try_get_context('repository_name') +
                             "-{}".format(STAGE2),
                             env={
                                 'region': "ap-northeast-1",
                                 'account': os.environ['PROD_ACCOUNT_ID']
                             })
        pipeline.add_application_stage(app_stage=prod)
Пример #23
0
    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        pipeline = CdkPipeline(self, "Pipeline",
            pipeline_name="WebinarPipeline",
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_action=codepipeline_actions.GitHubSourceAction(
                action_name="GitHub",
                output=source_artifact,
                oauth_token=SecretValue.secrets_manager("github-token"),
                trigger=codepipeline_actions.GitHubTrigger.POLL,
                # Replace these with your actual GitHub project info
                owner="rcouso",
                repo="cdkpipeline",
                branch="main"),
            synth_action=SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                # Use this if you need a build step (if you're not using ts-node
                # or if you have TypeScript Lambdas that need to be compiled).
                install_command="npm install -g aws-cdk && pip install -r requirements.txt",
                build_command="pytest pipelines_webinar/unittests",
                synth_command="cdk synth"
            )
        )
        # PRE STAGE
        pre_prod_app = WebServiceStage(self, 'Pre-Prod', env={
            'account': '282334958158',
            'region' : 'eu-west-1'
        })
        pre_prod_stage = pipeline.add_application_stage(pre_prod_app)
        pre_prod_stage.add_actions(ShellScriptAction(
            action_name="Integ",
            run_order=pre_prod_stage.next_sequential_run_order(),
            additional_artifacts=[source_artifact],
            commands=[
                "pip install -r requirements.txt",
                "pytest pipelines_webinar/integtests",
            ],
        use_outputs={
            "SERVICE_URL": pipeline.stack_output(pre_prod_app.url_output)
        }))
        # pre_prod_stage.add_manual_approval_action(action_name='PromoteToPro')
        pipeline.add_application_stage(WebServiceStage(self, 'Prod', env={
            'account': '282334958158',
            'region' : 'eu-west-1'
        }))
Пример #24
0
    def setup_api_pipeline(self):
        """Setup the build pipeline for API.

        Using codepipeline to create a Pipeline with 3 steps
            * Source: CodeCommitSourceAction
            * Build:  CodeBuildActioin
            * Deploy: EcsDeployAction: deploy to ECS service

        Returns
        -------
        aws_codepipeline.Pipeline

        """

        source_output = cp.Artifact()
        build_output = cp.Artifact(self.config.build_output)
        return cp.Pipeline(
            self,
            'ApiPipeline',
            pipeline_name=self.config.api.pipeline,
            stages=[
                cp.StageProps(stage_name='Source',
                              actions=[
                                  cp_actions.CodeCommitSourceAction(
                                      action_name='Source',
                                      repository=self.api_source,
                                      branch='master',
                                      output=source_output,
                                  )
                              ]),
                cp.StageProps(stage_name='Build',
                              actions=[
                                  cp_actions.CodeBuildAction(
                                      action_name='Build',
                                      project=self.api_build_project,
                                      input=source_output,
                                      outputs=[build_output])
                              ]),
                cp.StageProps(
                    stage_name='Deploy',
                    actions=[
                        cp_actions.EcsDeployAction(
                            action_name='Deploy',
                            service=self.service.service,
                            input=build_output,
                            # image_file=build_output.at_path('imagedefinitions.json')
                        )
                    ])
            ])
Пример #25
0
    def __init__(self, scope: core.Construct, id: str, *, env=None):
        super().__init__(scope, id, env=env)

        source_artifact = aws_codepipeline.Artifact()
        cloud_assembly_artifact = aws_codepipeline.Artifact()

        source_action = aws_codepipeline_actions.GitHubSourceAction(
            action_name="GitHub",
            output=source_artifact,
            oauth_token=core.SecretValue.secrets_manager("github-token"),
            # Replace these with your actual GitHub project name
            owner="winderslide008",
            repo="prj-cdk_python")

        synth_action = pipelines.SimpleSynthAction.standard_npm_synth(
            source_artifact=source_artifact,
            cloud_assembly_artifact=cloud_assembly_artifact,
            install_command=
            "npm install -g aws-cdk && npm update && python -m pip install -r requirements.txt",

            # Use this if you need a build step (if you're not using ts-node
            # or if you have TypeScript Lambdas that need to be compiled).
            build_command="npx cdk synth -o dist")

        cdk_props = pipelines.CdkPipelineProps(
            synth_action=synth_action,
            source_action=source_action,
            cloud_assembly_artifact=cloud_assembly_artifact,
            pipeline_name="cdkPythonPipeline")

        # pipeline = pipelines.CdkPipeline(self, "pipe", cdk_props=cdk_props)

        pipeline = pipelines.CdkPipeline(
            self,
            "pipelineCdkPython",
            synth_action=synth_action,
            source_action=source_action,
            cloud_assembly_artifact=cloud_assembly_artifact)

        pprod_env = core.Environment(account="927534600513",
                                     region="eu-central-1")
        # pprod_props = core.StageProps(env=pprod_env)
        pipeline_stage_pprod = PipelineStage(self, id="preprod", env=pprod_env)
        pipeline.add_application_stage(pipeline_stage_pprod)

        prod_env = core.Environment(account="582362266023",
                                    region="eu-central-1")
        pipeline_stage_prod = PipelineStage(self, id="prod", env=prod_env)
        pipeline.add_application_stage(pipeline_stage_prod)
Пример #26
0
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        source_action = codepipeline_actions.GitHubSourceAction(
            action_name="Github.com",
            output=source_artifact,
            oauth_token=core.SecretValue.secrets_manager(
                secret_id="asset-test", json_field="github_token"),  # TODO
            owner="amirfireeye",
            repo="asset-test",
            branch="master",
        )

        synth_action = pipelines.SimpleSynthAction(
            source_artifact=source_artifact,
            cloud_assembly_artifact=cloud_assembly_artifact,
            environment=dict(privileged=True),
            install_commands=[
                "pip install poetry",
                "npm install -g [email protected]",
                "DOCKERHUB_USERNAME=`aws secretsmanager get-secret-value --secret-id asset-test --query SecretString --output text | jq -r .docker_username`",
                "DOCKERHUB_PASSWORD=`aws secretsmanager get-secret-value --secret-id asset-test --query SecretString --output text | jq -r .docker_password`",
                "docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_PASSWORD}",
            ],
            synth_command=
            "poetry install && poetry run cdk synth && cat cdk.out/assembly-*/*.assets.json",
            role_policy_statements=[
                # for docker secret
                iam.PolicyStatement(effect=iam.Effect.ALLOW,
                                    actions=[
                                        "secretsmanager:ListSecrets",
                                        "secretsmanager:GetSecretValue"
                                    ],
                                    resources=["*"]),
            ])

        pipeline = pipelines.CdkPipeline(
            self,
            "pipeline",
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_action=source_action,
            synth_action=synth_action,
        )

        stage = BaseStage(self, "stage")
        pipeline.add_application_stage(stage)
Пример #27
0
    def setup_web_pipeline(self):
        """Setup the build pipeline.

        Using codepipeline to create a Web Pipeline with 3 stages:
            * Source: CodeCommitSourceAction
            * Build : CodeBuildActioin
            * Deploy: S3DeployAction

        Returns
        -------
        aws_codepipeline.Pipeline

        """

        source_output = cp.Artifact()
        build_output = cp.Artifact(self.config.web.build_output)
        return cp.Pipeline(
            self,
            'WebPipeline',
            pipeline_name=self.config.web.pipeline,
            stages=[
                cp.StageProps(stage_name='Source',
                              actions=[
                                  cp_actions.CodeCommitSourceAction(
                                      action_name='Source',
                                      repository=self.web_source,
                                      branch='master',
                                      output=source_output,
                                  )
                              ]),
                cp.StageProps(stage_name='Build',
                              actions=[
                                  cp_actions.CodeBuildAction(
                                      action_name='Build',
                                      project=self.web_build_project,
                                      input=source_output,
                                      outputs=[build_output])
                              ]),
                cp.StageProps(
                    stage_name='Deploy',
                    actions=[
                        cp_actions.S3DeployAction(
                            action_name='Deploy',
                            bucket=self.web_bucket,
                            input=build_output,
                            access_control=s3.BucketAccessControl.PUBLIC_READ)
                    ])
            ])
Пример #28
0
    def __init__(self, scope: core.Construct, id: str,
                 repo: codecommit.Repository, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        #---------- CodePipeline ----------#
        artifactBucket = s3.Bucket(self,
                                   'PipelineBucket',
                                   bucket_name="bucket-name")

        pipeline = codepipeline.Pipeline(
            self,
            "CodePipeline",
            artifact_bucket=s3.Bucket.from_bucket_attributes(
                self, 'ImportedBucket', bucket_name="bucket-name"))

        source_output = codepipeline.Artifact()
        source_action = codepipeline_actions.CodeCommitSourceAction(
            action_name="Source", repository=repo, output=source_output)
        pipeline.add_stage(stage_name="Source", actions=[source_action])

        #---------- Deploy ----------#
        deploy_application = codedeploy.ServerApplication(
            self, "CodeDeployApplication", application_name="application-name")

        deployment_group = codedeploy.ServerDeploymentGroup(
            self,
            "DeploymentGroup",
            application=deploy_application,
        )

        deploy_action = codepipeline_actions.CodeDeployServerDeployAction(
            action_name="deploy",
            input=source_output,
            deployment_group=deployment_group)
        pipeline.add_stage(stage_name="Deploy", actions=[deploy_action])
Пример #29
0
    def _source(self,
                owner: str,
                repo: str,
                branch: str = 'master',
                connection: str = None,
                oauth: str = None):
        """[summary]

        Args:
            owner (str): Github organization/user
            repo (str): git repository url name
            branch (str): git branch
            connection (str): AWS codebuild connection_arn
            oauth (str): Github oauth token
        """
        artifact = cp.Artifact()

        if not connection and not oauth:
            raise SystemError("No credentials for Github provided")

        checkout = cpa.BitBucketSourceAction(
            connection_arn=connection,
            action_name="Source-{}".format(branch),
            output=artifact,
            owner=owner,
            repo=repo,
            branch=branch,
            code_build_clone_output=True)

        self.artifacts['sources'].append(artifact)
        self.actions['sources'].append(checkout)
        self.pipe.add_stage(stage_name='Source@{}'.format(repo),
                            actions=[checkout])
Пример #30
0
    def __init__(self, scope: Construct, stack_name: str, component_id: str,
                 **kwargs):
        super().__init__(scope=scope, id=component_id, **kwargs)

        self.context = self.node.try_get_context('train')
        self.region = self.node.try_get_context('region')
        self.name_prefix = f"{stack_name}-{component_id}"
        self.sfn_name = f"{self.name_prefix}_{self.context['stepfunctions_name']}"

        self.source_output = codepipeline.Artifact()

        # Create Resources
        self._create_s3bucket()
        self._create_roles_for_train_step()
        self._create_roles_for_set_experiment_info_env_step()

        self.sns_topic = self._create_slack_notify_sns_topic()
        self._create_network()
        self._create_rds()
        self.set_experiment_info_env_lambdaFn = self._create_lambda_for_set_experiment_info_env(
        )
        self._create_lambda_for_manual_approval()
        self.postprocess_lambdaFn = self._create_lambda_for_post_process()

        self._create_pipeline()
        self._create_lambda()

        self._cfnoutput()