Exemple #1
0
    def __init__(self,
                 scope: core.Construct,
                 id: str,
                 *,
                 repo_name: str = None,
                 bucket,
                 **kwargs) -> None:

        super().__init__(scope, id, **kwargs)
        github_secret_personal_site = sm.Secret(self,  'github_secret_personal_site', description=f'{__name__} secret for github', \
                secret_name='github_secret_personal_site')

        personal_site_pipeline = codepipeline.Pipeline(
            self, "Pipeline", pipeline_name="personal_site_github")

        source_output = codepipeline.Artifact()

        source_action = codepipeline_actions.GitHubSourceAction(
            action_name="GitHub_Source",
            owner=repo_name.split('/')[0],
            repo=repo_name.split('/')[1],
            oauth_token=core.SecretValue.secrets_manager(
                "github_secret_personal_site"),
            output=source_output,
            branch="master")

        deploy_action = codepipeline_actions.S3DeployAction(
            action_name="S3Deploy", bucket=bucket, input=source_output)

        #Add the stages defined above to the pipeline
        personal_site_pipeline.add_stage(stage_name="Source",
                                         actions=[source_action])

        personal_site_pipeline.add_stage(stage_name="Deploy",
                                         actions=[deploy_action])
    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, 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"))
    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))
Exemple #5
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'))
    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'}))    
    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")))
    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)
Exemple #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("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"
            )
        )
Exemple #10
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",
            ),
        )
    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):
        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, **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")
		)
Exemple #14
0
    def __init__(self, scope: core.Construct, id: str,
                 landing_zone: ILandingZone, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        self.pipeline = pipe.Pipeline(self,
                                      'Pipeline',
                                      pipeline_name='{}-Rtsp-Connector'.format(
                                          landing_zone.zone_name))

        github_init_artifact = pipe.Artifact(
            artifact_name='github-init-artifact')

        self.pipeline.add_stage(
            stage_name='Build-Commit',
            actions=[
                actions.GitHubSourceAction(
                    action_name='Init-from-GitHub',
                    owner='dr-natetorious',
                    repo='aws-homenet',
                    # Note: The secret must be:
                    #  1. formated non-json using the literal value from github.com/settings/tokens
                    #     e.g., 1837422b*****26d31c
                    #  2. referencing a token that includes scopes notifications, repo, workflow
                    oauth_token=core.SecretValue.secrets_manager(
                        'GithubAccessToken'),
                    output=github_init_artifact)
            ])

        self.build_stage = self.pipeline.add_stage(stage_name='Build')
Exemple #15
0
    def __init__(self, scope: core.Stack, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        # create a pipeline
        self.pipeline = codepipeline.Pipeline(self,
                                              "Pipeline",
                                              pipeline_name='API_Gateway')

        # add a source stage
        self.source_stage = self.pipeline.add_stage(stage_name="Source")
        self.source_artifact = codepipeline.Artifact()

        # codebuild projects
        self.codebuild_validate = CodeBuildProjects(
            self, "CodebuildValidate", buildspec='buildspec-diff.yml')
        self.codebuild_deploy = CodeBuildProjects(self,
                                                  "CodebuildDeploy",
                                                  buildspec='buildspec.yml')

        # add source action
        self.source_stage.add_action(
            codepipeline_actions.GitHubSourceAction(
                oauth_token=core.SecretValue.secrets_manager(
                    secret_id='prod/github_oauth_token',
                    json_field='github_oauth_token'),
                output=self.source_artifact,
                owner=config['CODEPIPELINE']['GITHUB_OWNER'],
                repo=config['CODEPIPELINE']['GITHUB_REPO'],
                branch=config['CODEPIPELINE']['GITHUB_BRANCH'],
                action_name='Pull_Source',
                run_order=1,
            ))

        # add validate stage
        self.validate_stage = self.pipeline.add_stage(stage_name='Validate')

        # add validate codebuild action
        self.validate_stage.add_action(
            codepipeline_actions.CodeBuildAction(
                input=self.source_artifact,
                project=self.codebuild_validate.project,
                action_name='Validate_Changes'))

        # add approval stage
        self.approval_stage = self.pipeline.add_stage(stage_name='Approval')

        # simple approval stage to continue build after manual validation complete
        self.approval_stage.add_action(
            codepipeline_actions.ManualApprovalAction(action_name='Approval'))

        # add deploy stage
        self.deploy_stage = self.pipeline.add_stage(stage_name='Deploy')

        # add deploy codebuild action
        self.deploy_stage.add_action(
            codepipeline_actions.CodeBuildAction(
                input=self.source_artifact,
                project=self.codebuild_deploy.project,
                action_name='Deploy_Changes'))
    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'
                            }))
