diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 79f1bfc..2a38534 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.5.0] + +- Catesta template module changes + - CI/CD Changes: + - AWS: + - Each CodeBuild project now has its own `AWS::Logs::LogGroup` created with a configurable retention policy. + - Minor changes to formatting in CFNs to satisfy new `cfn-lint` requirements. + ## [2.4.0] - Catesta template module changes diff --git a/docs/Catesta.md b/docs/Catesta.md index b032dfc..083aa7f 100644 --- a/docs/Catesta.md +++ b/docs/Catesta.md @@ -2,7 +2,7 @@ Module Name: Catesta Module Guid: 6796b193-9013-468a-b022-837749af2d06 Download Help Link: NA -Help Version: 2.4.0 +Help Version: 2.5.0 Locale: en-US --- diff --git a/src/Catesta/Catesta.psd1 b/src/Catesta/Catesta.psd1 index cb83c95..30610ab 100644 --- a/src/Catesta/Catesta.psd1 +++ b/src/Catesta/Catesta.psd1 @@ -12,7 +12,7 @@ RootModule = 'Catesta.psm1' # Version number of this module. - ModuleVersion = '2.4.0' + ModuleVersion = '2.5.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildCC.yml b/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildCC.yml index 4e813ef..e5a152e 100644 --- a/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildCC.yml +++ b/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildCC.yml @@ -31,6 +31,11 @@ Parameters: Default: 30 Description: The number of minutes before a CodeBuild build will timeout. + LogRetentionInDays: + Type: Number + Default: 30 + Description: The number of days to retain the CodeBuild logs. + PrimaryBranchName: Type: String Default: main @@ -102,6 +107,7 @@ Metadata: Parameters: - CodeBuildBadgeEnabled - CodeBuildTimeoutInMinutes + - LogRetentionInDays # - CodeBuildEnvironment # - CodeBuildComputeType # - BuildSpecFile @@ -119,6 +125,8 @@ Metadata: default: Badge Enabled CodeBuildTimeoutInMinutes: default: Timeout in Minutes + LogRetentionInDays: + default: Log Retention in Days PrimaryBranchName: default: Primary Branch Name # CodeBuildEnvironment: @@ -165,7 +173,7 @@ Resources: IgnorePublicAcls: true RestrictPublicBuckets: true Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName S3BucketDevelopmentBuilds: @@ -194,7 +202,7 @@ Resources: IgnorePublicAcls: true RestrictPublicBuckets: true Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName # The IAM Role CodeBuild will run the container as @@ -222,7 +230,35 @@ Resources: - logs:CreateLogStream - logs:PutLogEvents Resource: - - '*' +<% + if ($PLASTER_PARAM_AWSOptions -eq 'ps') { +@' + - Fn::GetAtt: + - CodeBuildpsProjectLogGroup + - Arn +'@ + } +%> + +<% + if ($PLASTER_PARAM_AWSOptions -eq 'pwshcore') { +@' + - Fn::GetAtt: + - CodeBuildpwshcoreProjectLogGroup + - Arn +'@ + } +%> + +<% + if ($PLASTER_PARAM_AWSOptions -eq 'pwsh') { +@' + - Fn::GetAtt: + - CodeBuildpwshProjectLogGroup + - Arn +'@ + } +%> - PolicyName: CodePipelineS3 PolicyDocument: Version: '2012-10-17' @@ -292,8 +328,8 @@ Resources: - sts:AssumeRole Path: / ManagedPolicyArns: - - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole - - arn:aws:iam::aws:policy/AWSCodeBuildDeveloperAccess + - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole + - !Sub arn:${AWS::Partition}:iam::aws:policy/AWSCodeBuildDeveloperAccess # An SNS Topic used for CodeBuild status updates # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-topic.html @@ -301,7 +337,7 @@ Resources: Type: AWS::SNS::Topic Properties: Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName # The SNS Topic Policy @@ -354,7 +390,7 @@ Resources: RepositoryDescription: !Ref CodeCommitRepositoryDescription RepositoryName: !Ref CodeCommitRepositoryName Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName Triggers: <% @@ -398,8 +434,25 @@ Resources: <% if ($PLASTER_PARAM_AWSOptions -eq 'ps') { @' + + CodeBuildpsProjectLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Retain + Properties: + LogGroupName: + Fn::Sub: ${CodeCommitRepositoryName}-windows-powershell + RetentionInDays: !Ref LogRetentionInDays + Tags: + - Key: Service + Value: !Ref CodeCommitRepositoryName + # Windows PowerShell CodeBuild # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-webhookfilter.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html + # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html CodeBuildProjectWPS: Type: AWS::CodeBuild::Project Properties: @@ -418,6 +471,11 @@ Resources: - Name: s3_prefix Value: placeholder Type: PLAINTEXT + LogsConfig: + CloudWatchLogs: + GroupName: + Ref: CodeBuildpsProjectLogGroup + Status: ENABLED Name: !Join - '-' @@ -429,10 +487,8 @@ Resources: Location: !Sub 'https://git-codecommit.${AWS::Region}.amazonaws.com/v1/repos/${CodeCommitRepositoryName}' BuildSpec: buildspec_powershell_windows.yml Tags: - - Key: Purpose - Value: CodeCommitRepositoryName - Key: Service - Value: PowerShellBuildPipeline + Value: CodeCommitRepositoryName TimeoutInMinutes: !Ref CodeBuildTimeoutInMinutes '@ } @@ -441,8 +497,25 @@ Resources: <% if ($PLASTER_PARAM_AWSOptions -eq 'pwshcore') { @' + + CodeBuildpwshcoreProjectLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Retain + Properties: + LogGroupName: + Fn::Sub: ${CodeCommitRepositoryName}-windows-pwsh + RetentionInDays: !Ref LogRetentionInDays + Tags: + - Key: Service + Value: !Ref CodeCommitRepositoryName + # Windows Pwsh CodeBuild # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-webhookfilter.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html + # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html CodeBuildProjectWPwsh: Type: AWS::CodeBuild::Project Properties: @@ -461,6 +534,11 @@ Resources: - Name: s3_prefix Value: placeholder Type: PLAINTEXT + LogsConfig: + CloudWatchLogs: + GroupName: + Ref: CodeBuildpwshcoreProjectLogGroup + Status: ENABLED Name: !Join - '-' @@ -472,10 +550,8 @@ Resources: Location: !Sub 'https://git-codecommit.${AWS::Region}.amazonaws.com/v1/repos/${CodeCommitRepositoryName}' BuildSpec: buildspec_pwsh_windows.yml Tags: - - Key: Purpose - Value: CodeCommitRepositoryName - Key: Service - Value: PowerShellBuildPipeline + Value: CodeCommitRepositoryName TimeoutInMinutes: !Ref CodeBuildTimeoutInMinutes '@ } @@ -484,9 +560,25 @@ Resources: <% if ($PLASTER_PARAM_AWSOptions -eq 'pwsh') { @' + + CodeBuildpwshProjectLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Retain + Properties: + LogGroupName: + Fn::Sub: ${CodeCommitRepositoryName}-linux-pwsh + RetentionInDays: !Ref LogRetentionInDays + Tags: + - Key: Service + Value: !Ref CodeCommitRepositoryName + # Linux Pwsh CodeBuild # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-webhookfilter.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html CodeBuildProjectLPwsh: Type: AWS::CodeBuild::Project Properties: @@ -505,6 +597,11 @@ Resources: - Name: s3_prefix Value: placeholder Type: PLAINTEXT + LogsConfig: + CloudWatchLogs: + GroupName: + Ref: CodeBuildpwshProjectLogGroup + Status: ENABLED Name: !Join - '-' @@ -516,10 +613,8 @@ Resources: Location: !Sub 'https://git-codecommit.${AWS::Region}.amazonaws.com/v1/repos/${CodeCommitRepositoryName}' BuildSpec: buildspec_pwsh_linux.yml Tags: - - Key: Purpose - Value: CodeCommitRepositoryName - Key: Service - Value: PowerShellBuildPipeline + Value: CodeCommitRepositoryName TimeoutInMinutes: !Ref CodeBuildTimeoutInMinutes '@ } @@ -599,7 +694,7 @@ Resources: PrimaryBranchName: !Ref PrimaryBranchName Role: !GetAtt CodeCommitTriggeredLambdaFunctionIAMRole.Arn Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName Code: ZipFile: | @@ -676,7 +771,7 @@ Resources: LogGroupName: !Sub '/aws/lambda/${CodeCommitTriggeredLambdaWPS}' RetentionInDays: 60 Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName '@ } @@ -704,7 +799,7 @@ Resources: PrimaryBranchName: !Ref PrimaryBranchName Role: !GetAtt CodeCommitTriggeredLambdaFunctionIAMRole.Arn Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName Code: ZipFile: | @@ -781,7 +876,7 @@ Resources: LogGroupName: !Sub '/aws/lambda/${CodeCommitTriggeredLambdaWPwsh}' RetentionInDays: 60 Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName '@ } @@ -809,7 +904,7 @@ Resources: PrimaryBranchName: !Ref PrimaryBranchName Role: !GetAtt CodeCommitTriggeredLambdaFunctionIAMRole.Arn Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName Code: ZipFile: | @@ -886,7 +981,7 @@ Resources: LogGroupName: !Sub '/aws/lambda/${CodeCommitTriggeredLambdaL}' RetentionInDays: 60 Tags: - - Key: Purpose + - Key: Service Value: CodeCommitRepositoryName '@ } @@ -962,6 +1057,10 @@ Outputs: CodeBuildProjectWPS: Description: The name of the PS Windows CodeBuild Project. Value: !Ref CodeBuildProjectWPS + + CodeBuildProjectWPSURL: + Description: PS Windows CodeBuild URL + Value: !Sub "https://console.aws.amazon.com/codebuild/home?region=${AWS::Region}#/projects/${CodeBuildProjectWPS}/view" '@ } %> @@ -971,6 +1070,10 @@ Outputs: CodeBuildProjectWPwsh: Description: The name of the pwsh Windows CodeBuild Project. Value: !Ref CodeBuildProjectWPwsh + + CodeBuildProjectWPwshURL: + Description: pwsh Windows CodeBuild URL + Value: !Sub "https://console.aws.amazon.com/codebuild/home?region=${AWS::Region}#/projects/${CodeBuildProjectWPwsh}/view" '@ } %> @@ -980,6 +1083,10 @@ Outputs: CodeBuildProjectLPwsh: Description: The name of the PS Linux CodeBuild Project. Value: !Ref CodeBuildProjectLPwsh + + CodeBuildProjectLPwshURL: + Description: PS Linux CodeBuild URL + Value: !Sub "https://console.aws.amazon.com/codebuild/home?region=${AWS::Region}#/projects/${CodeBuildProjectLPwsh}/view" '@ } %> diff --git a/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildGit.yml b/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildGit.yml index 6345dd8..afbff99 100644 --- a/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildGit.yml +++ b/src/Catesta/Resources/AWS/CloudFormation/PowerShellCodeBuildGit.yml @@ -67,6 +67,11 @@ elseif ($PLASTER_PARAM_RepoType -eq 'BitBucket') { Default: 30 Description: The number of minutes before a CodeBuild build will timeout. + LogRetentionInDays: + Type: Number + Default: 30 + Description: The number of days to retain the CodeBuild logs. + # https://docs.aws.amazon.com/codebuild/latest/userguide/create-project.html#create-project-cli #CodeBuildEnvironment: # Type: String @@ -138,6 +143,7 @@ Metadata: Parameters: - CodeBuildBadgeEnabled - CodeBuildTimeoutInMinutes + - LogRetentionInDays #- CodeBuildEnvironment #- CodeBuildComputeType # - BuildSpecFile @@ -161,6 +167,8 @@ Metadata: default: Badge Enabled CodeBuildTimeoutInMinutes: default: Timeout in Minutes + LogRetentionInDays: + default: Log Retention in Days #CodeBuildEnvironment: # default: Container Type #CodeBuildComputeType: @@ -195,7 +203,7 @@ Resources: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: - Version: "2012-10-17" + Version: '2012-10-17' Statement: - Effect: Allow Principal: @@ -206,7 +214,7 @@ Resources: Policies: - PolicyName: CBCloudWatchPublishing PolicyDocument: - Version: "2012-10-17" + Version: '2012-10-17' Statement: - Effect: Allow Action: @@ -214,10 +222,39 @@ Resources: - logs:CreateLogStream - logs:PutLogEvents Resource: - - !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/<%=$PLASTER_PARAM_ModuleName%>*" +<% + if ($PLASTER_PARAM_AWSOptions -eq 'ps') { +@' + - Fn::GetAtt: + - CodeBuildpsProjectLogGroup + - Arn +'@ + } +%> + +<% + if ($PLASTER_PARAM_AWSOptions -eq 'pwshcore') { +@' + - Fn::GetAtt: + - CodeBuildpwshcoreProjectLogGroup + - Arn +'@ + } +%> + +<% + if ($PLASTER_PARAM_AWSOptions -eq 'pwsh') { +@' + - Fn::GetAtt: + - CodeBuildpwshProjectLogGroup + - Arn +'@ + } +%> + - PolicyName: CBS3ArtifactAccess PolicyDocument: - Version: "2012-10-17" + Version: '2012-10-17' Statement: - Effect: Allow Action: @@ -225,10 +262,10 @@ Resources: - s3:GetObject - s3:GetObjectVersion Resource: - - !Sub arn:aws:s3:::codepipeline-${AWS::Region}-* + - !Sub arn:${AWS::Partition}:s3:::codepipeline-${AWS::Region}-* - PolicyName: CBReportAccess PolicyDocument: - Version: "2012-10-17" + Version: '2012-10-17' Statement: - Effect: Allow Action: @@ -241,11 +278,23 @@ Resources: - codebuild:BatchPutCodeCoverages - codebuild:BatchPutTestCases Resource: - - !Sub "arn:aws:codebuild:${AWS::Region}:${AWS::AccountId}:report-group/<%=$PLASTER_PARAM_ModuleName%>*" + - !Sub "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:report-group/<%=$PLASTER_PARAM_ModuleName%>*" <% if ($PLASTER_PARAM_AWSOptions -eq 'ps') { @' + + CodeBuildpsProjectLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Retain + Properties: + LogGroupName: !Sub ${ProjectName}-windows-powershell + RetentionInDays: !Ref LogRetentionInDays + Tags: + - Key: Service + Value: !Ref ProjectName + # The CodeBuild Project configuration # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-webhookfilter.html @@ -266,6 +315,11 @@ Resources: # Type: !Ref CodeBuildEnvironment Type: WINDOWS_SERVER_2019_CONTAINER # Type: WINDOWS_CONTAINER + LogsConfig: + CloudWatchLogs: + GroupName: + Ref: CodeBuildpsProjectLogGroup + Status: ENABLED Name: !Join - '-' - - !Ref ProjectName @@ -297,6 +351,19 @@ Resources: <% if ($PLASTER_PARAM_AWSOptions -eq 'pwshcore') { @' + + CodeBuildpwshcoreProjectLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Retain + Properties: + LogGroupName: + Fn::Sub: ${ProjectName}-windows-pwsh + RetentionInDays: !Ref LogRetentionInDays + Tags: + - Key: Service + Value: !Ref ProjectName + # The CodeBuild Project configuration # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-webhookfilter.html @@ -317,6 +384,11 @@ Resources: Type: WINDOWS_SERVER_2019_CONTAINER # Type: !Ref CodeBuildEnvironment # Type: WINDOWS_CONTAINER + LogsConfig: + CloudWatchLogs: + GroupName: + Ref: CodeBuildpwshcoreProjectLogGroup + Status: ENABLED Name: !Join - '-' - - !Ref ProjectName @@ -348,6 +420,19 @@ Resources: <% if ($PLASTER_PARAM_AWSOptions -eq 'pwsh') { @' + + CodeBuildpwshProjectLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Retain + Properties: + LogGroupName: + Fn::Sub: ${ProjectName}-linux-pwsh + RetentionInDays: !Ref LogRetentionInDays + Tags: + - Key: Service + Value: !Ref ProjectName + # The CodeBuild Project configuration # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-webhookfilter.html @@ -367,6 +452,11 @@ Resources: Image: aws/codebuild/standard:7.0 #Type: !Ref CodeBuildEnvironment Type: LINUX_CONTAINER + LogsConfig: + CloudWatchLogs: + GroupName: + Ref: CodeBuildpwshProjectLogGroup + Status: ENABLED Name: !Join - '-' - - !Ref ProjectName @@ -494,18 +584,11 @@ Outputs: if ($PLASTER_PARAM_AWSOptions -eq 'ps') { @' CodeBuildpsProject: - Description: The name of the CodeBuild Project. + Description: The name of the Windows PowerShell CodeBuild Project. Value: !Ref CodeBuildpsProject CodeBuildpsURL: - Description: CodeBuild URL - Value: - Fn::Join: - - "" - - - https://console.aws.amazon.com/codebuild/home?region= - - Ref: AWS::Region - - "#/projects/" - - Ref: CodeBuildpsProject - - "/view" + Description: Windows PowerShell CodeBuild URL + Value: !Sub "https://console.aws.amazon.com/codebuild/home?region=${AWS::Region}#/projects/${CodeBuildpsProject}/view" '@ } %> @@ -513,18 +596,11 @@ Outputs: if ($PLASTER_PARAM_AWSOptions -eq 'pwshcore') { @' CodeBuildpwshcoreProject: - Description: The name of the CodeBuild Project. + Description: The name of the Windows pwsh CodeBuild Project. Value: !Ref CodeBuildpwshcoreProject CodeBuildpwshcoreURL: - Description: CodeBuild URL - Value: - Fn::Join: - - "" - - - https://console.aws.amazon.com/codebuild/home?region= - - Ref: AWS::Region - - "#/projects/" - - Ref: CodeBuildpwshcoreProject - - "/view" + Description: Windows pwsh CodeBuild URL + Value: !Sub "https://console.aws.amazon.com/codebuild/home?region=${AWS::Region}#/projects/${CodeBuildpwshcoreProject}/view" '@ } %> @@ -532,18 +608,11 @@ Outputs: if ($PLASTER_PARAM_AWSOptions -eq 'pwsh') { @' CodeBuildpwshProject: - Description: The name of the CodeBuild Project. + Description: The name of the Linux pwsh CodeBuild Project. Value: !Ref CodeBuildpwshProject CodeBuildpwshURL: - Description: CodeBuild URL - Value: - Fn::Join: - - "" - - - https://console.aws.amazon.com/codebuild/home?region= - - Ref: AWS::Region - - "#/projects/" - - Ref: CodeBuildpwshProject - - "/view" + Description: Linux pwsh CodeBuild URL + Value: !Sub "https://console.aws.amazon.com/codebuild/home?region=${AWS::Region}#/projects/${CodeBuildpwshProject}/view" '@ } %> diff --git a/src/Catesta/Resources/Module/plasterManifest.xml b/src/Catesta/Resources/Module/plasterManifest.xml index be843e4..770001c 100644 --- a/src/Catesta/Resources/Module/plasterManifest.xml +++ b/src/Catesta/Resources/Module/plasterManifest.xml @@ -18,7 +18,7 @@ Catesta 258a61ba-566b-4c3a-8230-c2b6861a1a8d - 2.4.0 + 2.5.0 Catesta Scaffolds a new PowerShell module project Jake Morrison diff --git a/src/Catesta/Resources/Vault/plasterManifest.xml b/src/Catesta/Resources/Vault/plasterManifest.xml index 507aa3d..b71b849 100644 --- a/src/Catesta/Resources/Vault/plasterManifest.xml +++ b/src/Catesta/Resources/Vault/plasterManifest.xml @@ -6,7 +6,7 @@ Catesta d531e058-52b8-4dd2-8162-01c95d1eb8f7 - 2.4.0 + 2.5.0 Catesta Scaffolds a new PowerShell SecretManagement extension vault module project Jake Morrison diff --git a/src/Tests/Integration/New-ModuleProject.Tests.ps1 b/src/Tests/Integration/New-ModuleProject.Tests.ps1 index 928a859..58be43e 100644 --- a/src/Tests/Integration/New-ModuleProject.Tests.ps1 +++ b/src/Tests/Integration/New-ModuleProject.Tests.ps1 @@ -265,6 +265,9 @@ Describe 'Module Integration Tests' { $cfnContent | Should -BeLike "*CodeBuildpsProject*" $cfnContent | Should -BeLike "*CodeBuildpwshcoreProject*" $cfnContent | Should -BeLike "*CodeBuildpwshProject*" + $cfnContent | Should -BeLike "*CodeBuildpsProjectLogGroup*" + $cfnContent | Should -BeLike "*CodeBuildpwshcoreProjectLogGroup*" + $cfnContent | Should -BeLike "*CodeBuildpwshProjectLogGroup*" $cfnContent | Should -BeLike "*GITHUB*" } #it @@ -374,6 +377,9 @@ Describe 'Module Integration Tests' { $cfnContent | Should -BeLike "*CodeBuildProjectWPS*" $cfnContent | Should -BeLike "*CodeBuildProjectWPwsh*" $cfnContent | Should -BeLike "*CodeBuildProjectLPwsh*" + $cfnContent | Should -BeLike "*CodeBuildpsProjectLogGroup*" + $cfnContent | Should -BeLike "*CodeBuildpwshcoreProjectLogGroup*" + $cfnContent | Should -BeLike "*CodeBuildpwshProjectLogGroup*" } #it It 'should not generate CFN if a non-supported repo type is chosen' { @@ -413,6 +419,114 @@ Describe 'Module Integration Tests' { } #it + It 'should only generate CodeBuild projects for the project type specified for a GitHub based module' { + $moduleParameters = @{ + VAULT = 'text' + ModuleName = 'modulename' + Description = 'text' + Version = '0.0.1' + FN = 'user full name' + CICD = 'CODEBUILD' + AWSOptions = 'ps' + RepoType = 'GITHUB' + ReadtheDocs = 'NONE' + License = 'MIT' + Changelog = 'CHANGELOG' + COC = 'CONDUCT' + Contribute = 'CONTRIBUTING' + Security = 'SECURITY' + CodingStyle = 'Stroustrup' + Help = 'Yes' + Pester = '5' + S3Bucket = 'PSGallery' + PassThru = $true + NoLogo = $true + } + $eval = New-ModuleProject -ModuleParameters $moduleParameters -DestinationPath $outPutPath + $eval | Should -Not -BeNullOrEmpty + + $codeBuildModuleFiles = Get-ChildItem -Path $outPutPathStar -Recurse -Force + + $codeBuildModuleFiles.Name.Contains('buildspec_powershell_windows.yml') | Should -BeExactly $true + $codeBuildModuleFiles.Name.Contains('buildspec_pwsh_linux.yml') | Should -BeExactly $false + $codeBuildModuleFiles.Name.Contains('buildspec_pwsh_windows.yml') | Should -BeExactly $false + $powershellContentPath = [System.IO.Path]::Combine($outPutPath, 'buildspec_powershell_windows.yml') + $powershellContent = Get-Content -Path $powershellContentPath -Raw + $powershellContent | Should -BeLike '*modulename*' + + $codeBuildModuleFiles.Name.Contains('configure_aws_credential.ps1') | Should -BeExactly $true + + $codeBuildModuleFiles.Name.Contains('install_modules.ps1') | Should -BeExactly $true + $installContentPath = [System.IO.Path]::Combine($outPutPath, 'install_modules.ps1') + $installContent = Get-Content -Path $installContentPath -Raw + $installContent | Should -BeLike '*$galleryDownload = $true*' + + $codeBuildModuleFiles.Name.Contains('PowerShellCodeBuildCC.yml') | Should -BeExactly $false + $codeBuildModuleFiles.Name.Contains('PowerShellCodeBuildGit.yml') | Should -BeExactly $true + + $cfnContentPath = [System.IO.Path]::Combine($outPutPath, 'CloudFormation', 'PowerShellCodeBuildGit.yml') + $cfnContent = Get-Content -Path $cfnContentPath -Raw + $cfnContent | Should -BeLike "*CodeBuildpsProject*" + $cfnContent | Should -Not -BeLike "*CodeBuildpwshcoreProject*" + $cfnContent | Should -Not -BeLike "*CodeBuildpwshProject*" + $cfnContent | Should -BeLike "*CodeBuildpsProjectLogGroup*" + $cfnContent | Should -Not -BeLike "*CodeBuildpwshcoreProjectLogGroup*" + $cfnContent | Should -Not -BeLike "*CodeBuildpwshProjectLogGroup*" + $cfnContent | Should -BeLike "*GITHUB*" + } #it + + It 'should only generate CodeBuild projects for the project type specified for a CodeCommit based module' { + $moduleParameters = @{ + VAULT = 'text' + ModuleName = 'modulename' + Description = 'text' + Version = '0.0.1' + FN = 'user full name' + CICD = 'CODEBUILD' + AWSOptions = 'ps' + RepoType = 'CodeCommit' + ReadtheDocs = 'NONE' + License = 'MIT' + Changelog = 'CHANGELOG' + COC = 'CONDUCT' + Contribute = 'CONTRIBUTING' + Security = 'SECURITY' + CodingStyle = 'Stroustrup' + Help = 'Yes' + Pester = '5' + S3Bucket = 'PSGallery' + PassThru = $true + NoLogo = $true + } + $eval = New-ModuleProject -ModuleParameters $moduleParameters -DestinationPath $outPutPath + $eval | Should -Not -BeNullOrEmpty + + $codeBuildModuleFiles = Get-ChildItem -Path $outPutPathStar -Recurse -Force + + $codeBuildModuleFiles.Name.Contains('buildspec_powershell_windows.yml') | Should -BeExactly $true + $codeBuildModuleFiles.Name.Contains('buildspec_pwsh_linux.yml') | Should -BeExactly $false + $codeBuildModuleFiles.Name.Contains('buildspec_pwsh_windows.yml') | Should -BeExactly $false + + $codeBuildModuleFiles.Name.Contains('configure_aws_credential.ps1') | Should -BeExactly $true + + $codeBuildModuleFiles.Name.Contains('install_modules.ps1') | Should -BeExactly $true + $installContentPath = [System.IO.Path]::Combine($outPutPath, 'install_modules.ps1') + $installContent = Get-Content -Path $installContentPath -Raw + $installContent | Should -BeLike '*$galleryDownload = $true*' + + $codeBuildModuleFiles.Name.Contains('PowerShellCodeBuildCC.yml') | Should -BeExactly $true + $codeBuildModuleFiles.Name.Contains('PowerShellCodeBuildGit.yml') | Should -BeExactly $false + + $cfnContentPath = [System.IO.Path]::Combine($outPutPath, 'CloudFormation', 'PowerShellCodeBuildCC.yml') + $cfnContent = Get-Content -Path $cfnContentPath -Raw + $cfnContent | Should -BeLike "*CodeBuildProjectWPS*" + $cfnContent | Should -Not -BeLike "*CodeBuildProjectWPwsh*" + $cfnContent | Should -Not -BeLike "*CodeBuildProjectLPwsh*" + $cfnContent | Should -BeLike "*CodeBuildpsProjectLogGroup*" + $cfnContent | Should -Not -BeLike "*CodeBuildpwshcoreProjectLogGroup*" + $cfnContent | Should -Not -BeLike "*CodeBuildpwshProjectLogGroup*" + } #it + } #aws_codeBuild Context 'Azure Pipelines' {