TaskCat CI/CD Pipeline for AWS CloudFormation on AWS

Partner Solution Deployment Guide

QS

October 2022
Shivansh Singh, Tony Vattathil, and Troy Lindsay, AWS Integration & Automation team

Refer to the GitHub repository to view source files, report bugs, submit feature ideas, and post feedback about this Partner Solution. To comment on the documentation, refer to Feedback.

This Partner Solution was created by Amazon Web Services (AWS). Partner Solutions are automated reference deployments that help people deploy popular technologies on AWS according to AWS best practices. If you’re unfamiliar with AWS Partner Solutions, refer to the AWS Partner Solution General Information Guide.

Overview

This AWS Solution deploys a TaskCat continuous integration/continuous deployment (CI/CD) pipeline for AWS CloudFormation on the Amazon Web Services (AWS) Cloud. It is for users that want to automatically test and deploy CloudFormation templates in a GitHub repository. For more information, refer to What is TaskCat?.

Costs and licenses

There is no cost to use this AWS Solution, but you will be billed for any AWS services or resources that this AWS Solution deploys. For more information, refer to the AWS Partner Solutions General Information Guide.

Architecture

Deploying this Partner Solution with default parameters builds the following TaskCat environment in the AWS Cloud.

Architecture
Figure 1. AWS Partner Solution architecture for TaskCat on AWS

As shown in Figure 1, this AWS Solution sets up the following:

  • AWS CodePipeline to automate a CI/CD pipeline with source, build/test, and deploy stages.

  • In the source stage, a Git user pushes a commit, which invokes CodePipeline. CodePipeline retrieves source code and stores it in an Amazon Simple Storage Service (Amazon S3) artifacts bucket.

  • In the build/test stage:

    • AWS CodeBuild retrieves code from an artifacts S3 bucket and runs TaskCat.

    • TaskCat deploys and tests CloudFormation templates and saves test results to a reports S3 bucket.

    • AWS Secrets Manager stores credentials used by CodeBuild for Git access.

  • In the deploy stage, a Lambda function merges tested code with the release branch in the GitHub repository.

Deployment options

This AWS Solution provides the following deployment option:

Predeployment steps

Configuring your GitHub repository

This project requires a GitHub repository that contains the AWS CloudFormation templates that you want to test as part of the CI/CD pipeline as well as a TaskCat configuration file.

  • Templates folder: All CloudFormation template files must be stored in a folder named templates. Both JSON and YAML format CloudFormation templates are supported.

  • TaskCat config file: The config file must be named .taskcat.yml and stored in the root of the repository. It should specify the name of the template in the templates folder that needs to be tested, and the configuration of each test that TaskCat should run. For more information about how to configure this file, refer to Config files.

If you want to give TaskCat a trial run, you can download and use any of the AWS CloudFormation templates and configuration files in the Partner Solutions GitHub organization at https://github.com/aws-quickstart.

Configuring your GitHub access

  1. Log into your GitHub account at https://github.com/.

  2. Create a personal access token (also known as an OAuth2 token) and grant it the admin:repo_hook and repo scopes. If you already have a token with these permissions, you can use that. You can find a list of all of your personal access tokens at https://github.com/settings/tokens.

  3. Make a note of the following information in GitHub, as these values will be used as inputs when deploying the TaskCat CI/CD pipeline:

    • Personal access token name.

    • Repository owner – The GitHub organization or user that owns the repository.

    • Repository name – This repository should have the folder structure and files described earlier in the [Repository] section.

    • Source branch name – The branch that CodePipeline should monitor for changes.

    • Release branch name – The branch that the source branch will be merged into after a successful test.

  4. Create an AWS Secrets Manager secret for storing sensitive and/or deployment‑specific input parameter override values for the TaskCat tests. The name of this secret must match the name of the repository, and it must be created in the same Region as the TaskCat CI/CD pipeline.

Deployment steps

  1. Sign in to your AWS account, and launch this Partner Solution, as described under Deployment options. The AWS CloudFormation console opens with a prepopulated template.

  2. Choose the correct AWS Region, and then choose Next.

  3. On the Create stack page, keep the default setting for the template URL, and then choose Next.

  4. On the Specify stack details page, change the stack name if needed. Review the parameters for the template. Provide values for the parameters that require input. For all other parameters, review the default settings and customize them as necessary. When you finish reviewing and customizing the parameters, choose Next.

    Unless you’re customizing the Partner Solution templates or are instructed otherwise in this guide’s Predeployment section, don’t change the default settings for the following parameters: QSS3BucketName, QSS3BucketRegion, and QSS3KeyPrefix. Changing the values of these parameters will modify code references that point to the Amazon Simple Storage Service (Amazon S3) bucket name and key prefix. For more information, refer to the AWS Partner Solutions Contributor’s Guide.
  5. On the Configure stack options page, you can specify tags (key-value pairs) for resources in your stack and set advanced options. When you finish, choose Next.

  6. On the Review page, review and confirm the template settings. Under Capabilities, select all of the check boxes to acknowledge that the template creates AWS Identity and Access Management (IAM) resources that might require the ability to automatically expand macros.

  7. Choose Create stack. The stack takes about 15 minutes to deploy.

  8. Monitor the stack’s status, and when the status is CREATE_COMPLETE, the TaskCat CI/CD Pipeline for AWS CloudFormation deployment is ready.

  9. To view the created resources, choose the Outputs tab.

Postdeployment steps

  1. Sign in to the AWS Management Console and open the CloudFormation console.

  2. In the left navigation pane, choose Stacks.

  3. On the Stacks page, choose the TaskCat CI/CD stack.

  4. Choose the Outputs tab.

  5. Choose the URL link to load the new CI/CD pipeline running in the CodePipeline console. Figure 2 shows the pipeline running in the CodePipeline console.

CodePipeline CI/CD pipeline
Figure 2. CI/CD pipeline for the templates in your GitHub repository

Troubleshooting

For troubleshooting common Partner Solution issues, refer to the AWS Partner Solution General Information Guide and Troubleshooting CloudFormation.

Resources

Customer responsibility

After you deploy a Partner Solution, confirm that your resources and services are updated and configured—including any required patches—to meet your security and other needs. For more information, refer to the Shared Responsibility Model.

Feedback

To submit feature ideas and report bugs, use the Issues section of the GitHub repository for this Partner Solution. To submit code, refer to the Partner Solution Contributor’s Guide. To submit feedback on this deployment guide, use the following GitHub links:

Notices

This document is provided for informational purposes only. It represents current AWS product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS products or services, each of which is provided "as is" without warranty of any kind, whether expressed or implied. This document does not create any warranties, representations, contractual commitments, conditions, or assurances from AWS, its affiliates, suppliers, or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.

The software included with this paper is licensed under the Apache License, version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at https://aws.amazon.com/apache2.0/ or in the accompanying "license" file. This code is distributed on an "as is" basis, without warranties or conditions of any kind, either expressed or implied. Refer to the License for specific language governing permissions and limitations.