Exemple #17
0
    def __init__(self, scope: core.Stack, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        # create an iam role to be assumed later by codebuild
        self.role = iam.Role(
            self,
            "CodeBuildRole",
            assumed_by=iam.CompositePrincipal(
                iam.ServicePrincipal('codebuild.amazonaws.com'),
                iam.ServicePrincipal('ec2.amazonaws.com')))

        # TODO: Don't need admin, let's make this least privilege
        self.role.add_to_policy(
            iam.PolicyStatement(
                actions=['*'],
                resources=['*'],
            ))

        # create a pipeline
        self.pipeline = codepipeline.Pipeline(self,
                                              "Pipeline",
                                              pipeline_name='EKS')

        # add a source stage
        self.source_stage = self.pipeline.add_stage(stage_name="Source")
        self.source_artifact = codepipeline.Artifact()

        # codebuild projects
        self.codebuild_deploy = CodeBuildProjects(self,
                                                  "CodebuildDeploy",
                                                  buildspec='buildspec.yml',
                                                  codepipelinerole=self.role)

        # add source action
        self.source_stage.add_action(
            codepipeline_actions.GitHubSourceAction(
                oauth_token=core.SecretValue.secrets_manager(
                    secret_id='prod/github_oauth_token',
                    json_field='github_oauth_token'),
                output=self.source_artifact,
                owner=config['CODEPIPELINE']['GITHUB_OWNER'],
                repo=config['CODEPIPELINE']['GITHUB_REPO'],
                action_name='Pull_Source',
                run_order=1,
            ))

        # add deploy stage
        self.deploy_stage = self.pipeline.add_stage(stage_name='Deploy')

        # add deploy codebuild action
        self.deploy_stage.add_action(
            codepipeline_actions.CodeBuildAction(
                input=self.source_artifact,
                project=self.codebuild_deploy.project,
                action_name='Deploy_EKS_Cluster'))
Exemple #18
0
    def __init__(self, scope: core.Stack, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)

        # create a pipeline
        self.pipeline = codepipeline.Pipeline(self,
                                              "Pipeline",
                                              pipeline_name='Service_API')

        # add a source stage
        self.source_stage = self.pipeline.add_stage(stage_name="Source")
        self.source_artifact = codepipeline.Artifact()

        # codebuild projects
        self.codebuild_deploy_swagger = CodeBuildProjects(
            self, "CodebuildSwagger", buildspec='buildspec-swagger.yml')
        self.codebuild_deploy_ecr = CodeBuildProjects(
            self, "CodebuildDocker", buildspec='buildspec-docker.yml')

        # add source action
        self.source_stage.add_action(
            codepipeline_actions.GitHubSourceAction(
                oauth_token=core.SecretValue.secrets_manager(
                    secret_id='prod/github_oauth_token',
                    json_field='github_oauth_token'),
                output=self.source_artifact,
                owner=config['CODEPIPELINE']['GITHUB_OWNER'],
                repo=config['CODEPIPELINE']['GITHUB_REPO'],
                branch=config['CODEPIPELINE']['GITHUB_BRANCH'],
                action_name='Pull_Source',
                run_order=1,
            ))

        # add build/test stage
        self.deploy_stage = self.pipeline.add_stage(
            stage_name='Test_and_Build')

        # add build/test codebuild action
        self.deploy_stage.add_action(
            codepipeline_actions.CodeBuildAction(
                input=self.source_artifact,
                project=self.codebuild_deploy_ecr.project,
                action_name='Test_and_Build'))

        # add deploy stage
        self.deploy_stage = self.pipeline.add_stage(
            stage_name='API_Deployment')

        # add deploy codebuild action
        self.deploy_stage.add_action(
            codepipeline_actions.CodeBuildAction(
                input=self.source_artifact,
                project=self.codebuild_deploy_swagger.project,
                action_name='API_Deployment'))
Exemple #19
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'
                }
            )
        )
