{"id":27603877,"url":"https://github.com/versent/cdk-code-pipeline-demo","last_synced_at":"2025-10-04T03:33:30.569Z","repository":{"id":282363672,"uuid":"948241470","full_name":"Versent/cdk-code-pipeline-demo","owner":"Versent","description":"The repository which contains a CDK AWS Code Pipeline demo","archived":false,"fork":false,"pushed_at":"2025-03-17T01:01:12.000Z","size":166,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T19:20:02.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Versent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-14T01:38:10.000Z","updated_at":"2025-03-18T10:57:41.000Z","dependencies_parsed_at":"2025-03-14T07:43:24.499Z","dependency_job_id":null,"html_url":"https://github.com/Versent/cdk-code-pipeline-demo","commit_stats":null,"previous_names":["versent/cdk-code-pipeline-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fcdk-code-pipeline-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fcdk-code-pipeline-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fcdk-code-pipeline-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fcdk-code-pipeline-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Versent","download_url":"https://codeload.github.com/Versent/cdk-code-pipeline-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250306601,"owners_count":21408927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-22T19:20:06.817Z","updated_at":"2025-10-04T03:33:30.508Z","avatar_url":"https://github.com/Versent.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CDK Code Pipeline Demo\n\nThis is a demo for how to use AWS Code Pipeline for creating cross account Continuous Integration and Continuous Delivery pipelines.\n\nThere are three stacks:\n\n- A common resources stack, which contains essential resources for pipelines: S3 bucket, KMS key and IAM roles.\n- A Continuous Integration pipeline, which builds and deploys PRs to a non-production environment.\n- A Continuous Delivery pipeline, which builds and deploys a workload to non-production and production environments.\n\nA separate CloudFormation template for Cross Account roles is used to deploy roles to the target accounts.\n\n## Architecture\n\n![Architecture](images/Architecture.png)\n\n### Cross Accounts Roles\n\n![Stack Sets](images/StackSets.png)\n\n## Workload requirements\n\nThe pipelines have assumed that there is a separate GitHub repository with a buildspec file, which builds the app and packages templates for deployment. For the purposes\nof testing this approach, this was a simple Python application with basic commands to build, test and lint source code and for the packaging of CloudFormation templates.\n\nThe example buildspec.yaml is as follows:\n\n```bash\nversion: 0.2\nphases:\n  install:\n    runtime-versions:\n      python: 3.9\n    commands:\n      - pip3 install pytest\n      - pip3 install cfn-lint\n  build:\n    commands:\n      # pytest\n      - python -m pytest --junitxml=test-reports/output.xml\n\n      # Run cfn-lint\n      - cfn-lint $TemplateName.yaml\n\n      # copy over environment config\n      - cp \"$TemplateName-dev-params.json\" \"packaged-template-dev-params.json\"\n      - cp \"$TemplateName-test-params.json\" \"packaged-template-test-params.json\"\n      - cp \"$TemplateName-prod-params.json\" \"packaged-template-prod-params.json\"\n\n      # install third party dependencies\n      - pip install --upgrade pip\n      - pip install -t /src -r requirements.txt\n\n      # copy Lambda source code\n      - cp -v workload/*.py /src\n\n      # package up cloud formation\n      - aws cloudformation package --template-file $TemplateName.yaml --s3-bucket $S3Bucket --s3-prefix $S3BuildsPrefix --output-template-file packaged-template.yaml\nartifacts:\n  name: BuildArtifacts\n  files:\n    - \"**/*\"\n  secondary-artifacts:\n    BuildOutput:\n      files:\n        - packaged-template.yaml\n        - \"*-params.json\"\nreports:\n  pytest_reports:\n    files:\n      - output.xml\n    base-directory: test-reports\n    file-format: JUNITXML\n```\n\n## Deploy commands\n\n### Prerequisites\n\n- Install CDK\n- Install the lastest version of the AWS CLI\n- Create a CodeStar connection to GitHub - https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create.html\n\n### Common Resources Stack\n\nThe following command can be used to deploy the stack:\ncdk deploy CommonResourcesStack \\\n --parameters CrossAccountDeployerRoleName=CrossAccountDeployerRole \\\n --parameters CrossAccountPipelineRoleName=CrossAccountPipelineRole \\\n --parameters OrganisationId=\u003corg-id\u003e\n\n## Deploy Cross Account Roles\n\nTo deploy the cross account roles to the target accounts, you can use the `template/CrossAccountRoles.yaml` CloudFormation template. This template sets up the necessary IAM roles for cross-account access.\n\nThe following command can be used to deploy the template to the target account:\n\n```bash\naws cloudformation deploy \\\n    --template-file template/CrossAccountRoles.yaml \\\n    --stack-name CrossAccountRolesStack \\\n    --capabilities CAPABILITY_NAMED_IAM \\\n    --parameter-overrides \\\n        CrossAccountPipelineRoleName=\u003cpipeline-role-name\u003e \\\n        CrossAccountDeployerRoleName=\u003cdeployer-role-name\u003e \\\n        PipelineAccount=\u003caccount-number\u003e \\\n        CMKARN: \u003ccmk-arn\u003e\n```\n\nNote there is some dependencies on the resources created in the common resources stack.\n\n### CI Pipeline Stack\n\nThe following command can be used to deploy the stack:\n\n    cdk deploy CIPipelineStack \\\n    --parameters BranchName=\u003cbranch-name\u003e \\\n    --parameters BranchTemplateName=\u003cbranch-template-name\u003e \\\n    --parameters CodeStarConnectionId=\u003ccode-star-connection-id\u003e \\\n    --parameters DependencyFolders=\u003cdependency-folders\u003e \\\n    --parameters NonProductionAccount=\u003caccount-number\u003e \\\n    --parameters RepositoryName=\u003crepo-name\u003e \\\n    --parameters RepositoryOwner=\u003crepo-owner\u003e \\\n    --parameters StackName=\u003cstack-name\u003e\n\nExample:\n\n    cdk deploy CIPipelineStack \\\n    --parameters BranchName=main \\\n    --parameters BranchTemplateName=template/cf-stack \\\n    --parameters CodeStarConnectionId=d1b54466-93f9-4482-a34d-a5bb39af7456 \\\n    --parameters NonProductionAccount=381492168999 \\\n    --parameters RepositoryName=code-pipeline \\\n    --parameters RepositoryOwner=craigjpickles \\\n    --parameters StackName=CodePipelineCDKDemo\n\n### CD Pipeline Stack\n\nThe following command can be used to deploy the stack:\n\n    cdk deploy CDPipelineStack \\\n    --parameters BranchName=\u003cbranch-name\u003e \\\n    --parameters BranchTemplateName=\u003cbranch-template-name\u003e \\\n    --parameters CodeStarConnectionId=\u003ccode-star-connection-id\u003e \\\n    --parameters DependencyFolders=\u003cdependency-folders\u003e \\\n    --parameters NonProductionAccount=\u003caccount-number\u003e \\\n    --parameters ProductionAccount=\u003caccount-number\u003e \\\n    --parameters RepositoryName=\u003crepo-name\u003e \\\n    --parameters RepositoryOwner=\u003crepo-owner\u003e \\\n    --parameters StackName=\u003cstack-name\u003e\n\nExample:\n\n    cdk deploy CDPipelineStack \\\n    --parameters BranchName=main \\\n    --parameters BranchTemplateName=template/cf-stack \\\n    --parameters CodeStarConnectionId=d1b54466-93f9-4482-a34d-a5bb39af7456 \\\n    --parameters NonProductionAccount=381492168999 \\\n    --parameters ProductionAccount=637423600999 \\\n    --parameters RepositoryName=code-pipeline \\\n    --parameters RepositoryOwner=craigjpickles \\\n    --parameters StackName=CodePipelineCDKDemo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversent%2Fcdk-code-pipeline-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fversent%2Fcdk-code-pipeline-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversent%2Fcdk-code-pipeline-demo/lists"}