# This code launches the pipeline resources i.e., codecommit repository, codebuild project and code pipeline. # ? 2023 Amazon Web Services, Inc. or its affiliates. All Rights Reserved. # This AWS Content is provided subject to the terms of the AWS Customer Agreement available at # http://aws.amazon.com/agreement or other written agreement between Customer and either # Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both. AWSTemplateFormatVersion: 2010-09-09 Description: Creation of codecommit repository, Codebuild Project and CodePipeline Parameters: ProjectName: Description: The name of the project for which pipelines are to be created by the master pipeline. Type: String TechStack: Description: The technology stack of the project for which pipelines are to be created by the master pipeline. e.g. java, cloudformation Type: String AllowedValues: - java - cloudformation - python - terraform Resources: CodeRepository: Type: 'AWS::CodeCommit::Repository' Properties: RepositoryName: !Join - '-' - - !Ref 'ProjectName' - 'Repo' RepositoryDescription: !Join - '' - - 'Code repository for the Project ' - !Ref 'AWS::StackName' Code: BranchName: main S3: Bucket: '{{resolve:ssm:S3TemplateBucketName}}' Key: !Join - '' - - 'generated-artifacts' - '/' - !Ref 'TechStack' - '/' - !Ref 'ProjectName' - '/' - !Ref 'TechStack' - '-templates.zip' DeployResources: Type: AWS::CodeBuild::Project Properties: Name: !Join - '-' - - !Ref 'ProjectName' - 'Build' ServiceRole: '{{resolve:ssm:CodeBuildRoleARN}}' EncryptionKey: !Sub 'arn:aws:kms:${AWS::Region}:${AWS::AccountId}:alias/aws/s3' Artifacts: Type: CODEPIPELINE Environment: ComputeType: BUILD_GENERAL1_SMALL Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0 Type: LINUX_CONTAINER EnvironmentVariables: - Name: BUILD_ARTIFACT_BUCKET Value: '{{resolve:ssm:DeploymentArtifactBucketName}}' - Name: TECH_STACK Value: !Ref TechStack Source: Type: CODEPIPELINE BuildSpec: buildspec.yml DependsOn: CodeRepository CodePipeline: Type: AWS::CodePipeline::Pipeline Properties: Name: !Join - '-' - - !Ref 'ProjectName' - 'Pipeline' RoleArn: '{{resolve:ssm:CodePipelineServiceRoleARN}}' ArtifactStore: Type: S3 Location: '{{resolve:ssm:DeploymentArtifactBucketName}}' Stages: - Name: CodeCheckout Actions: - InputArtifacts: [] Name: code RunOrder: 1 ActionTypeId: Category: Source Owner: AWS Version: 1 Provider: CodeCommit OutputArtifacts: - Name: SourceCodeOutputArtifact Configuration: RepositoryName: !Join - '-' - - !Ref 'ProjectName' - 'Repo' BranchName: main PollForSourceChanges: "true" - Name: Build Actions: - Name: ResourceBuild ActionTypeId: Category: Build Owner: AWS Version: 1 Provider: CodeBuild InputArtifacts: - Name: SourceCodeOutputArtifact OutputArtifacts: [] Configuration: ProjectName: !Ref DeployResources RunOrder: 2