Exemple #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)
Exemple #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)
                }))
    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'}))
    def create_source_stage(self, token, code_owner, source_repo, branch, action_name):
        
        artifact= pipeline.Artifact()
        
        git_source = pipelineActions.GitHubSourceAction(
            oauth_token=core.SecretValue.secrets_manager(token),
            output=artifact,
            owner=code_owner,
            repo= source_repo,
            branch=branch,
            action_name=action_name
        )

        return git_source, artifact
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # Create IAM Role For CodeBuild
        codebuild_role = iam.Role(
            self,
            "BuildRole",
            assumed_by=iam.ServicePrincipal("codebuild.amazonaws.com"),
            managed_policies=[
                iam.ManagedPolicy.from_aws_managed_policy_name(
                    "AdministratorAccess")
            ])

        # Create CodeBuild PipelineProject
        build_project = codebuild.PipelineProject(
            self,
            "BuildProject",
            role=codebuild_role,
            build_spec=codebuild.BuildSpec.from_source_filename(
                "aws-app-resources/buildspec.yml"))

        # Create CodePipeline
        pipeline = codepipeline.Pipeline(self, "Pipeline")

        # Create Artifact
        artifact = codepipeline.Artifact()

        # Add Source Stage
        pipeline.add_stage(
            stage_name="Source",
            actions=[
                codepipeline_actions.GitHubSourceAction(
                    action_name="SourceCodeRepo",
                    owner="jasonumiker",
                    repo="k8s-plus-aws-gitops",
                    output=artifact,
                    oauth_token=core.SecretValue.secrets_manager(
                        'github-token'))
            ])

        # Add CodeBuild Stage
        pipeline.add_stage(
            stage_name="Deploy",
            actions=[
                codepipeline_actions.CodeBuildAction(
                    action_name="CodeBuildProject",
                    project=build_project,
                    type=codepipeline_actions.CodeBuildActionType.BUILD,
                    input=artifact)
            ])
Exemple #25
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'
        }))
    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)
Exemple #27
0
    def create_source_action(self, branch, source_output):
        secret = secretsmanager.Secret.from_secret_attributes(self,
                                                              branch + "_secret",
                                                              secret_arn="arn:aws:secretsmanager:ap-northeast-1:044768335503:secret:github-api-token-wtevPt")
        oauth_token = secret.secret_value_from_json("github-api-token")

        return codepipeline_actions.GitHubSourceAction(
            action_name="GithubRepo",
            oauth_token=oauth_token,
            output=source_output,
            owner=owner,
            repo=repo_name,
            branch=branch
        )
Exemple #28
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)
Exemple #29
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)
Exemple #30
0
def create_source_stage(self, source_output, from_bucket):
    source_stage=_cp.StageProps(
        stage_name='Source',
        actions=[
            _cpa.GitHubSourceAction(
                action_name='source_from_github',
                owner='koren-kobatake',
                repo='aws-study',
                branch='master',
                trigger=_cpa.GitHubTrigger.POLL,
                oauth_token=SecretValue.plain_text('21063a42a37fa2b93804b3ed776a9f4fbe450f2f'),
                output=source_output
            )
        ]
    )
    return source_stage