This file contains the steps to follow to test any changes to the CFN resources.
- Install AtlasCLI and configure the default profile on your machine as the scripts use Atlas CLI
- Ensure AWS CLI, CFN CLI, SAM CLI are installed and configured correctly for your AWS account
- Configure an Atlas profile secret in AWS account with your API keys. Refer README for more information on how to do this
- Have Docker running on your machine
- Refer to the prerequisites for your resource in the
cfn-resources/[resource-folder]/test
- Run the following command to build the resource and start AWS SAM
cd cfn-resources/[resource-folder] && make build && sam local start-lambda --skip-pull-image
- Open a new terminal session
- Generate the cfn test inputs file and required Atlas resources. Each resource may require specific environment variables to be defined, you will find this under
cfn-resources/[resource-folder]/test/cfn-test-create-inputs.sh
. Generated input files also assume you have adefault
profile defined which will be used.
./../../cfn-testing-helper.sh <resource-folder>
- Run cfn test
cd cfn-resources/[resource-folder]
cfn test --function-name TestEntrypoint --verbose
- Ensure all steps above are complete
- Publish the resource to the AWS Private registry
cfn submit --set-default
- Getting test parameters:
- Option 1 [Recommended]: Re-use params from
cfn-resources/[resource-folder]/inputs/inputs_1_create.template.json
generated as part of prerequisites - Option 2: Run again
cfn-testing-helper
to create new parameters. This will create some required resources for you in your configured Atlas account
- Option 1 [Recommended]: Re-use params from
- Update template in
examples/[resource-folder]/[resource-name].json
with your changes (if any) AND required params from last step - Login to AWS account -> CloudFormation -> click on Create Stack dropdown and select (with new resources)
- Upload the updated template: You can either upload the updated file OR select Create template in Designer
- Add a Stack name on Specify stack details page and provide any required parameters for your resource, if any
- Click on Next and follow UI prompts to configure stack options if needed. Finally, click on Submit. Your stack should now be created and resource creation
IN_PROGRESS
- In AWS CloudFormation, navigate to your stack and click on Update. You can use the current template or edit in designer
- Update any parameters or outputs for your template
- Follow UI prompts and Submit
- In AWS CloudFormation, navigate to your stack and click on Delete
- Refer to the success criteria for your resource first in the
cfn-resources/[resource-folder]/test
. - Stack Outputs should show required data correctly based on the template
- Create: Stack should complete successfully and resource should be created and correctly configured in Atlas account as per template
- Update: Stack should complete successfully and resource should be updated and correctly configured in Atlas account as per template
- Delete: Stack should complete successfully and resource should be deleted from your Atlas account