--- layout: false .left-colum[ # What is taskcat? ] .right-column[ **taskcat** is a tool that tests AWS CloudFormation templates. It deploys your AWS CloudFormation template in multiple AWS Regions and generates a report with a pass/fail grade for each region. You can specify the regions and number of Availability Zones you want to include in the test, and pass in parameter values from your AWS CloudFormation template. taskcat was developed by the aws-ia team to test AWS CloudFormation templates that automatically deploy workloads on AWS. ] --- ### CLI The cli is self documenting by using `--help`. The most common use of taskcat is for executing function tests of CloudFormation templates. The command for this is: ```bash taskcat test run ``` add `--help` to see the supported flags and arguments ```bash optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -q, --quiet reduce output to the minimum -d, --debug adds debug output and tracebacks --profile _PROFILE set the default profile used. commands: delete - [ALPHA] Deletes an installed package in an AWS account/region deploy - [ALPHA] installs a stack into an AWS account/region lint - checks CloudFormation templates for issues using cfn-python-lint list - [ALPHA] lists taskcat jobs with active stacks package - packages lambda source files into zip files. If a dockerfile is present in asource folder, it will be run prior to zipping the contents test - Performs functional tests on CloudFormation templates. update-ami - Updates AMI IDs within CloudFormation templates upload - Uploads project to S3. ``` --- ### Python Taskcat can be imported into Python and used in the testing framework of your choice. ``` from taskcat.testing import CFNTest test = CFNTest.from_file(project_root='./template_dir') with test as stacks: # Calling 'with' or 'test.run()' will deploy the stacks. for stack in stacks: print(f"Testing {stack.name}") bucket_name = "" for output in stack.outputs: if output.key == "LogsBucketName": bucket_name = output.value break assert "logs" in bucket_name assert stack.region.name in bucket_name print(f"Created bucket: {bucket_name}") ``` --- ## Config files taskcat has several configuration files which can be used to set behaviors in a flexible way. ### Global config `~/.taskcat.yml` provides global settings that become defaults for all projects. Please see our [schema reference](docs/schema/taskcat_schema.html) for specific configuration options that are available. ### Project config `
/.taskcat.yml` provides project specific configuration. Please see our [schema reference](docs/schema/taskcat_schema.html) for specific configuration options that are available. --- ## Inheritence Generally: - Least specific over most specific unless defined Parameters: - Most specific over least specific --- ### Examples `~/.taskcat.yml` (Global config) ```yaml general: s3_bucket: my-globally-defined-bucket parameters: KeyPair: my-global-ec2-keypair ```
(plus)
Given a simple project config: `/path/to/project/.taskcat.yml` ```yaml project: name: my-project regions: - us-east-2 tests: default: template: ./template.yaml ``` ---
(equals)
```yaml tests: default: template: ./template.yaml s3_bucket: my-globally-defined-bucket # from global parameters: # from global KeyPair: my-global-ec2-keypair # from global ``` Heirarchy: - Global - Project - Test Parameter Heirarchy: - Global - Project - Test - Override file --- ## Parameter overrides - Common parameters - Sensitive data --- ## Psuedo Parameters | Psuedo-Parameter | Example Value passed to the CloudFormation stack| | ------------- | ------------- | ------------- | | `$[taskcat_autobucket]` | taskcat-tag-sample-taskcat-project-5fba6597| | `$[taskcat_genaz_1]` | "us-east-1a" | | `$[taskcat_genaz_2]` | "us-east-1a,us-east-1b" | | `$[taskcat_genaz_3]` | "us-east-1a,us-east-1b,us-east-1c" | | `$[taskcat_genpass_8A]` | tI8zN3iX8 | | `$[taskcat_genpass_8S]` | mA5@cB5! | | `$[taskcat_random-string]` | yysuawpwubvotiqgwjcu | | `$[taskcat_random-numbers]` | 56188163597280820763 | | `$[taskcat_genuuid]` | 1c2e3483-2c99-45bb-801d-8af68a3b907b | | `$[taskcat_getval_MyAppPassword]` | _Dynamically generated password for the MyAppPassword parameter_ | | `$[taskcat_current_region]` | "us-east-2" | | `$[taskcat_project_name]` | "my-example-project" | | `$[taskcat_test_name]` | "cluster-with-windows-ad" | | `$[taskcat_ssm_/path/to/ssm/parameter]` | _SSM Parameter Value_ | | `$[taskcat_secretsmanager_SecretNameOrARN]` |_Value from SecretsManager_ | --- #### From: (defined in taskcat.yaml') ``` InstanceType: t2.small AvailablityZones: $[taskcat_genaz_2] RandomString: $[taskcat_random-string] RandomNumbers: $[taskcat_random-numbers] GenerateUUID: $[taskcat_genuuid] Password: $[taskcat_genpass_8A] PasswordConfirm: $[taskcat_getval_Password] ``` #### To: (At runtime passed to cloudformation API) ``` InstanceType: t2.small AvailablityZones: us-east-1a,us-east-1b RandomString: yysuawpwubvotiqgwjcu RandomNumbers: 56188163597280820763 GenerateUUID: 1c2e3483-2c99-45bb-801d-8af68a3b907b Password: tI8zN3iX8 PasswordConfirm: tI8zN3iX8 ``` --- # Q&A (open forum)