Package: pipegen
pipegenA CodePipeline/CodeBuild CI/CD Pipeline creator + deployer.InstallationInstall using pip/pypi:pipinstallpipegenUsageDeploying your pipeline with pipegen:pipegendeploy--configCONFIG_FILE--stack-nameNAME_OF_STACK[--varKEY=VALUE[--varKEY=VALUE]]To output compiled configuration:pipegendumpconfig--configCONFIG_FILE[--varKEY=VALUE[--varKEY=VALUE]]To output compiled CloudFormation template:pipegendumptemplate--configCONFIG_FILE[--varKEY=VALUE[--varKEY=VALUE]]Configuration SchemaThe schema is broken down into several sections:Base/shared config used across many of the resourcesSource configurationPipeline configurationBase ConfigBase config is used across multiple resources deployed usingpipegen, or can be used to override some defaults.Full schema is documented below, required elements are specified with(R), and defaults are indicated.config:s3_bucket:(R) the name of a S3 bucket to store artifacts in (source copies,codebuild artifacts, etc)kms_key_arn:(R) the ARN of a KMS key to encrypt all resources withcodepipeline:restart_execution_on_update:whether or not to restart an in-progressCodePipeline execution if the pipeline isupdated (default:false)codebuild:compute_type: the default compute type to use (default:BUILD_GENERAL1_SMALL)image:the default docker image to use(default:aws/codebuild/amazonlinux2-x86_64-standard:3.0)log_group:enabled:whether or not to enable CloudWatch logs for CodeBuildprojects (default:true)create: whether or not to create the CloudWatch log group (default:true).Disable if you have created the log group externally.name:the name of the CloudWatch log group for the pipeline(default:random generated name based on the stack name)retention: A number in days to retain logs (default:null, logs are retainedindefinitely)iam: a list of IAM statements to add to the CodeBuild role (default:null).Use if your CodeBuild projects need to manipulate AWS resourcesIAM ExamplesBy default,pipegenconfigures CodeBuild with the minimal amount of permissions in order to run, decrypt your artifacts from KMS, pull images from ECR (if configured), write logs to CloudWatch logs (if configured).  If you require additional IAM permissions, you can specify them using the following syntax:config:iam:-standard IAM statementFor example, adding permissions to upload files to S3 in your build:config:iam:-Effect:AllowAction:-s3:PutObjectResource:-my-bucket-name/*Source configurationSource configuration defines where your project's code comes from.Two top-level options are supported currently:CodeCommit, AWS' hosted git serviceCodeStar Connections, to use Github.com, GitHub Enterprise (GHE), or BitBucketPipelines can use multiple source repositories mixed from either provider.CodeCommitThe following describes source configuration for using CodeCommit.Full schema is documented below, required elements are specified with(R), and defaults are indicated.sources:-name:(R) a unique name for this source entryfrom:(R) the provider to use. use `CodeCommit` for CodeCommitrepository:(R) the name of the repositorybranch:(R) the branch to build frompoll_for_source_changes: whether CodePipeline should poll for updates (default:false)event_for_source_changes:whether to use CloudWatch events/EventBridge todetect updates (default:true)Note: if you want the pipeline to trigger a build when the repository is pushed to, eitherpoll_for_source_changesorevent_for_source_changesshould be set totrue(event_for_source_changesis preferred).CodeStar ConnectionsThe following describes source configuration for using CodeStar Connections to get your source from Github.com, GHE or BitBucket.In order to use CodeStar connections, you must have configurared a connection separately and prior to deploying the pipeline stack.Full schema is documented below, required elements are specified with(R), and defaults are indicated.sources:-name:(R) a unique name for this source entryfrom:(R) the provider to use. use `CodeCommit` for CodeCommitrepository:(R) the name of the repositorybranch:(R) the branch to build fromconnection_arn:(R) the codestar connection ARN to use to pull changes throughPipeline configurationThe following describes the pipeline's build configuration.Full schema is documented below, required elements are specified with(R), and defaults are indicated.stages:-name:(R) a unique name for this deploy stage, e.g. "Build", "Deploy", etcenabled: whether or not this stage is enabled (default:true)actions:-name:(R) a unique name for this action, e.g. "Build", "DeployToStaging","DeleteProduction", etcprovider:the provider to use to perform the action,allowed values: CodeBuild (default:CodeBuild).Note:list may be extended in futurebuildspec:a path to a CodeBuild buildspec YAML file from your firstrepository's root directorycommands:a list of commands to run as part of your buildspecartifacts:a list of file path artifacts to store after your buildcompute_type: the compute type to use (default:config.codebuild.compute_type's value)image: the docker image to use (default:config.codebuild.image's value)environment:a hash of "key:value" variables to provide to the buildinput_artifacts:a list of other build actions `Name` fields, who's artifactsto bring in to your buildBuildSpec / Commands / ArtifactsWhen using CodeBuild, you can either:not specifybuildspec,commands, orartifactsfields, which will default to usingbuildspec.ymlin the primary source's root directory for build instructions,provide abuildspecfield, to specify a file in your repository that contains build instructions,providecommands(andartifactsif needed) for pipegen to generate a buildspec for you inline.The template reference for a CodeBuild buildspec can be found here:https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html. If you specifycommands, pipegen uses buildspec v0.2 to generate a buildspec inline.Environment VariablesBy default, pipegen provides two environment variables to your build project:AWS_DEFAULT_REGIONandAWS_REGION, both are set to the AWS region that you deploy to (CloudFormation equivalent toAWS::Region). Either of these can be overridden by specifying those keys with alternative values.You can provide additional environment variables as needed using the following syntax:environment:KEY:VALUEMY_VARIABLE:my valueInput ArtifactsEvery CodeBuild project that pipegen configures will have all sources configured added as inputs, meaning that each build will have access to each repository.If you are building using a "build then deploy" pattern, you may want to pass build artifacts through to deployment stages. You can achieve this with a syntax similar to the following:stages:-name:Buildactions:-name:MyBuildStep-name:Deployactions:-name:Deploycommmands:-bin/deployinput_artifacts:-MyBuildStep# << Note that this matches the action name aboveVariables and Importspipegensupports two special syntaxes for most configuration entries.VariablesAny--var key=namepassed to the CLI can be used inside your configuration file, to vary behaviour at runtime using a syntax like{{vars.KEY}}. This is commonly used to vary things like the branch used. For example:config.yml:sources:-name:Sourcefrom:CodeCommitrepository:my-repobranch:{{vars.BranchName}}pipegen cli:pipegendeploy--varBranchName=main...Further, as configuration for pipegen is evaluated using jinja2, you can use variables to determine other values. Commonly this can be used to enable/disable stages based on branch (e.g. only running a production deploy for themainbranch).stages:-name:Productionenabled:{{vars.BranchName == "main"}}Importspipegensupports importing values fromCloudFormation exportsusing syntax likeimport:ImportName.Example:config:s3_bucket:import:S3BucketNamekms_key_arn:import:KmsKeyArnExample configurationBuilding from CodeCommit---config:s3_bucket:my-s3-bucketkms_key_arn:arn:aws:kms:REGION:ACCOUNT:key/KEY-IDsources:-name:Sourcefrom:CodeCommitrepository:my-repobranch:{{vars.BranchName}}stages:-name:Buildactions:-name:Buildprovider:CodeBuildbuildspec:buildspecs/build.yml-name:DevDeployactions:-name:Deployprovider:CodeBuildbuildspec:buildspecs/deploy.ymlenvironment:TARGET_ENVIRONMENT:devinput_artifacts:-Build-name:ProdDeployenabled:{{vars.BranchName == "main"}}actions:-name:ProdDeployprovider:CodeBuildbuildspec:buildspecs/deploy.ymlenvironment:TARGET_ENVIRONMENT:prodinput_artifacts:-BuildBuilding from CodeStar/Github.com---config:s3_bucket:import:S3BucketNamekms_key_arn:import:KMSKeyArncodebuild:log_group:retention:7# (days)sources:-name:codebuild-testfrom:CodeStarConnectionrepository:samjarrett/codebuild-testbranch:mainconnection_arn:arn:aws:codestar-connections:REGION:ACCOUNT:connection/CONNECTION-IDstages:-name:Buildactions:-name:Buildprovider:CodeBuildcommands:-make buildartifacts:-build/*-name:Deployactions:-name:Deployprovider:CodeBuildcommands:-make deployinput_artifacts:-Build