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")))
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, 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))
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)
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, 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: 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 = 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, 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): 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) -> 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' ]))
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' }))
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) -> 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)
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 __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) -> 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)
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)
def create_synth_action(_source_artifact, _cloud_assembly_artifact, _create_roles, _synth_accounts, additional_policy): return pipelines.SimpleSynthAction( source_artifact=_source_artifact, cloud_assembly_artifact=_cloud_assembly_artifact, install_command='npm install -g aws-cdk' + _create_roles, build_command="pip install -r requirements.txt", synth_command='cdk synth' + _synth_accounts + ' && cp cdk.json cdk.out', role_policy_statements=additional_policy, environment=BuildEnvironment( privileged=True, compute_type=ComputeType.LARGE, build_image=LinuxBuildImage.STANDARD_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='BabyNamesPipeline', source_action=cpactions.GitHubSourceAction( action_name='GitHub', output=source_artifact, oauth_token=core.SecretValue.secrets_manager('github-token'), owner='stuartgraham', repo='ScotBabyNames', branch='main', trigger=cpactions.GitHubTrigger.POLL), synth_action=pipelines.SimpleSynthAction( source_artifact=source_artifact, cloud_assembly_artifact=cloud_assembly_artifact, install_commands=[ 'npm install -g aws-cdk && pip install -r requirements.txt' ], build_commands=[''], synth_command='cdk synth')) dev_stage = pipeline.add_application_stage( ApplicationStage(self, 'Development', cdk_env_='Development', env={ 'account': '811799881965', 'region': 'eu-west-1' })) dev_stage.add_manual_approval_action(action_name='Promotion') pipeline.add_application_stage( ApplicationStage(self, 'Production', cdk_env_='Production', env={ 'account': '756754323790', 'region': 'eu-west-1' }))
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: super().__init__(scope, id, **kwargs) #declare sourece and destination source_artifact = codepipeline.Artifact() cloud_assembly_artifact = codepipeline.Artifact() #declare pipline pipeline = pipelines.CdkPipeline( self, 'Pipeline', cloud_assembly_artifact=cloud_assembly_artifact, pipeline_name='Pipline', #Code Trigger point to GitHub and take token from secert manager source_action=cpations.GitHubSourceAction( action_name='GitHub', output=source_artifact, oauth_token=core.SecretValue.secrets_manager('github-token'), owner='AungBoTun', repo="piplines", trigger=cpations.GitHubTrigger.POLL), #Code Build to execute ckd to CF 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( webservice_stage(self, 'Pre-Prod', env={ 'account': '308383475786', 'region': 'ap-southeast-1', })) pipeline.add_application_stage( webservice_stage(self, 'Prod', env={ 'account': '308383475786', 'region': 'ap-southeast-2', }))
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, 'datapipeline-demo-cd', 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']] ), aws_iam.PolicyStatement( actions=[ "ec2:CreateNetworkInterface", "ec2:DescribeAvailabilityZones", "ec2:DescribeInternetGateways", "ec2:DescribeSecurityGroups", "ec2:DescribeSubnets", "ec2:DescribeVpcs", "ec2:DeleteNetworkInterface", "ec2:ModifyNetworkInterfaceAttribute" ], resources=['*'] ), ], 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(DeploymentStage(self, 'datapipeline-demo'))
def __init__(self, scope: core.Construct, id: str, **kwargs): super().__init__(scope, id, **kwargs) param = Parameters.instance() pipeline_name = param.getParameter('pipeline_name') connection_arn = param.getParameter('connection_arn') github_owner = param.getParameter('github_owner') github_repo = param.getParameter('github_repo') github_branch = param.getParameter('github_branch') secret_arn = param.getParameter('secret_arn') source_artifact = codepipeline.Artifact() cloud_assembly_artifact = codepipeline.Artifact() pipeline = pipelines.CdkPipeline( self, 'CdkPipeline', cloud_assembly_artifact=cloud_assembly_artifact, pipeline_name=pipeline_name, source_action=cpactions.BitBucketSourceAction( action_name='GithubAction', output=source_artifact, connection_arn=connection_arn, owner=github_owner, repo=github_repo, branch=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=[secret_arn]) ], install_command= 'npm install -g aws-cdk && pip install --upgrade pip && pip install -r requirements.txt', synth_command= f"cdk synth -v -c region={AppContext.region} -c secret_name={AppContext.secret_name}", )) pipeline.add_application_stage(DeployStage(self, 'Deploy'))
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='Network-Pipeline', source_action=cpactions.GitHubSourceAction( action_name='GitHub', output=source_artifact, oauth_token=core.SecretValue.secrets_manager('github-token'), owner='marrnik', repo='network-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')) pipeline.add_application_stage( NetworkStage(self, 'Pre-Prod', env={ 'account': NETWORK_HUB_ACCOUNT, 'region': 'us-east-1' })) pipeline.add_application_stage( NetworkStage(self, 'Prod', env={ 'account': NETWORK_HUB_ACCOUNT, 'region': 'us-east-1' }))
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( scope=self, id="cdk-pipeline", pipeline_name="SSMComandsPipeline", cloud_assembly_artifact=cloud_assembly_artifact, source_action=codepipeline_actions.GitHubSourceAction( action_name="GitHub", output=source_artifact, oauth_token=core.SecretValue.secrets_manager( secret_id=constants.SECRET_GITHUB_ID, json_field=constants.SECRET_GITHUB_JSON_FIELD, ), trigger=codepipeline_actions.GitHubTrigger.POLL, owner=constants.GITHUB, repo=constants.GITHUB_REPO, ), synth_action=pipelines.SimpleSynthAction( source_artifact=source_artifact, cloud_assembly_artifact=cloud_assembly_artifact, install_command="npm install -g aws-cdk", build_command="pip install -r requirements.txt", synth_command="cdk synth", ), ) pipeline.add_application_stage( app_stage=SSMStage( scope=self, id='ssmstage', ), manual_approvals=False, )
def __init__(self, scope: core.Construct, id: str, **kwargs): super().__init__(scope, id, **kwargs) source_repo = codecommit.Repository( self, "sourcerepo", repository_name='ec2_generic_policy', description='Generic EC2 policy for using on EC2 Instance Roles') source_artifact = codepipeline.Artifact() cloud_assembly_artifact = codepipeline.Artifact() pipeline = pipelines.CdkPipeline( self, 'Pipeline', cloud_assembly_artifact=cloud_assembly_artifact, pipeline_name='EC2RolePolicy', source_action=cpactions.CodeCommitSourceAction( output=source_artifact, repository=source_repo, branch='master', trigger=cpactions.CodeCommitTrigger.EVENTS, action_name='OnRepoevent', run_order=1), 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')) # Add stages as required. app_env = core.Environment(account="194433038617", region="ap-southeast-2") prod_app = Ec2PolicyStage(self, 'Prod', env=app_env) prod_stage = pipeline.add_application_stage(prod_app)
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: super().__init__(scope, **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="bwarren2", repo="webinar-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", ), ) pre_prod_app = WebServiceStage( self, "Pre-Prod", env={ "account": "871089662319", "region": "us-east-1", }, ) pre_prod_stage = pipeline.add_application_stage(pre_prod_app) pre_prod_stage.add_actions( pipelines.ShellScriptAction( action_name="UnitTest", run_order=pre_prod_stage.next_sequential_run_order(), additional_artifacts=[source_artifact], commands=[ "pip install -r requirements.txt", "pytest unittests" ], ), 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": "871089662319", "region": "us-east-1", }, ))
def __init__(self, scope: core.Construct, id: str, config: BaseSettings, **kwargs): super().__init__(scope, id, **kwargs) source_artifact = codepipeline.Artifact() cloud_assembly_artifact = codepipeline.Artifact() source_action = pipeline_actions.GitHubSourceAction( action_name="GitHub", output=source_artifact, oauth_token=core.SecretValue.secrets_manager("github-token"), owner=config.gh_username, repo=config.gh_repo, trigger=pipeline_actions.GitHubTrigger.POLL, ) synth_action = pipelines.SimpleSynthAction( source_artifact=source_artifact, cloud_assembly_artifact=cloud_assembly_artifact, install_commands=[ "npm install -g aws-cdk", "pip install -r requirements.txt", ], test_commands=["pytest lambdas -v -m 'not integration'"], synth_command="cdk synth application", environment=codebuild.BuildEnvironment(privileged=True), ) pipeline = pipelines.CdkPipeline( self, "pipeline", cloud_assembly_artifact=cloud_assembly_artifact, pipeline_name="hello-pipeline", source_action=source_action, synth_action=synth_action, ) pre_prod_app = WebServiceStage( self, "preprod", env={ "account": config.account, "region": config.region, }, ) pre_prod_stage = pipeline.add_application_stage(pre_prod_app) pre_prod_stage.add_actions( pipelines.ShellScriptAction( action_name="integration_tests", run_order=pre_prod_stage.next_sequential_run_order(), additional_artifacts=[source_artifact], commands=[ "pip install -r requirements.txt", "pytest lambdas -v -m integration", ], use_outputs={ "http_api_url": pipeline.stack_output(pre_prod_app.service.http_api_url) }, )) pre_prod_stage.add_manual_approval_action(action_name="PromoteToProd") prod_app = WebServiceStage( self, "Prod", env={ "account": config.account, "region": config.region, }, ) pipeline.add_application_stage(prod_app)