Question 2
Domain 1: SDLC AutomationA company has an application and a CI/CD pipeline. The CI/CD pipeline consists of an AWS CodePipeline pipeline and an AWS CodeBuild project. The CodeBuild project runs tests against the application as part of the build process and outputs a test report. The company must keep the test reports for 90 days. Which solution will meet these requirements?
Correct answer: B
Explanation
AWS CodeBuild test reports are generated in a report group, and the buildspec can define the report "path and format" for those reports. Because CodeBuild report retention is not the same as long-term archival, copying the reports to Amazon S3 on build completion and using an S3 Lifecycle rule to "expire the objects after 90 days" preserves them for the required period.
Why each option is right or wrong
A. Add a new stage in the CodePipeline pipeline after the stage that contains the CodeBuild project. Create an Amazon S3 bucket to store the reports. Configure an S3 deploy action type in the new CodePipeline stage with the appropriate path and format for the reports.
S3 deploy stages move pipeline artifacts, not native CodeBuild test report groups automatically.
B. Add a report group in the CodeBuild project buildspec file with the appropriate path and format for the reports. Create an Amazon S3 bucket to store the reports. Configure an Amazon EventBridge rule that invokes an AWS Lambda function to copy the reports to the S3 bucket when a build is completed. Create an S3 Lifecycle rule to expire the objects after 90 days.
AWS CodeBuild test reports are defined in a report group via the buildspec `reports` section, where the report `files`, `base-directory`, and `file-format` are specified; CodeBuild itself does not provide a 90-day retention control for keeping those artifacts long term. Under Amazon S3 lifecycle management, an `Expiration` rule can automatically delete objects after a set number of days, so copying the reports to S3 on the `CodeBuild Build State Change` event and setting expiration to `90` days satisfies the retention requirement exactly.
C. Add a new stage in the CodePipeline pipeline. Configure a test action type with the appropriate path and format for the reports. Configure the report expiration time to be 90 days in the CodeBuild project buildspec file.
CodePipeline test actions and report expiration settings do not provide 90-day report archival here.
D. Add a report group in the CodeBuild project buildspec file with the appropriate path and format for the reports. Create an Amazon S3 bucket to store the reports. Configure the report group as an artifact in the CodeBuild project buildspec file. Configure the S3 bucket as the artifact destination. Set the object expiration to 90 days.
CodeBuild reports are not simply exported as standard build artifacts by declaring the report group.